Skip to content

Borrow ClickHouse map attribute keys and values - #373

Merged
mheffner merged 1 commit into
rotel-dev:mainfrom
mheffner:perf2-clickhouse-attrs
Oct 30, 2026
Merged

mheffner merged 1 commit into
rotel-dev:mainfrom
mheffner:perf2-clickhouse-attrs

Conversation

@mheffner

Copy link
Copy Markdown
Member

In the default Map (non-JSON) mode the ClickHouse exporter converted every attribute list (resource, scope, span/log record/data point, events, links) into a Vec<(String, String)>, cloning every key and every string value and formatting bools with to_string, only to serialize them into the RowBinary buffer right away.

Make MapOrJson::Map hold Cow pairs: keys and string values borrow from the OTLP attributes, and only flattened nested keys ("a.b") and non-string values are allocated. The owned variant used for exemplars converts to owned Cows. Serialized bytes are unchanged (same str serialization).

Benchmark (rotel-bench, Intel N95, ClickHouse exporter against a mock HTTP endpoint, 5+5 runs ABBA, mean +- stddev, vs main):
saturation, SUT on 1 core:
logs 410.4k+-1.0k -> 461.3k+-0.7k logs/s (+12.4%), CPU/log -11.1%,
p99 201 -> 179 ms
metrics 917.3k+-6.0k -> 970.0k+-3.2k points/s (+5.7%), CPU/point -5.5%
traces 623.8k+-1.4k -> 641.0k+-2.3k spans/s (+2.8%), CPU/span -2.9%
fixed rate: logs 20k/s CPU -5.1%, traces 50k/s CPU -1.5%; latency
unchanged.

In the default Map (non-JSON) mode the ClickHouse exporter converted every
attribute list (resource, scope, span/log record/data point, events,
links) into a Vec<(String, String)>, cloning every key and every string
value and formatting bools with to_string, only to serialize them into the
RowBinary buffer right away.

Make MapOrJson::Map hold Cow<str> pairs: keys and string values borrow from
the OTLP attributes, and only flattened nested keys ("a.b") and non-string
values are allocated. The owned variant used for exemplars converts to
owned Cows. Serialized bytes are unchanged (same str serialization).

Benchmark (rotel-bench, Intel N95, ClickHouse exporter against a mock HTTP
endpoint, 5+5 runs ABBA, mean +- stddev, vs main):
  saturation, SUT on 1 core:
    logs     410.4k+-1.0k -> 461.3k+-0.7k logs/s (+12.4%), CPU/log -11.1%,
             p99 201 -> 179 ms
    metrics  917.3k+-6.0k -> 970.0k+-3.2k points/s (+5.7%), CPU/point -5.5%
    traces   623.8k+-1.4k -> 641.0k+-2.3k spans/s (+2.8%), CPU/span -2.9%
  fixed rate: logs 20k/s CPU -5.1%, traces 50k/s CPU -1.5%; latency
  unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mheffner
mheffner merged commit 420cc17 into rotel-dev:main Oct 30, 2026
6 checks passed
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.

1 participant