Skip to content

Increase max stack trace nodes per chunk limit #2597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/phlaredb/symdb/block_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@ func (w *writer) Flush() (err error) {

func (w *writer) writeStacktraces(partition *PartitionWriter) (err error) {
for ci, c := range partition.stacktraces.chunks {
stacks := c.stacks
if stacks == 0 {
stacks = uint32(len(partition.stacktraces.hashToIdx))
}
h := StacktraceChunkHeader{
Offset: w.stacktraces.w.offset,
Size: 0, // Set later.
Partition: partition.header.Partition,
ChunkIndex: uint16(ci),
ChunkEncoding: ChunkEncodingGroupVarint,
Stacktraces: c.stacks,
Stacktraces: stacks,
StacktraceNodes: c.tree.len(),
StacktraceMaxDepth: 0, // TODO
StacktraceMaxNodes: c.partition.maxNodesPerChunk,
Expand Down
8 changes: 4 additions & 4 deletions pkg/phlaredb/symdb/symdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ func DefaultConfig() *Config {
return &Config{
Dir: DefaultDirName,
Stacktraces: StacktracesConfig{
// A million of nodes ensures predictable
// memory consumption, although causes a
// small overhead.
MaxNodesPerChunk: 1 << 20,
// At the moment chunks are loaded in memory at once.
// Due to the fact that chunking causes some duplication,
// it's better to keep them large.
MaxNodesPerChunk: 4 << 20,
},
Parquet: ParquetConfig{
MaxBufferRowCount: 100 << 10,
Expand Down
36 changes: 36 additions & 0 deletions pkg/phlaredb/symdb/symdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,39 @@ func treeFingerprint(t *phlaremodel.Tree) [][2]uint64 {
sort.Slice(m, func(i, j int) bool { return m[i][0] < m[j][0] })
return m
}

func Test_Stats(t *testing.T) {
s := memSuite{
t: t,
files: [][]string{{"testdata/profile.pb.gz"}},
config: &Config{
Dir: t.TempDir(),
Stacktraces: StacktracesConfig{
MaxNodesPerChunk: 4 << 20,
},
Parquet: ParquetConfig{
MaxBufferRowCount: 100 << 10,
},
},
}

s.init()
bs := blockSuite{memSuite: &s}
bs.flush()
defer bs.teardown()

p, err := bs.reader.Partition(context.Background(), 0)
require.NoError(t, err)

var actual PartitionStats
p.WriteStats(&actual)
expected := PartitionStats{
StacktracesTotal: 611,
MaxStacktraceID: 1793,
LocationsTotal: 762,
MappingsTotal: 3,
FunctionsTotal: 507,
StringsTotal: 700,
}
require.Equal(t, expected, actual)
}