Add assert and restore reference count when releasing Chunks#14391
Merged
normanmaurer merged 1 commit into4.2from Oct 5, 2024
Merged
Add assert and restore reference count when releasing Chunks#14391normanmaurer merged 1 commit into4.2from
normanmaurer merged 1 commit into4.2from
Conversation
Motivation: Let's restore the original reference count if we fail to queue the Chunk for reuse. Modifications: - Restore reference count and so make code more robust - Add assert to ensure there is no race Result: Cleanup code
chrisvest
approved these changes
Oct 4, 2024
Member
chrisvest
left a comment
There was a problem hiding this comment.
Oh, yeah, that's a head-scratcher. Nice catch!
normanmaurer
commented
Oct 4, 2024
| @@ -744,8 +744,11 @@ private void deallocate() { | |||
| allocatedBytes = 0; | |||
| if (!mag.trySetNextInLine(this)) { | |||
Member
Author
There was a problem hiding this comment.
What we could also do is just create a new Chunk object that wraps the delegate. This way we would not need to call resetRefCnt() and so would not need to do the release dance below. @chrisvest WDYT ?
Member
There was a problem hiding this comment.
That also works. More overhead, but correct by construction.
Member
Author
There was a problem hiding this comment.
Yeah it produce a bit more GC but maybe it's safer
normanmaurer
added a commit
that referenced
this pull request
Oct 5, 2024
Motivation: Let's restore the original reference count if we fail to queue the Chunk for reuse. Modifications: - Restore reference count and so make code more robust - Add assert to ensure there is no race Result: Cleanup code
normanmaurer
added a commit
that referenced
this pull request
Oct 5, 2024
…#14394) Motivation: Let's restore the original reference count if we fail to queue the Chunk for reuse. Modifications: - Restore reference count and so make code more robust - Add assert to ensure there is no race Result: Cleanup code
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:
Let's restore the original reference count if we fail to queue the Chunk for reuse.
Modifications:
Result:
Cleanup code