Skip to content

Conversation

@danipozo
Copy link
Contributor

@danipozo danipozo commented Feb 6, 2026

Adds an optional flag to enable storage of traces in a ClickHouse server. This enables better scalability for users who wish to ingest and query data from many nodes, as the current FrostDB storage struggles with heavy use cases.

This introduces a new module implementing the same public interface as the parcacol module, based on FrostDB, and initializes the selected backend depending on the flag. Traces are inserted into and queried from a MergeTree table, the basic engine in ClickHouse. This could be modified to be a ReplicatedMergeTree to enable more complex setups. For the labels, it uses a column with the JSON type, which stores most frequent labels in separate columns for query efficiency (this was a design objective of FrostDB AFAIK).

Caveats

  1. The ingester assumes that every location from the profile contains only one line, as I've only seen that case and I'm not sure the extra complexity is worth introducing right now. For addresses with inlined functions in native binaries, they are ingested as one line unsymbolized and then the inlined functions are extracted by the symbolizer.
  2. I haven't reviewed in depth the code that actually generates flamegraph structures, as it may be worth to push that computation to ClickHouse too, but I think it would be too much scope for this PR anyway.

Add a new optional storage backend backed by a ClickHouse database. This
should improve performance over the FrostDB backend and help users send
data from more nodes and query it efficiently.

This commit is the first working version of the code, improvements will
follow in later commits.
- move Symbolizer interface to the symbolizer module
- remove deduplication and ordering of results on the Go side, relying
  on the database instead
- in QueryRange, move grouping by labels to ClickHouse
- in QuerySingle and QueryMerge, match FrostDB aggregation behavior
- remove dead code
- formatting
The function was moved to that module so it makes sense for the test to
be there too.

Remove test that only checked constants had specific values.
@danipozo danipozo requested review from a team as code owners February 6, 2026 17:13
@danipozo
Copy link
Contributor Author

danipozo commented Feb 6, 2026

cc @thorfour @umanwizard

@thorfour
Copy link
Contributor

thorfour commented Feb 6, 2026

cc @thorfour @umanwizard

Awesome! Thanks for this. Will review it next week

@danipozo danipozo requested a review from a team as a code owner February 6, 2026 17:45
@danipozo danipozo force-pushed the danipozo/clickhouse-backend branch from 213a51a to 597c762 Compare February 6, 2026 20:42
@thorfour
Copy link
Contributor

thorfour commented Feb 9, 2026

This looks great! Thanks for the contribution.

I would like to mark this as an experimental feature for now. As such can we move the clickhouse flags into the FlagsHidden struct so that they aren't not displayed in --help by default?

Hide them by default as it's an experimental feature
@danipozo
Copy link
Contributor Author

danipozo commented Feb 9, 2026

Sure! Done in the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants