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

3% speedup with LazyMap and MetadataStorage #8359

Merged
merged 18 commits into from
Nov 27, 2023

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Nov 21, 2023

Pull Request Description

Shall optimize #8324 by making all deserialized Map implementations (both Java and Scala) lazy.

Important Notes

I don't know how to convert Java Map to Scala immutable Map without copying - e.g. lazily. Scala experts please advice!

Checklist

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

  • All code follows the
    Scala,
    Java,
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Nov 21, 2023
@JaroslavTulach JaroslavTulach self-assigned this Nov 21, 2023
var pass = meta.get(BindingAnalysis$.MODULE$);
emitIOException();
return (BindingsMap) pass.get();
} catch (IOException ex) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Lazy deserialization of BindingsMap may fail: https://github.com/enso-org/enso/actions/runs/6974085571/job/18979188994?pr=8359#step:10:1073 - don't propagate the IOException further.

u.compilationStage(CompilationStage.INITIAL)
}
)
compiler.ensureParsed(mod)
Copy link
Member Author

Choose a reason for hiding this comment

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

Reparse without caching when lazy deserialization fails.

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Nov 24, 2023

OK, we are green. Now we need to judge whether this change worths being integrated, @hubertp?

Cons

The BindingsMap may turn to be broken during its deserialization (because calling its restoreFromSerialization which may yield an IOException later when traversing the IR). Now, when we are doing lazy deserialization the IOException signaling that BindingsMap cannot be created can be emitted at random places. When asking for getMetadata(BindingAnalysis), or when calling Module.getBindingsMap it may fail.

Pros

We can gain some speed. The base benchmark results are finally available. Let's schedule benchmark run with this PR - on develop: 3983, 3985, 3968 ms - with this PR: 3855, 3858, 3872 ms. E.g. the speedup is 100ms - e.g. 3%.

Decision

Today's a decision was made to integrate in spite of the "Cons".

@JaroslavTulach JaroslavTulach changed the title LazyMap and MetadataStorage 3% speedup with LazyMap and MetadataStorage Nov 26, 2023
@JaroslavTulach JaroslavTulach merged commit 893965e into develop Nov 27, 2023
32 of 35 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/LazyMaps_8324 branch November 27, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants