Skip to content

feat: Go implementation for manifestYamlDoc and escapeStringJson#742

Merged
sbarzowski merged 2 commits intogoogle:masterfrom
jgraeger:builtinYaml
Jun 9, 2024
Merged

feat: Go implementation for manifestYamlDoc and escapeStringJson#742
sbarzowski merged 2 commits intogoogle:masterfrom
jgraeger:builtinYaml

Conversation

@jgraeger
Copy link
Copy Markdown
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
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
vhata pushed a commit to discord/go-jsonnet that referenced this pull request Aug 30, 2024
…gle#742)

* Builtins for escapeStringJson and manifestYamlDoc

* Benchmark and tests
vhata pushed a commit to discord/go-jsonnet that referenced this pull request Aug 30, 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.
Comment thread builtins.go
} else {
buf.WriteByte(' ')
}
aux(fieldValue, buf, cindent)
Copy link
Copy Markdown
Contributor

@rudo-thomas rudo-thomas Apr 22, 2025

Choose a reason for hiding this comment

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

Note that the error from this call is unchecked.

Fix: #800

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR (#742) introduces a bug into manifestYamlDoc, which is now part of the 0.21.0 release. (We were even getting stack traces, but that's besides the point here.)

The fix is trivial (#800), but I'm having difficulties getting it merged -- nobody responded...

@jgraeger, can I kindly ask you, as the original author, to help me ping the right people and get the fix merged? Thanks :)

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.

3 participants