WIP: perf: copy-on-write for sentry_value_t clone#1794
Open
jpnurmi wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ec86d1f. Configure here.
Add copy-on-write (COW) semantics to sentry__value_clone() for list and object values. Instead of deep-copying items/pairs on clone, the new thing_t shares the underlying list_t/obj_t data via a data-level refcount. The actual copy is deferred to mutation time (thing_detach), making clone O(1) for flat containers. Two-level refcounting: - thing_t.refcount: how many sentry_value_t handles reference the thing - list_t.refcount / obj_t.refcount: how many thing_ts share the data Container children (nested lists/objects) are still recursively cloned to maintain value semantics at each nesting level. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In `thing_clone_children`, if `sentry__value_clone` fails for a nested container, the error was ignored. This resulted in clones that appeared usable but were missing nested data. Add a check to return false on clone failure, ensuring the entire operation fails rather than producing an incomplete result. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Keep object copy-on-write detach atomic when cloning keys fails. Track initialized pairs so partial clones can be freed without installing null keys. Co-Authored-By: OpenAI Codex <noreply@openai.com>
ec86d1f to
3e7dd7b
Compare
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.

Add copy-on-write (COW) semantics to
sentry__value_clone()for list and object values. Instead of deep-copying items/pairs on clone, the newthing_tshares the underlyinglist_t/obj_tdata via a data-level refcount. The actual copy is deferred to mutation time (thing_detach), making clone O(1) for flat containers.Two-level refcounting:
thing_t.refcount: how manysentry_value_thandles reference the thinglist_t.refcount/obj_t.refcount: how manything_ts share the dataContainer children (nested lists/objects) are still recursively cloned to maintain value semantics at each nesting level.
Close: #1551
See also: