Skip to content

Commit

Permalink
more verbose info on chunk indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Feb 12, 2024
1 parent 30d207d commit a8f513e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func channelUsersID(channelID string) GroupID {
}

func (c *Chunk) String() string {
return fmt.Sprintf("%s: %s", c.Type, c.ID())
return c.Type.String() + ": " + string(c.ID())
}

// Timestamps returns the timestamps of the messages in the chunk. For files
Expand Down
4 changes: 3 additions & 1 deletion internal/chunk/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type decoder interface {

// indexChunks indexes the records in the reader and returns an index.
func indexChunks(dec decoder) (index, error) {
start := time.Now()
idx := make(index, 200) // buffer for 200 chunks to avoid reallocations.
var id GroupID
for i := 0; ; i++ {
Expand All @@ -124,7 +125,8 @@ func indexChunks(dec decoder) (index, error) {
id = chunk.ID()
idx[id] = append(idx[id], offset)
}
logger.Default.Debugf("indexing chunks: %d: called from %v", len(idx), caller(2))

logger.Default.Debugf("indexing chunks: %d: called from %v, took %s (%.2f/sec)", len(idx), caller(2), time.Since(start), float64(len(idx))/time.Since(start).Seconds())
return idx, nil
}

Expand Down

0 comments on commit a8f513e

Please sign in to comment.