-
Notifications
You must be signed in to change notification settings - Fork 280
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
Vendor org.graalvm.collections #795
base: main
Are you sure you want to change the base?
Conversation
Motivation: Package org.graalvm.collections is used throughout the Pkl codebase. It is most heavily used in the Truffle interpreter, which requires putting most collection methods behind @TruffleBoundary. At the moment, this is done by wrapping collection methods with static methods declared in classes EconomicMaps and EconomicSets. However, static wrapper methods are inconvenient to use, decrease code readability, add some overhead, and are easy to forget about. Changes: - vendor package org.graalvm.collections into org.pkl.core.collection - org.graalvm.collections is licensed under: The Universal Permissive License (UPL), Version 1.0 - vendored version: https://github.com/oracle/graal/tree/graal-23.0.3/sdk/src/org.graalvm.collections/src/org/graalvm/collections - add package-info.java with original license - annotate most public methods with @TruffleBoundary - add @nullable annotations - switching to JSpecify will enable more accurate nullability checks - remove prefix tree classes (not used in Pkl) - make no other code changes to simplify review/updates - inline and remove EconomicMaps/Sets wrapper methods - replace usages of EconomicMaps.equals/hashCode with EconomicMapUtil.equals/hashCode - fix ProjectDeps.hashCode() Result: Cleaner, safer, and more efficient code.
a5f3237
to
7a12edd
Compare
I am not sure we want to do this. This makes it hard to upgrade the collections library, and I'm not sure how much of a performance gain we get out of this.
Thankfully, our CI builds (on main) will catch these errors if they are forgotten. Curious about @holzensp and @stackoverflow's thoughts |
Owning the collection library(s) used by a Truffle language implementation makes a lot of sense:
Vendoring |
I just stumbled upon the following conversation in the GraalVM Slack, where a Truffle committer argues for owning the collection library used in the Pkl interpreter. He's talking about Paguro, but it's the same thing, except that Paguro, or its future replacement, is way more challenging to own than
By the way, his latest announcement could be huge for Pkl performance, but is years away unless Pkl changes its versioning strategy:
|
I wasn't too keen on this change initially. But the library is tiny and allows us to further improve on performance (not only partial evaluation). |
I also see the benefits (and the low risk, due to the stability of this library). It would require a further update to |
done |
Motivation:
Package org.graalvm.collections is used throughout the Pkl codebase. It is most heavily used in the Truffle interpreter, which requires putting most collection methods behind @TruffleBoundary. At the moment, this is done by wrapping collection methods with static methods declared in classes EconomicMaps and EconomicSets. However, static wrapper methods are inconvenient to use, decrease code readability, add some overhead, and are easy to forget about.
Changes:
@TruffleBoundary
@Nullable
annotationsResult:
Cleaner, safer, and more efficient code.