Remove stream usage from Symtab.lookupPackage()
Archie Cobbs
archie.cobbs at gmail.com
Wed Feb 22 03:30:52 UTC 2023
On Tue, Feb 21, 2023 at 6:24 PM christoph.dreis at freenet.de <
christoph.dreis at freenet.de> wrote:
> I'm currently profiling some compilation phases of internal projects and
> noticed in allocation profiles that Symtab.lookupPackage takes up ~2%
> overall. The majority of this is spent in .stream().anyMatch() usages to
> find out if the given module symbol depends on the unnamed module.
>
Straightforward patch, but it's disappointing that unrolling a Stream into
the equivalent for loop makes it noticeably faster (how much?).
This also brings up larger philosophical questions about code style vs.
performance. If using a Stream somewhere makes for more
clean/elegant/understandable code, but is slower, how to weigh the
trade-off? Maybe this has been discussed before on this list before I
joined. Maybe we should assign this bug to the hotspot group :)
On this same topic, this pattern which appears constantly in the compiler
always makes me kind of quizzical:
JCExpression expr = TreeInfo.skipParens(tree.expr);
if (expr.hasTag(APPLY)) {
JCMethodInvocation apply = (JCMethodInvocation)expr;
...
}
Is instanceof really that much slower? Maybe it was once, long ago, and
this is a legacy thing?
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230221/0edbb902/attachment.htm>
More information about the compiler-dev
mailing list