Skip to content

Commit 18193a0

Browse files
yokoflyclaude
andcommitted
perf(proton): remove per-row mutex lock around batched.Append()
The ds.Context.Lock()/Unlock() around batched.Append(row...) was unnecessary: - batched is a local object created in the operation closure - batchRows is a local snapshot fully drained from the channel - No concurrent goroutine accesses either during the append loop This saved 1.66M mutex lock/unlock cycles. Benchmark (localhost, 1.66M rows, batch_limit=50K, cumulative): Baseline: 62s (41.0s user) + LZ4: 61s + g.Debug removal: 28s (10.5s user) + this: 27s ( 9.8s user) ← ~1s improvement Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 60a5ddd commit 18193a0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

core/dbio/database/database_proton.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,8 @@ func (conn *ProtonConn) processBatch(tableFName string, table Table, batch *iop.
733733
return backoff.Permanent(err) // Type conversion errors are permanent
734734
}
735735

736-
// Do insert
737-
ds.Context.Lock()
736+
// Do insert (batched is local to this closure, no concurrent access)
738737
err = batched.Append(row...)
739-
ds.Context.Unlock()
740738
if err != nil {
741739
ds.Context.CaptureErr(g.Error(err, "could not insert into table %s, row: %#v", tableFName, row))
742740
return g.Error(err, "could not execute statement") // Network/temporary errors can retry

0 commit comments

Comments
 (0)