Skip to content

Commit

Permalink
storage: remove allocs from iter.Close
Browse files Browse the repository at this point in the history
I actually don't understand why this allocated.
Escape analysis said:

> func literal escapes to heap: flow: {heap} =
> &{storage for func literal}: from func literal (spill) at <the defer>

This remained true even after simplifying the code (so that `iter, err`
were local to the block) but keeping the `defer`.

This was 0.41% on oltp_write_only.
  • Loading branch information
tbg committed Dec 17, 2024
1 parent f1c5e24 commit 5b77cd4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions pkg/storage/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5241,19 +5241,16 @@ func MVCCResolveWriteIntent(
if str == lock.Intent {
// Intent resolution requires an MVCC iterator to look up the MVCC
// version associated with the intent. Create one.
var iter MVCCIterator
{
iter, err = rw.NewMVCCIterator(ctx, MVCCKeyIterKind, IterOptions{
Prefix: true,
KeyTypes: IterKeyTypePointsAndRanges,
ReadCategory: fs.IntentResolutionReadCategory,
})
if err != nil {
return false, 0, nil, false, err
}
defer iter.Close()
iter, err := rw.NewMVCCIterator(ctx, MVCCKeyIterKind, IterOptions{
Prefix: true,
KeyTypes: IterKeyTypePointsAndRanges,
ReadCategory: fs.IntentResolutionReadCategory,
})
if err != nil {
return false, 0, nil, false, err
}
outcome, err = mvccResolveWriteIntent(ctx, rw, iter, ms, update, &buf.meta, buf)
iter.Close()
} else {
outcome, err = mvccReleaseLockInternal(ctx, rw, ms, update, str, &buf.meta, buf)
replLocksReleased = replLocksReleased || outcome != lockNoop
Expand Down

0 comments on commit 5b77cd4

Please sign in to comment.