-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db,wal: avoid Batch.refData allocation #3565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 6 files reviewed, 1 unresolved discussion (waiting on @aadityasondhi, @RaduBerinde, and @sumeerbhola)
batch.go
line 232 at r1 (raw file):
const batchClosedBit = 1 << 30 // TODO(jackson): Hide the wal.RefCount implementation from the public Batch interface.
Any ideas on how to achieve this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aadityasondhi, @jbowens, and @RaduBerinde)
batch.go
line 232 at r1 (raw file):
Previously, jbowens (Jackson Owens) wrote…
Any ideas on how to achieve this?
Not really. Wrapping Batch in another struct seems unnecessary boilerplate.
wal/wal.go
line 389 at r1 (raw file):
// like to reuse p's memory, the caller may pass a non-nil [RefCount]. If // the Writer will retain p, it will invoke the [RefCount] before returning. // When it's finished, it will invoke the func returned by the [RefCount] to
nit: func returned by the RefCount is stale.
Passing in the Batch.refData func into (wal.Writer).WriteRecord forced an allocation for every committed batch. This commit defines a new wal.RefCount interface implemented by Batch to avoid the allocation. Informs cockroachdb/cockroach#123236.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @aadityasondhi, @RaduBerinde, and @sumeerbhola)
wal/wal.go
line 389 at r1 (raw file):
Previously, sumeerbhola wrote…
nit: func returned by the RefCount is stale.
good catch
Passing in the Batch.refData func into (wal.Writer).WriteRecord forced an allocation for every committed batch. This commit defines a new wal.RefCount interface implemented by Batch to avoid the allocation.
Informs cockroachdb/cockroach#123236.