From 764cf80072d8edf9c30899b38b526834c861faac Mon Sep 17 00:00:00 2001 From: palmerlao Date: Sat, 10 Jan 2026 12:05:16 -0800 Subject: [PATCH] Remove dead progress tracking code in shard.go --- pkg/snapshot/shard.go | 48 ++----------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/pkg/snapshot/shard.go b/pkg/snapshot/shard.go index 2290eb93..f4e9fdb1 100644 --- a/pkg/snapshot/shard.go +++ b/pkg/snapshot/shard.go @@ -31,9 +31,6 @@ type shardRequest struct { v accountsdb.AccountIndexEntry } -// ShardProgressCallback is called with (bytesDone, totalBytes) to report shard flush progress -type ShardProgressCallback func(bytesDone, totalBytes int64) - // ShardLogger manages multiple sharded log files type ShardLogger struct { shards []*shard @@ -41,11 +38,6 @@ type ShardLogger struct { wg *sync.WaitGroup flushSem *semaphore.Weighted - // Progress tracking - totalBytes atomic.Int64 // total bytes written to shard logs - bytesDone atomic.Int64 // bytes flushed to cache - onProgress ShardProgressCallback - // closed flag to prevent sends after Close is called (defensive) closed atomic.Bool } @@ -58,7 +50,6 @@ type shard struct { requests chan shardRequest logSize int flushSem *semaphore.Weighted - parent *ShardLogger // parent for progress reporting } // NewShardLogger creates a new ShardLogger with the specified number of @@ -77,31 +68,15 @@ func NewShardLogger(numShards int, filePrefix string) *ShardLogger { sl.wg.Add(numShards) for i := range numShards { - sl.shards[i] = newShard(i, filePrefix, sl.flushSem, sl) + sl.shards[i] = newShard(i, filePrefix, sl.flushSem) go sl.shards[i].processRequests(sl.wg) } return sl } -// SetProgressCallback sets a callback to receive progress updates during shard flushes. -// The callback receives (bytesDone, totalBytes) and is called as bytes are flushed to cache. -func (sl *ShardLogger) SetProgressCallback(cb ShardProgressCallback) { - sl.onProgress = cb -} - -// TotalBytes returns the total bytes written to shard logs -func (sl *ShardLogger) TotalBytes() int64 { - return sl.totalBytes.Load() -} - -// BytesDone returns the bytes that have been flushed to cache -func (sl *ShardLogger) BytesDone() int64 { - return sl.bytesDone.Load() -} - // newShard creates a new shard with the given ID -func newShard(id int, filePrefix string, flushSem *semaphore.Weighted, parent *ShardLogger) *shard { +func newShard(id int, filePrefix string, flushSem *semaphore.Weighted) *shard { filename := filepath.Join(filePrefix, fmt.Sprintf("%03d", id)) file, err := os.Create(filename) if err != nil { @@ -114,7 +89,6 @@ func newShard(id int, filePrefix string, flushSem *semaphore.Weighted, parent *S file: file, requests: make(chan shardRequest, 100), flushSem: flushSem, - parent: parent, } return s @@ -135,16 +109,6 @@ func (s *shard) processRequests(wg *sync.WaitGroup) { bytesWritten := int64(len(req.k) + vlen) s.logSize += int(bytesWritten) - - // Track total bytes for progress reporting and notify callback - if s.parent != nil { - total := s.parent.totalBytes.Add(bytesWritten) - if s.parent.onProgress != nil { - // Notify with bytesDone=0 during streaming (before flush) - // The callback can use totalBytes to show indexing progress - s.parent.onProgress(0, total) - } - } } } @@ -195,14 +159,6 @@ func (s *shard) logToSST(ctx context.Context) error { pairs[i].k = solana.PublicKey(buf[:32]) pairs[i].v.Unmarshal((*[24]byte)(buf[32:56])) i++ - - // Track progress - if s.parent != nil { - done := s.parent.bytesDone.Add(recordSize) - if s.parent.onProgress != nil { - s.parent.onProgress(done, s.parent.totalBytes.Load()) - } - } } // Truncate file and replace file/writer pointers