Skip to content

Commit

Permalink
Drop MinID/MaxID from BlockMeta
Browse files Browse the repository at this point in the history
To shrink the size of the BlockMeta, here we drop two fields that should
have very little overall impact due to their light use.
  • Loading branch information
zalegrala committed Aug 9, 2024
1 parent 29a93af commit ac98dde
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 66 deletions.
13 changes: 0 additions & 13 deletions tempodb/backend/block_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ type BlockMeta struct {
Version string `json:"format"`
// BlockID is a unique identifier of the block.
BlockID uuid.UUID `json:"blockID"`
// MinID is the smallest object id stored in this block.
MinID []byte `json:"minID"`
// MaxID is the largest object id stored in this block.
MaxID []byte `json:"maxID"`
// A TenantID that defines the tenant to which this block belongs.
TenantID string `json:"tenantID"`
// StartTime roughly matches when the first obj was written to this block. It is used to determine block.
Expand Down Expand Up @@ -187,8 +183,6 @@ func NewBlockMetaWithDedicatedColumns(tenantID string, blockID uuid.UUID, versio
b := &BlockMeta{
Version: version,
BlockID: blockID,
MinID: []byte{},
MaxID: []byte{},
TenantID: tenantID,
Encoding: encoding,
DataEncoding: dataEncoding,
Expand All @@ -215,13 +209,6 @@ func (b *BlockMeta) ObjectAdded(id []byte, start, end uint32) {
}
}

if len(b.MinID) == 0 || bytes.Compare(id, b.MinID) == -1 {
b.MinID = id
}
if len(b.MaxID) == 0 || bytes.Compare(id, b.MaxID) == 1 {
b.MaxID = id
}

b.TotalObjects++
}

Expand Down
15 changes: 0 additions & 15 deletions tempodb/backend/block_meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func TestBlockMetaObjectAdded(t *testing.T) {
ids [][]byte
starts []uint32
ends []uint32
expectedMaxID []byte
expectedMinID []byte
expectedStart time.Time
expectedEnd time.Time
expectedObjects int
Expand All @@ -57,8 +55,6 @@ func TestBlockMetaObjectAdded(t *testing.T) {
ends: []uint32{
uint32(now.Add(time.Minute).Unix()),
},
expectedMaxID: []byte{0x01},
expectedMinID: []byte{0x01},
expectedStart: now,
expectedEnd: now.Add(time.Minute),
expectedObjects: 1,
Expand All @@ -76,8 +72,6 @@ func TestBlockMetaObjectAdded(t *testing.T) {
uint32(now.Add(time.Hour).Unix()),
uint32(now.Add(time.Minute).Unix()),
},
expectedMaxID: []byte{0x02},
expectedMinID: []byte{0x01},
expectedStart: now.Add(-time.Minute),
expectedEnd: now.Add(time.Hour),
expectedObjects: 2,
Expand All @@ -91,8 +85,6 @@ func TestBlockMetaObjectAdded(t *testing.T) {
b.ObjectAdded(tc.ids[i], tc.starts[i], tc.ends[i])
}

assert.Equal(t, tc.expectedMaxID, b.MaxID)
assert.Equal(t, tc.expectedMinID, b.MinID)
assert.Equal(t, tc.expectedStart, b.StartTime)
assert.Equal(t, tc.expectedEnd, b.EndTime)
assert.Equal(t, tc.expectedObjects, b.TotalObjects)
Expand All @@ -106,14 +98,9 @@ func TestBlockMetaParsing(t *testing.T) {
return date
}

minID, _ := util.HexStringToTraceID("00203ff2da512a3b4fab11d7243ac1cc")
maxID, _ := util.HexStringToTraceID("f12b7a1ad3115ff207734fab0d0ab235")

meta := BlockMeta{
Version: "vParquet3",
BlockID: uuid.MustParse("00000000-0000-0000-0000-000000000000"),
MinID: minID,
MaxID: maxID,
TenantID: "single-tenant",
StartTime: timeParse("2021-01-01T00:00:00.0000000Z"),
EndTime: timeParse("2021-01-02T00:00:00.0000000Z"),
Expand All @@ -136,8 +123,6 @@ func TestBlockMetaParsing(t *testing.T) {
expectedJSON := `{
"format": "vParquet3",
"blockID": "00000000-0000-0000-0000-000000000000",
"minID": "ACA/8tpRKjtPqxHXJDrBzA==",
"maxID": "8St6GtMRX/IHc0+rDQqyNQ==",
"tenantID": "single-tenant",
"startTime": "2021-01-01T00:00:00Z",
"endTime": "2021-01-02T00:00:00Z",
Expand Down
5 changes: 1 addition & 4 deletions tempodb/encoding/vparquet3/block_traceql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2657,10 +2657,7 @@ func (b *backendBlock) rowGroupsForShard(ctx context.Context, pf *parquet.File,
matches := []parquet.RowGroup{}
for i := 0; i < len(index.RowGroups); i++ {
if i == 0 {
// The index contains the max trace ID for each row
// group. So to determine the min/max for the first
// entry we use the minimum ID from block meta.
if testRange(m.MinID, index.RowGroups[i]) {
if testRange([]byte{}, index.RowGroups[i]) {
matches = append(matches, rgs[i])
}
} else {
Expand Down
5 changes: 1 addition & 4 deletions tempodb/encoding/vparquet4/block_traceql.go
Original file line number Diff line number Diff line change
Expand Up @@ -3164,10 +3164,7 @@ func (b *backendBlock) rowGroupsForShard(ctx context.Context, pf *parquet.File,
matches := []parquet.RowGroup{}
for i := 0; i < len(index.RowGroups); i++ {
if i == 0 {
// The index contains the max trace ID for each row
// group. So to determine the min/max for the first
// entry we use the minimum ID from block meta.
if testRange(m.MinID, index.RowGroups[i]) {
if testRange([]byte{}, index.RowGroups[i]) {
matches = append(matches, rgs[i])
}
} else {
Expand Down
30 changes: 0 additions & 30 deletions tempodb/tempodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse(BlockIDMax),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
start: 0,
end: 0,
Expand All @@ -293,8 +291,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse(BlockIDMax),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
start: 0,
end: 0,
Expand All @@ -307,8 +303,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse(BlockIDMax),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
start: 0,
end: 0,
Expand All @@ -321,8 +315,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse(BlockIDMax),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
start: 0,
end: 0,
Expand All @@ -335,8 +327,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
StartTime: time.Unix(10000, 0),
EndTime: time.Unix(20000, 0),
},
Expand All @@ -351,8 +341,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
StartTime: time.Unix(1650285326, 0),
EndTime: time.Unix(1650288990, 0),
},
Expand All @@ -367,8 +355,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x05},
MaxID: []byte{0x05},
},
start: 0,
end: 0,
Expand All @@ -382,8 +368,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("51000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("52000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
},
// todo: restore when this is fixed: https://github.com/grafana/tempo/issues/1903
Expand All @@ -394,8 +378,6 @@ func TestIncludeBlock(t *testing.T) {
// blockEnd: uuid.MustParse(BlockIDMax),
// meta: &backend.BlockMeta{
// BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
// MinID: []byte{0x01},
// MaxID: []byte{0x10},
// },
// },
// {
Expand All @@ -405,8 +387,6 @@ func TestIncludeBlock(t *testing.T) {
// blockEnd: uuid.MustParse(BlockIDMax),
// meta: &backend.BlockMeta{
// BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
// MinID: []byte{0x01},
// MaxID: []byte{0x10},
// },
// },
{
Expand All @@ -416,8 +396,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("51000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("4FFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
},
{
Expand All @@ -427,8 +405,6 @@ func TestIncludeBlock(t *testing.T) {
blockEnd: uuid.MustParse("51000000-0000-0000-0000-000000000000"),
meta: &backend.BlockMeta{
BlockID: uuid.MustParse("51000000-0000-0000-0000-000000000001"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
},
}
Expand Down Expand Up @@ -467,8 +443,6 @@ func TestIncludeCompactedBlock(t *testing.T) {
meta: &backend.CompactedBlockMeta{
BlockMeta: backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
CompactedTime: time.Now().Add(-(1 * blocklistPoll)),
},
Expand All @@ -484,8 +458,6 @@ func TestIncludeCompactedBlock(t *testing.T) {
meta: &backend.CompactedBlockMeta{
BlockMeta: backend.BlockMeta{
BlockID: uuid.MustParse("50000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
CompactedTime: time.Now().Add(-(3 * blocklistPoll)),
},
Expand All @@ -501,8 +473,6 @@ func TestIncludeCompactedBlock(t *testing.T) {
meta: &backend.CompactedBlockMeta{
BlockMeta: backend.BlockMeta{
BlockID: uuid.MustParse("51000000-0000-0000-0000-000000000000"),
MinID: []byte{0x00},
MaxID: []byte{0x10},
},
CompactedTime: time.Now().Add(-(1 * blocklistPoll)),
},
Expand Down

0 comments on commit ac98dde

Please sign in to comment.