-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for caching based on compaction level and block age (#805)
* Checkpoint: Compaction summary enhancements, add block shard count & size histogram Signed-off-by: Annanay <annanayagarwal@gmail.com> * Experimenting with 2d map of size vs time for blocks Signed-off-by: Annanay <annanayagarwal@gmail.com> * Clean out histogram library, experiment with per day + per level bloom shard counters Signed-off-by: Annanay <annanayagarwal@gmail.com> * Actual support for caching based on level and age Signed-off-by: Annanay <annanayagarwal@gmail.com> * Fix bucket reader Signed-off-by: Annanay <annanayagarwal@gmail.com> * Add new cache summary command to view bloom filter shards per day per level Signed-off-by: Annanay <annanayagarwal@gmail.com> * Add docs for new cache summary command and cache estimation Signed-off-by: Annanay <annanayagarwal@gmail.com> * Tweak/simplify verbiage Signed-off-by: Martin Disibio <mdisibio@gmail.com> * Change var names, logic for clarity Signed-off-by: Martin Disibio <mdisibio@gmail.com> * changelog Signed-off-by: Martin Disibio <mdisibio@gmail.com> * Update ingester and compactor to use cache settings when writing blocks Signed-off-by: Martin Disibio <mdisibio@gmail.com> * Fixed docs links and image Signed-off-by: Martin Disibio <mdisibio@gmail.com> * Comments from review Signed-off-by: Martin Disibio <mdisibio@gmail.com> Co-authored-by: Martin Disibio <mdisibio@gmail.com>
- Loading branch information
Showing
16 changed files
with
300 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/olekukonko/tablewriter" | ||
) | ||
|
||
type listCacheSummaryCmd struct { | ||
TenantID string `arg:"" help:"tenant-id within the bucket"` | ||
backendOptions | ||
} | ||
|
||
func (l *listCacheSummaryCmd) Run(ctx *globalOptions) error { | ||
r, c, err := loadBackend(&l.backendOptions, ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
windowDuration := time.Hour | ||
|
||
results, err := loadBucket(r, c, l.TenantID, windowDuration, false) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
displayCacheSummary(results) | ||
|
||
return nil | ||
} | ||
|
||
func displayCacheSummary(results []blockStats) { | ||
fmt.Println() | ||
fmt.Println("Bloom filter shards by day and compaction level:") | ||
|
||
columns := []string{"bloom filter age"} | ||
out := make([][]string, 0) | ||
bloomTable := make([][]int, 0) | ||
|
||
for _, r := range results { | ||
row := r.CompactionLevel | ||
// extend rows | ||
for len(bloomTable)-1 < int(row) { | ||
bloomTable = append(bloomTable, make([]int, 0)) | ||
} | ||
column := -1 * (int(time.Until(r.StartTime) / (time.Hour * 24))) | ||
// extend column of given row | ||
for len(bloomTable[row])-1 < column { | ||
bloomTable[row] = append(bloomTable[row], 0) | ||
} | ||
// extend columns (header of bloomTable) | ||
for i := len(columns) - 1; i <= column; i++ { | ||
columns = append(columns, fmt.Sprintf("%d days", i)) | ||
} | ||
|
||
if int(row) < len(bloomTable) && column < len(bloomTable[row]) { | ||
bloomTable[row][column] += int(r.BloomShardCount) | ||
} else { | ||
fmt.Println("something wrong with row / column", row, column) | ||
} | ||
} | ||
|
||
fmt.Println() | ||
columnTotals := make([]int, len(columns)-1) | ||
for i, row := range bloomTable { | ||
line := make([]string, 0) | ||
line = append(line, fmt.Sprintf("compaction level %d", i)) | ||
|
||
for j, column := range row { | ||
line = append(line, fmt.Sprintf("%d", column)) | ||
columnTotals[j] += column | ||
} | ||
out = append(out, line) | ||
} | ||
|
||
columnTotalsRow := make([]string, 0, len(columns)) | ||
columnTotalsRow = append(columnTotalsRow, "total") | ||
for _, total := range columnTotals { | ||
columnTotalsRow = append(columnTotalsRow, fmt.Sprintf("%d", total)) | ||
} | ||
|
||
fmt.Println() | ||
w := tablewriter.NewWriter(os.Stdout) | ||
w.SetHeader(columns) | ||
w.AppendBulk(out) | ||
w.SetFooter(columnTotalsRow) | ||
w.Render() | ||
} |
This file contains 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
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.