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

feat: Go implementation for manifestYamlDoc and escapeStringJson #742

Merged
merged 2 commits into from
Jun 9, 2024

Conversation

jgraeger
Copy link
Contributor

@jgraeger jgraeger commented Jan 26, 2024

This PR introduces native Go implementations for two standard library functions in Jsonnet: manifestYamlDoc and escapeStringJson. These enhancements are a response to performance challenges, especially noticeable in cases where quote_keys=false is set. This issue is documented in google/jsonnet#1019 and also holds for the Go implementation.

Benchmarks

Running Before Test... (10s)
Running After Test... (10s)
benchmark                                old ns/op     new ns/op     delta
Benchmark_Builtin_escapeStringJson-8     9061562       3082901       -65.98%
Benchmark_Builtin_manifestYamlDoc-8      12660395      3559494       -71.88%

On a large, non-public codebase generating megabytes of yaml from jsonnet, the runtime decreased from over 10 minutes to 8 seconds.

@sbarzowski sbarzowski merged commit dec1aa2 into google:master Jun 9, 2024
1 check passed
theSuess added a commit to theSuess/go-jsonnet that referenced this pull request Jun 11, 2024
The `valueToString` operation introduced by google#742 is incompatible with the way
the implementation from google#739 as it tries to manifest an object from stack while
the implementation needed by the debugger returns the value as-is without
further evaluation.
sbarzowski pushed a commit that referenced this pull request Jun 11, 2024
The `valueToString` operation introduced by #742 is incompatible with the way
the implementation from #739 as it tries to manifest an object from stack while
the implementation needed by the debugger returns the value as-is without
further evaluation.
@jgraeger jgraeger deleted the builtinYaml branch July 1, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants