add end-to-end IO benchmarks and fix pprof-identified hotspots - #128
Merged
Conversation
Add comprehensive benchmark suite (io_bench_test.go): - BenchmarkEndToEndRead/Write: full SCSI stack (512B to 256KB) - BenchmarkEndToEndReadParallel/WriteParallel: concurrent IO - BenchmarkFileBackingStoreRead/Write: isolated backing store pprof-guided optimizations: - Guard hot-path log.Debugf with log.GetLevel() check in scsi.go, sbc.go, backingstore.go — eliminates 22% CPU overhead from logrus Entry allocation even when debug logging is disabled - Add FileBackingStore.ReadAt for zero-copy reads directly into caller's buffer, bypassing Read()'s per-call make([]byte, tl) - Use ReadAt via interface assertion in bsPerformCommand to read directly into InSDBBuffer, eliminating allocation + copy Results (256KB reads): +42% throughput, allocs reduced from 10 to 5 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Designed benchmark programs for read/write IO paths, used pprof CPU+memory profiling to identify hotspots, and fixed them.
Benchmark Suite (
io_bench_test.go)BenchmarkEndToEndRead/Write— full SCSI stack: AddCommandQueue -> SBCReadWrite -> FileBackingStore (512B/4KB/64KB/256KB)BenchmarkEndToEndReadParallel/WriteParallel— concurrent 4KB IOBenchmarkFileBackingStoreRead/Write— isolated backing store layerpprof Findings & Fixes
1. logrus debug logging: 22% CPU (FIXED)
log.Debugf()in hot paths (scsi.go:101, sbc.go:436, backingstore.go:161) was allocating logrus Entry objects even when debug level was disabled. Fixed by guarding withlog.GetLevel() >= log.DebugLevel.2. FileBackingStore.Read allocation: 38% memory (FIXED)
Every read allocated
make([]byte, tl)then copied to InSDBBuffer. AddedReadAt(buf, offset)method to FileBackingStore, used via interface assertion in bsPerformCommand to read directly into InSDBBuffer — zero allocation, zero copy.Results (256KB reads)
Test plan
go build ./...passesgo vet ./...passesgo test ./...all tests pass