Repository navigation
Borrow ClickHouse map attribute keys and values - #373
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.