Skip to content

Add assert and restore reference count when releasing Chunks - #14391

Merged
normanmaurer merged 1 commit into
4.2from
release
Oct 5, 2024
Merged

normanmaurer merged 1 commit into
4.2from
release

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

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

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
normanmaurer requested a review from chrisvest October 4, 2024 14:29
@normanmaurer normanmaurer added this to the 4.2.0.Alpha5 milestone Oct 4, 2024

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, yeah, that's a head-scratcher. Nice catch!

@@ -744,8 +744,11 @@ private void deallocate() {
allocatedBytes = 0;
if (!mag.trySetNextInLine(this)) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That also works. More overhead, but correct by construction.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah it produce a bit more GC but maybe it's safer

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@normanmaurer
normanmaurer deleted the release branch October 4, 2024 16:20
@normanmaurer
normanmaurer restored the release branch October 4, 2024 18:48
@normanmaurer normanmaurer reopened this Oct 4, 2024
@normanmaurer
normanmaurer merged commit fdc65e9 into 4.2 Oct 5, 2024
@normanmaurer
normanmaurer deleted the release branch October 5, 2024 09:04
@normanmaurer
normanmaurer restored the release branch October 5, 2024 09:04
@normanmaurer
normanmaurer deleted the release branch October 5, 2024 09:04
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
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.

2 participants