add end-to-end IO benchmarks and fix pprof-identified hotspots
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 commit is contained in:
@@ -139,6 +139,14 @@ func (bs *FileBackingStore) Read(offset, tl int64) ([]byte, error) {
|
||||
return tmpbuf, nil
|
||||
}
|
||||
|
||||
// ReadAt reads directly into the provided buffer, avoiding allocation.
|
||||
func (bs *FileBackingStore) ReadAt(buf []byte, offset int64) (int, error) {
|
||||
if bs.file == nil {
|
||||
return 0, fmt.Errorf("Backend store is nil")
|
||||
}
|
||||
return bs.file.ReadAt(buf, offset)
|
||||
}
|
||||
|
||||
func (bs *FileBackingStore) Write(wbuf []byte, offset int64) error {
|
||||
length, err := bs.file.WriteAt(wbuf, offset)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user