perf: speed up TOML manifestation#828
Merged
stephenamar-db merged 1 commit intoMay 11, 2026
Merged
Conversation
Collaborator
|
rebase |
cf705bd to
2b5b106
Compare
Motivation: std.manifestTomlEx allocates avoidable intermediate strings, regex matchers, sequence paths, and table partition/sort structures while rendering TOML. Modification: Render TOML strings and keys directly to the existing writer, replace bare-key regex matching with an ASCII scan, reuse renderer/path buffers during table traversal, and classify sections with cached sorted keys. Result: Keeps output-compatible TOML rendering and adds directional golden coverage for key escaping, non-section ordering, nested tables, and table arrays. References: PR: databricks#828
2b5b106 to
3efa453
Compare
Contributor
Author
|
Rebased onto latest master and reduced this PR to TOML-only so it no longer duplicates #825's repeated-join work. I refreshed the local validation and benchmark data in the PR description. |
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.
Motivation:
std.manifestTomlExspends avoidable time and allocation while rendering TOML: regex matching for bare keys, intermediate escaped strings, per-value renderer allocation,Seqpath copies,partition, and repeated sorting during table traversal.Key Design Decision
Keep this PR TOML-only. The earlier repeated-join work is now handled separately in #825, so this branch was intentionally reduced to a single focused TOML rendering commit after rebasing onto latest master.
Modification:
StringWriter.StringWriter.flush()calls while rendering arrays.TomlRendererper table level and keep table paths in a mutable buffer.partitionplus extra sorting.Benchmark Results:
JMH on JDK 21,
./mill -j 1 bench.runRegressions bench/resources/go_suite/manifestTomlEx.jsonnet, lowerms/opis better;ops/ms = 1 / ms_per_op, higher is better.go_suite/manifestTomlEx.jsonnetScala Native hyperfine, lower is better, comparing locally built Scala Native binaries and source-built
jrsonnet 0.5.0-pre98.go_suite/manifestTomlEx.jsonnetAnalysis:
The output remains compatible with current sjsonnet behavior: local master and this PR produced identical output on the benchmark inputs and the new directional TOML golden test. The scaled Native comparison includes jrsonnet as a performance reference, but jrsonnet's TOML formatting differs from sjsonnet on these inputs, so sjsonnet-vs-sjsonnet output equality is the semantic gate.
References:
3efa453a5b6f48d6dfd0e1cd034922d6c8e2ff030ae7b78a93c4e643f9bcfb6dd1d99d9fe7a522a9Result:
./mill --no-server -j 1 __.reformatpassed locally../mill --no-server -j 1 __.testpassed locally.