Skip to content

Commit a2fcc09

Browse files
chore(posting): strip debug fmt.Println from hot paths
Removes the unconditional debug prints scattered through posting/ during the original WIP work — they fired on every read, mutation, rollup, and commit. None of them were guarded by a verbosity flag, so under load they would have produced megabytes of stdout noise per second. Sites stripped: - posting/lists.go: READING / READING SINGLE / GETTING KEY FROM DELTAS - posting/index.go: TOKENS, LOCAL MAP, INSERTING INDEX, UPDATE INDEX, ERRORRRING, "Inserting tokenizer indexes ... took" - posting/mvcc.go: COMMITTING (and unused fmt import) - posting/list.go: "Buidlding committed uids", "Setting mutation", PrintRollup helper (called once internally, never elsewhere) Left in place: printTreeStats() in index.go, which is already gated by the DEBUG_SHOW_HNSW_TREE env var and is an intentional opt-in HNSW debug helper. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 436b55f commit a2fcc09

4 files changed

Lines changed: 2 additions & 54 deletions

File tree

posting/index.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@ func (mp *MutationPipeline) ProcessVectorIndex(ctx context.Context, pipeline *Pr
129129
}
130130

131131
func (mp *MutationPipeline) InsertTokenizerIndexes(ctx context.Context, pipeline *PredicatePipeline, postings *map[uint64]*pb.PostingList, info predicateInfo) error {
132-
startTime := time.Now()
133-
defer func() {
134-
fmt.Println("Inserting tokenizer indexes for predicate", pipeline.attr, "took", time.Since(startTime))
135-
}()
136-
137132
tokenizers := schema.State().Tokenizer(ctx, pipeline.attr)
138133
if len(tokenizers) == 0 {
139134
return nil
@@ -192,7 +187,6 @@ func (mp *MutationPipeline) InsertTokenizerIndexes(ctx context.Context, pipeline
192187
if !loaded {
193188
tokens, err = indexTokens(ctx, info)
194189
if err != nil {
195-
fmt.Println("ERRORRRING", err)
196190
x.Panic(err)
197191
}
198192
syncMap.Store(key, tokens)
@@ -204,8 +198,6 @@ func (mp *MutationPipeline) InsertTokenizerIndexes(ctx context.Context, pipeline
204198

205199
for _, token := range tokens.([]string) {
206200
key := x.IndexKey(pipeline.attr, token)
207-
pk, _ := x.Parse([]byte(key))
208-
fmt.Println("TOKENS", key, pk)
209201
val, ok := indexGenInThread[string(key)]
210202
if !ok {
211203
val = &pb.PostingList{}
@@ -217,8 +209,6 @@ func (mp *MutationPipeline) InsertTokenizerIndexes(ctx context.Context, pipeline
217209
}
218210

219211
for key, value := range indexGenInThread {
220-
pk, _ := x.Parse([]byte(key))
221-
fmt.Println("LOCAL MAP", pk, value)
222212
indexesGenInMutation.Update(key, func(val *MutableLayer, ok bool) *MutableLayer {
223213
if !ok {
224214
val = newMutableLayer()
@@ -261,10 +251,7 @@ func (mp *MutationPipeline) InsertTokenizerIndexes(ctx context.Context, pipeline
261251
mp.txn.cache.deltas.indexMap[pipeline.attr] = indexGenInTxn
262252
}
263253

264-
fmt.Println("INSERTING INDEX", pipeline.attr, *postings)
265254
updateFn := func(key string, value *MutableLayer) {
266-
pk, _ := x.Parse([]byte(key))
267-
fmt.Println("UPDATE INDEX", pk, value)
268255
indexGenInTxn.Update(key, func(val *pb.PostingList, ok bool) *pb.PostingList {
269256
if !ok {
270257
val = &pb.PostingList{}

posting/list.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ func (mm *MutableLayer) insertCommittedPostings(pl *pb.PostingList) {
335335
// We insert old postings in reverse order. So we only need to read the first update to an UID.
336336
if _, ok := mm.committedUids[mpost.Uid]; !ok {
337337
mm.committedUids[mpost.Uid] = mpost
338-
fmt.Println("Buidlding committed uids", mm.committedUids, mpost)
339338
}
340339
}
341340
}
@@ -1104,9 +1103,6 @@ func (l *List) setMutation(startTs uint64, data []byte) {
11041103
}
11051104

11061105
func (l *List) setMutationWithPosting(startTs uint64, pl *pb.PostingList) {
1107-
// pk, _ := x.Parse(l.key)
1108-
// fmt.Println("Setting mutation for ", l.key, pk, pl)
1109-
11101106
l.Lock()
11111107
if l.mutationMap == nil {
11121108
l.mutationMap = newMutableLayer()
@@ -1526,17 +1522,10 @@ func (l *List) Rollup(alloc *z.Allocator, readTs uint64) ([]*bpb.KV, error) {
15261522
return bytes.Compare(kvs[i].Key, kvs[j].Key) <= 0
15271523
})
15281524

1529-
PrintRollup(out.plist, out.parts, l.key, kv.Version)
15301525
x.VerifyPostingSplits(kvs, out.plist, out.parts, l.key)
15311526
return kvs, nil
15321527
}
15331528

1534-
func PrintRollup(plist *pb.PostingList, parts map[uint64]*pb.PostingList, baseKey []byte, ts uint64) {
1535-
k, _ := x.Parse(baseKey)
1536-
uids := codec.Decode(plist.Pack, 0)
1537-
fmt.Printf("[TXNLOG] DOING ROLLUP for key: %+v at timestamp: %v, uids: %+v\n", k, ts, uids)
1538-
}
1539-
15401529
// ToBackupPostingList uses rollup to generate a single list with no splits.
15411530
// It's used during backup so that each backed up posting list is stored in a single key.
15421531
func (l *List) ToBackupPostingList(

posting/lists.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ func (d *Deltas) Get(key string) (*pb.PostingList, bool) {
128128
}
129129
}
130130

131-
// fmt.Println("GETTING KEY FROM DELTAS", pk, "res", res, "val", val, "d.deltas", d.deltas, "d.indexMap[pk.Attr]", d.indexMap[pk.Attr], "ok", ok)
132-
133131
return res, len(res.Postings) > 0
134132
}
135133

@@ -396,20 +394,12 @@ func (lc *LocalCache) getInternal(key []byte, readFromDisk, readUids bool) (*Lis
396394
lc.RLock()
397395
defer lc.RUnlock()
398396
if lc.plists == nil {
399-
l, err := getNew(key, pstore, lc.startTs, readUids)
400-
if err != nil {
401-
return nil, err
402-
}
403-
pk, _ := x.Parse(key)
404-
fmt.Println("READING NEW PLIST", pk, l.Print())
405-
return l, nil
397+
return getNew(key, pstore, lc.startTs, readUids)
406398
}
407399
if l, ok := lc.plists[skey]; ok {
408400
if delta, ok := lc.deltas.Get(skey); ok && delta != nil {
409401
l.setMutationWithPosting(lc.startTs, delta)
410402
}
411-
pk, _ := x.Parse(key)
412-
fmt.Println("READING PLIST", pk, l.Print())
413403
return l, nil
414404
}
415405
return nil, nil
@@ -442,8 +432,6 @@ func (lc *LocalCache) getInternal(key []byte, readFromDisk, readUids bool) (*Lis
442432
}
443433
lc.RUnlock()
444434

445-
pk, _ := x.Parse(key)
446-
fmt.Println("READING ", pk, pl.Print())
447435
return lc.SetIfAbsent(skey, pl), nil
448436
}
449437

@@ -480,26 +468,19 @@ func (lc *LocalCache) readPostingListAt(key []byte) (*pb.PostingList, error) {
480468
// given key. This is used for retrieving the value of a scalar predicats.
481469
func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
482470
// This would return an error if there is some data in the local cache, but we couldn't read it.
483-
484-
pk, _ := x.Parse(key)
485-
fmt.Println("READING SINGLE ", pk)
486-
487471
getListFromLocalCache := func() (*pb.PostingList, error) {
488472
lc.RLock()
489473

490474
if delta, ok := lc.deltas.Get(string(key)); ok && delta != nil {
491475
lc.RUnlock()
492-
fmt.Println("READING SINGLE FROM DELTA", pk, delta)
493476
return delta, nil
494477
}
495478

496479
l := lc.plists[string(key)]
497480
lc.RUnlock()
498481

499482
if l != nil {
500-
res, err := l.StaticValue(lc.startTs)
501-
fmt.Println("READING SINGLE FROM PLISTS", pk, res, err, l.Print())
502-
return res, err
483+
return l.StaticValue(lc.startTs)
503484
}
504485

505486
return nil, nil
@@ -517,15 +498,10 @@ func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
517498
}
518499

519500
pl, err := getPostings()
520-
521-
fmt.Println("READING SINGLE ", pk, "pl:", pl)
522-
523501
if err == badger.ErrKeyNotFound {
524-
fmt.Println("READING ", pk, nil)
525502
return nil, nil
526503
}
527504
if err != nil {
528-
fmt.Println("READING ", pk, err)
529505
return nil, err
530506
}
531507

@@ -538,7 +514,6 @@ func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
538514
}
539515
}
540516
pl.Postings = pl.Postings[:idx]
541-
// fmt.Println("READING ", pk, pl)
542517
return pl, nil
543518
}
544519

posting/mvcc.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"bytes"
1010
"context"
1111
"encoding/hex"
12-
"fmt"
1312
"math"
1413
"strconv"
1514
"sync"
@@ -308,8 +307,6 @@ func (txn *Txn) CommitToDisk(writer *TxnWriter, commitTs uint64) error {
308307
if len(pl.Postings) == 0 {
309308
continue
310309
}
311-
pk, _ := x.Parse([]byte(key))
312-
fmt.Println("COMMITTING", pk, pl)
313310
if ts := cache.maxVersions[key]; ts >= commitTs {
314311
// Skip write because we already have a write at a higher ts.
315312
// Logging here can cause a lot of output when doing Raft log replay. So, let's

0 commit comments

Comments
 (0)