Optimize default set operations#813
Merged
stephenamar-db merged 1 commit intodatabricks:masterfrom May 1, 2026
Merged
Conversation
stephenamar-db
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Optimize default-key
std.setUnion,std.setInter, andstd.setDiffby adding a dedicated defaultkeyF=idmerge path.The new path keeps the current forced key at each merge cursor, compares numbers/strings directly, and writes into a pre-sized
Array[Eval]before trimming. CustomkeyFkeeps the previous implementation, so function-call semantics are unchanged.This is intentionally narrower than jrsonnet's whole set implementation: the goal is a JVM/JIT-friendly hot path without the large per-type method explosion that did not improve results enough to justify the code size.
JMH
Command:
./mill -i bench.runJmh sjsonnet.bench.RegressionBenchmark.main \ -p 'path=bench/resources/sjsonnet_suite/setUnion.jsonnet,bench/resources/sjsonnet_suite/setInter.jsonnet,bench/resources/sjsonnet_suite/setDiff.jsonnet' \ -wi 3 -i 5 -w 1s -r 2s -f 1 -tu msEnvironment:
--enable-native-access=ALL-UNNAMED -Xmx4G -XX:+UseG1GCsetUnion.jsonnetsetInter.jsonnetsetDiff.jsonnetJMH GC profiler
Command:
./mill -i bench.runJmh sjsonnet.bench.RegressionBenchmark.main \ -p 'path=bench/resources/sjsonnet_suite/setUnion.jsonnet,bench/resources/sjsonnet_suite/setInter.jsonnet,bench/resources/sjsonnet_suite/setDiff.jsonnet' \ -wi 2 -i 3 -w 1s -r 1s -f 1 -tu ms -prof gcNormalized allocation is effectively unchanged/slightly lower:
setUnion.jsonnetsetInter.jsonnetsetDiff.jsonnetNative hyperfine
Command shape:
setUnion.jsonnetsetInter.jsonnetsetDiff.jsonnetNative CLI remains dominated by startup/whole-program costs on these small inputs. jrsonnet is still about 1.9-2.2x faster for the native CLI set cases.
Correctness / validation