-
Notifications
You must be signed in to change notification settings - Fork 324
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
WithWarnings uses EnsoHashMap to speed things up #10555
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.
Pavel, you wrote:
the performance is much worse so far, will investigate closely tomorrow
I think the approach you are using is correct. I cannot say why it is slow.
I'd like to advocate usage of specialized Node
classes to manipulate WithWarnings
. Ideally WithWarnings
is an opaque class without any methods that can only be manipulated by associated nodes.
engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeCallableNode.java
Outdated
Show resolved
Hide resolved
...e/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/vector/Array.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/Warning.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/Warning.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/error/WithWarnings.java
Outdated
Show resolved
Hide resolved
out.println(" @Override"); | ||
out.println(" public Object call(VirtualFrame frame, Object[] args) {"); | ||
out.println(" return handleExecute(frame, extra, body, args);"); | ||
out.println(" return handleExecute(frame, extra, body, insertNode, interop, args);"); |
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.
Interesting. I can't say I like this at all! I don't want new arguments to handleExecute
, if possible... can we keep handleExecute
untouched and just wrap all calls to handleExecute
with proper warnings handling magic?
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.
That sounds very difficult. handleExecutes
strips warnings from almost all the arguments, and then reassembles these warnings into the result. Doing this outside of handleExecute
would mean that we would need to process arguments also outside handleExecute
.
Why don't you like additional arguments to handleExecute
?
lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/MethodProcessor.java
Outdated
Show resolved
Hide resolved
out.println( | ||
" if (" | ||
+ arrayRead(argumentsArray, arg.getPosition()) | ||
+ " instanceof WithWarnings) {"); | ||
+ " instanceof WithWarnings withWarnings) {"); |
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.
Recently I was claiming to @GregoryTravis that instanceof WithWarnings
isn't the right way to check for warnings. Is or isn't it the right way in this case? Is or isn't it the right way in Greg's case?
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 this case, checking via warnsLibrary.hasWarnings(x)
is not possible. The reason is that later, we fetch the value out of withWarnings
via withWarnings.getValue()
, which retains the old warnings. If you checked for warnings with warnsLibrary.hasWarnings(x)
, you would need to fetch the value via warnsLibrary.removeWarnings(x)
, and that does not retain old warnings. I have already tried to implement it that way, but some tests in Warning_Spec
on Warning.get_all wrap_errors=True
were failing.
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.
Is or isn't it the right way in Greg's case?
Generally, I would prefer the check to be done via WarningsLibrary
. This case in MethodProcessor
is a bit special, though.
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.
On my branch, without these changes, the WarningsLibrary approach looks good:
Should I wait for this to be merged and benchmark my changes before merging them?
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.
@GregoryTravis I have just scheduled benchmarks for this PR. All other tests are already successful. If benchmarks are OK, I will merge it. Wait, please before I compare the benchmarks, I will ping you then.
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMapBuilder.java
Outdated
Show resolved
Hide resolved
Hash size is fetched via HashMapSizeNode.
|
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.
This is a huge change and it'd be better to get it finally in. These are the benchmarks results I see:
sbt:runtime-benchmarks> benchOnly Warning
[info] Benchmark Mode Cnt Score Error Units
[info] WarningBenchmarks.diffWarningRandomElementsVecSum avgt 3 12.885 ± 3.815 ms/op
[info] WarningBenchmarks.noWarningsVecSum avgt 3 0.006 ± 0.001 ms/op
[info] WarningBenchmarks.randomElementsVecSum avgt 3 0.034 ± 0.014 ms/op
[info] WarningBenchmarks.sameWarningVecSum avgt 3 1.842 ± 0.306 ms/op
It is far from ideal, but if we are faster than current develop
and CI is green, let's integrate and continue this endeavor in another PR.
...e/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeConversionNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/callable/IndirectInvokeMethodNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/EnsoHashMapBuilder.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapInsertAllNode.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/hash/HashMapInsertAllNode.java
Show resolved
Hide resolved
Comparing the benchmark results with develop:
Conclussion: Benchmarks look very good. |
Closes #8682
Pull Request Description
Majority of warnings handling is now done via newly introduced nodes. Moreover, the underlying representation of warnings storage in
WithWarnings
was changed fromWarning[]
toEnsoHashMap
.Important Notes
ArrayRope
.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR: