feat(jsonnet): preserve hidden fields in rtkMemoize#7
Closed
julienduchesne wants to merge 1 commit into
Closed
Conversation
Store memoized values as a thread-portable OwnedVal snapshot instead of a lossy JSON string. Hidden (::) object fields now round-trip through the cross-worker cache, where previously any hidden field was rejected. Functions still cannot be memoized (they capture a thread-local closure context plus Rust builtins), but the error now lists the path of every function found in the value rather than failing on the first one. Co-authored-by: Cursor <cursoragent@cursor.com>
Benchmark Results
Full results available in workflow artifacts. Benchmark run on commit |
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
rtkMemoizecached values as a JSON string so it could share them across worker threads, which silently dropped hidden (::) fields — so it rejected any value containing one. Swap that JSON round-trip for a thread-portableOwnedValsnapshot that mirrors the jsonnet value model, so hidden fields survive memoization.Val(with::restored) in each consuming thread; cache hits clone anArcinstead of reparsing JSON.spec.template.withName,<root>,items[0]).Context
ValisRc/Cc-based and bound to the evaluating thread, so the cross-worker cache must hold aSend/Syncvalue and rebuild per thread. JSON was the easy portable form but lossy.OwnedValis an owned deep copy (scalars/arrays/objects + visibility) that stays portable without losing hidden data. Functions remain out of scope: aFuncValcaptures a closureContext(free vars,self/super,std, imports) plus Rust builtins, none of which reduce to thread-independent data.One behavioral note: snapshotting forces every field, including hidden ones, so a hidden field that errors now fails the memoize call even if it is never used.
Made with Cursor