Skip to content
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

Removing State from method signatures #12233

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Feb 5, 2025

Pull Request Description

Fixes #7117 by removing State from method signatures and moving it into Truffle thread context local variable:

Everything compiles. Tests pass after fixing one of them. Benchmarks shall be OK soon.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Feb 5, 2025
@JaroslavTulach JaroslavTulach self-assigned this Feb 5, 2025
@JaroslavTulach JaroslavTulach marked this pull request as draft February 5, 2025 08:07
@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Feb 5, 2025
@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/StateInContext7117 branch from 1231c92 to 86520e3 Compare February 5, 2025 15:45
@JaroslavTulach JaroslavTulach marked this pull request as ready for review February 5, 2025 16:00
@@ -74,7 +75,7 @@ public static DataflowError withDefaultTrace(

/** Slow version of {@link #withDefaultTrace(State, Object, Node, HasContextEnabledNode)}. */
public static DataflowError withDefaultTrace(Object payload, Node location) {
return withDefaultTrace(null, payload, location, HasContextEnabledNode.getUncached());
return withDefaultTrace(payload, location, HasContextEnabledNode.getUncached());
Copy link
Member Author

@JaroslavTulach JaroslavTulach Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of this null is causing the change in test behavior:

DataflowError.withDefaultTrace() (DataflowError.java:65)
DataflowError.withDefaultTrace() (DataflowError.java:78)
DivNode.doLong() (DivNode.java:29)

Previously the withDefaultTrace(Object payload, Node location) was actually always attaching the full stack trace. That wasn't correct and we need to update the test: 952125c

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Feb 6, 2025

1st run of engine benchmarks show some regressions:

obrazek

Possibly in caseBench6 benchmark:

obrazek

Multi value benchmark:

obrazek
obrazek

Also in RecursionBenchmarks:

obrazek
obrazek

VectorBenchmarks:

obrazek

Some of them are addressed by 4ef8f4d, but many remain regressed.

@JaroslavTulach
Copy link
Member Author

Some benchmarks still show 2-3x regression:

AtomBenchmarks_benchMapReverseListCurry
IfVsCaseBenchmarks_caseBench6
MultiValueBenchmarks_sumOverComplexAndFloat5
MultiValueBenchmarks_sumOverFloatAndComplex6
MultiValueBenchmarks_sumOverFloatComplexRecastedToFloat4
RecursionBenchmarks_benchNestedThunkSum
RecursionBenchmarks_benchSumStateTCO
WarningBenchmarks_noWarningsVecSum
WarningBenchmarks_randomElementsVecSum

VectorBenchmarks_averageOverArray
VectorBenchmarks_averageOverArrayProxy
VectorBenchmarks_averageOverArrayProxyNew
VectorBenchmarks_averageOverPolyglotVector
VectorBenchmarks_averageOverSliceWrapped10
VectorBenchmarks_averageOverSliceWrapped100

something has to be done to speed them up.

@JaroslavTulach
Copy link
Member Author

Running engine bechmarks again

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Feb 13, 2025

Here is some difference in boxing:

obrazek

The previous analysis is more related to hasWarnings problem: #12258 (comment)

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Feb 13, 2025

There are now AllocatedObject nodes in the graph. They aren't there on the develop branch.
obrazek
Obviously allocating an object is costly. I am not yet sure what is causing such allocation.

Update: with 42e2337 the VectorBenchmarks.averageOverSliceWrapped100 benchmark seems to be back at full speed. New engine benchmarks run scheduled.

* ArgumentsHelper#buildArguments(Function,CallerInfo, Object, Object[])}
* @return the state for the function
*/
public static State getState(Object[] arguments) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State is no longer passed as a VirtualFrame.getArguments() when a Function is invoked.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Feb 14, 2025

VectorBenchmarks_averageOverArray
VectorBenchmarks_averageOverArrayProxy
VectorBenchmarks_averageOverArrayProxyNew
VectorBenchmarks_averageOverPolyglotVector
VectorBenchmarks_averageOverSliceWrapped10
VectorBenchmarks_averageOverSliceWrapped100

something has to be done to speed them up.

With 42e2337 these benchmarks are on par with develop:

[info] Benchmark                                    Mode  Cnt  Score    Error  Units
[info] VectorBenchmarks.averageAbstractList         avgt    5  0.054 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverArray            avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverArrayProxy       avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverArrayProxyNew    avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverPolyglotArray    avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverPolyglotVector   avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverSlice            avgt    5  0.001 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverSliceWrapped10   avgt    5  0.005 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverSliceWrapped100  avgt    5  0.005 ±  0.001  ms/op
[info] VectorBenchmarks.averageOverVector           avgt    5  0.001 ±  0.001  ms/op

Remaining Regessions

StringBenchmarks_lengthOfStrings
RecursionBenchmarks_benchSumStateTCO
RecursionBenchmarks_benchNestedThunkSum

@@ -60,7 +60,8 @@ protected Object callInlineable(
Object[] arguments,
@Cached("function.getCallTarget()") RootCallTarget cachedTarget,
@Cached("createInlineableNode(cachedTarget)") InlineableNode callNode) {
var args = Function.ArgumentsHelper.buildArguments(function, callerInfo, state, arguments);
var args =
Function.ArgumentsHelper.buildArguments(function, callerInfo, arguments); // XXX no state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State and Contexts are not preserved through the Polyglot boundary
4 participants