RFR 8220792: JavacFileManager.list() performance
Jonathan Gibbons
jonathan.gibbons at oracle.com
Tue Mar 26 20:52:23 UTC 2019
On 03/18/2019 11:14 AM, Ron Shapiro wrote:
> Hi,
>
> Please review this change to improve the performance of
> JavacFileManager.list().
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8220792
> webrev: http://cr.openjdk.java.net/~ronsh/8220792/webrev.00/
> <http://cr.openjdk.java.net/%7Eronsh/8220792/webrev.00/>
>
> Thanks,
> Ron
Ron,
Look at these lines:
984 // First collect all of the containers that don't maintain their own
index on
985 // RelativeDirectory. These need to always be included for all mappings
986 java.util.List<PathAndContainer> nonIndexingContainers = new
ArrayList<>();
987 for (PathAndContainer pathAndContainer : allPathsAndContainers) {
988 if (!(pathAndContainer.container instanceof ArchiveContainer)) {
989 nonIndexingContainers.add(pathAndContainer);
990 }
991 }
The "instanceof" on line 988 does not generally match the comment about
"all of the
containers that don't maintain their own index".
Digging into the Mercurial histroy a bit, I see that the package index
was added as a
performance update in JDK-8150461. What if we were to do similar fixes
on other
subtypes of Container? Your code would be more future-proof if the
instanceof was
replaced by a new method on the Container interface, indicating if the
container
maintained its own map.
That being said, it would be even better if the "master index" was
automatically updated
whenever any directory was found in any container. That way, the master
index would lazily
learn about the contents of the JRTImageContainer and DirectoryContainer
as well.
-- Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20190326/e09cb6d2/attachment-0001.html>
More information about the compiler-dev
mailing list