-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the speed of preorder operation on IR #11019
Improve the speed of preorder operation on IR #11019
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to remove the old preorder()
method altogether as the new callback approach seems sufficient for all the use-cases.
Is there any effect on performance? Any benchmarks affected?
Shows ~10% speed improvement during the compilation
What methodology is used to measure these 10%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In runtime-benchmarks
, there are benchmarks that measure speed of the compilation. This is the list:
[info] org.enso.compiler.benchmarks.exportimport.ExportImportResolutionBenchmark.importsAndExportsResolution
[info] org.enso.compiler.benchmarks.exportimport.ExportImportResolutionBenchmark.importsResolution
[info] org.enso.compiler.benchmarks.inline.InlineCompilerBenchmark.longExpression
[info] org.enso.compiler.benchmarks.inline.InlineCompilerErrorBenchmark.expressionWithErrors
[info] org.enso.compiler.benchmarks.module.ImportStandardLibrariesBenchmark.importStandardLibraries
[info] org.enso.compiler.benchmarks.module.ManyErrorsBenchmark.manyErrors
[info] org.enso.compiler.benchmarks.module.ManyLocalVarsBenchmark.longMethodWithLotOfLocalVars
[info] org.enso.compiler.benchmarks.module.ManyNestedBlocksBenchmark.manyNestedBlocks
[info] org.enso.compiler.benchmarks.module.ManySmallMethodsBenchmark.manySmallMethods
(Get this list via runtime-benchmarks/run -l
)
Would you please verify the difference (locally on your machine is fine) to develop on this set of benchmarks? Run them with runtime-benchmarks/run <bench1> <bench2> ...
...ne/runtime-compiler/src/main/scala/org/enso/compiler/pass/analyse/AutomaticParallelism.scala
Outdated
Show resolved
Hide resolved
ir, | ||
{ ir => | ||
if (ir.getExternalId.contains(externalId)) { | ||
return Some(ir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those explicit returns are so not Scala, you make bunny cry.
* @param ir the node to traverse | ||
* @param cb the callback to apply | ||
*/ | ||
static void preorder(IR ir, Consumer<IR> cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I so much wish Consumer
was a partial function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scala.PartialFunction[IR, IR]
is nice. But implementing that on java side, not so much. You have to explicitly override both isDefinedAt
and apply
methods. Which is unnecessary duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make a variant for a PartialFunction
as well, but Pavel is right, it cannot be used as a lambda from Java.
@Akirathan here are the results develop
wip/db/10537-improve-the-speed-of-preorder-operation-cb
I was using Two benchmarks here look slightly worse:
However, when executed multiple times, they show a lot of variation in the results. And the |
This is a nice result:
10% is nice. |
@4e6 Thanks for the measurements. Yes, 10% is very nice improvement. As for the variation - note the |
Pull Request Description
close #10537
Changelog:
IR.preorder
method with callbackIR.preorder
method usagesImportant Notes
Shows ~10% speed improvement during the compilation
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.