MCPcopy
hub / github.com/grafana/tempo / benchmarkCompleteBlock

Function benchmarkCompleteBlock

tempodb/tempodb_test.go:719–770  ·  view source on GitHub ↗
(b *testing.B, e encoding.VersionedEncoding)

Source from the content-addressed store, hash-verified

717}
718
719func benchmarkCompleteBlock(b *testing.B, e encoding.VersionedEncoding) {
720 // Create a WAL block with traces
721 traceCount := 10_000
722 flushCount := 1000
723
724 tempDir := b.TempDir()
725 _, w, _, err := New(&Config{
726 Backend: backend.Local,
727 Local: &local.Config{
728 Path: path.Join(tempDir, "traces"),
729 },
730 Block: &common.BlockConfig{
731 BloomFP: .01,
732 BloomShardSizeBytes: 100_000,
733 Version: e.Version(),
734 RowGroupSizeBytes: 30_000_000,
735 },
736 WAL: &wal.Config{
737 IngestionSlack: time.Minute,
738 Filepath: path.Join(tempDir, "wal"),
739 },
740 BlocklistPoll: 0,
741 }, nil, log.NewNopLogger())
742 require.NoError(b, err)
743
744 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
745
746 wal := w.WAL()
747 meta := &backend.BlockMeta{BlockID: backend.NewUUID(), TenantID: testTenantID}
748 blk, err := wal.NewBlock(meta, model.CurrentEncoding)
749 require.NoError(b, err)
750
751 for i := 0; i < traceCount; i++ {
752 id := test.ValidTraceID(nil)
753 req := test.MakeTrace(10, id)
754 writeTraceToWal(b, blk, dec, id, req, 0, 0)
755
756 if i%flushCount == 0 {
757 require.NoError(b, blk.Flush())
758 }
759 }
760
761 fmt.Println("Created wal block")
762
763 b.ResetTimer()
764
765 // Complete it
766 for i := 0; i < b.N; i++ {
767 _, err := w.CompleteBlock(context.Background(), blk)
768 require.NoError(b, err)
769 }
770}
771
772func TestCreateLegacyCache(t *testing.T) {
773 tcs := []struct {

Callers 1

BenchmarkCompleteBlockFunction · 0.85

Calls 12

MustNewSegmentDecoderFunction · 0.92
NewUUIDFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
NewBlockMethod · 0.80
NewFunction · 0.70
writeTraceToWalFunction · 0.70
JoinMethod · 0.65
VersionMethod · 0.65
WALMethod · 0.65
FlushMethod · 0.65
CompleteBlockMethod · 0.65

Tested by

no test coverage detected