phase168: rotate bounded native WAL lanes

This commit is contained in:
pingqiu committed 2026-07-29 21:28:08 -07:00
1 parent 7316a820d0
commit e96a422d77
2 files changed
+33 -1

No files matched your search

@@ -36,6 +36,7 @@ type nativeWALSubmitter struct {
stop chan struct{}
done chan struct{}
closeOnce sync.Once
nextLane int
mu sync.Mutex
stats NativeIOStats
@@ -137,10 +138,13 @@ func (submitter *nativeWALSubmitter) takeRound() ([]nativeWALBatch, error) {
maxOperations = len(submitter.store.lanes)
}
batches := make([]nativeWALBatch, 0, maxOperations)
for _, lane := range submitter.store.lanes {
startLane := submitter.nextLane
for visited := 0; visited < len(submitter.store.lanes); visited++ {
if len(batches) == maxOperations {
break
}
laneID := (startLane + visited) % len(submitter.store.lanes)
lane := submitter.store.lanes[laneID]
batch, ok, err := submitter.takeLaneBatch(lane)
if err != nil {
if len(batch.requests) != 0 {
@@ -150,6 +154,7 @@ func (submitter *nativeWALSubmitter) takeRound() ([]nativeWALBatch, error) {
}
if ok {
batches = append(batches, batch)
submitter.nextLane = (laneID + 1) % len(submitter.store.lanes)
}
}
return batches, nil
@@ -69,3 +69,30 @@ func TestIOUringOwnerBatchesAcrossLanesAndRecoversPortably(t *testing.T) {
}
}
}
func TestIOUringOwnerRotatesAcrossLanesAtDepthOne(t *testing.T) {
path := filepath.Join(t.TempDir(), "depth-one.bin")
cfg := testConfig()
cfg.QueueDepth = 1
cfg.Execution = ExecutionIOUring
store, err := CreateStoreWithConfig(path, cfg)
if err != nil {
t.Fatal(err)
}
defer store.Close()
blocks := [][]byte{
testBlock(0x51, cfg.BlockSize),
testBlock(0x52, cfg.BlockSize),
testBlock(0x53, cfg.BlockSize),
testBlock(0x54, cfg.BlockSize),
}
if _, err := store.WriteBatch(0, blocks); err != nil {
t.Fatal(err)
}
stats := store.NativeIOStats()
if stats.QueueDepth != 1 || stats.SubmissionRounds != 4 ||
stats.SQEs != 4 || stats.CompletionCount != 4 {
t.Fatalf("depth-one native stats=%+v", stats)
}
}