Skip to content

Add state/structure to OTAP batch + sorting/delta decoding transforms #468

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 26 commits into from
May 23, 2025

Conversation

albertlockett
Copy link
Member

@albertlockett albertlockett commented May 20, 2025

Part of #449

This PR adds:

  • A new structure called OtapBatch that encapsulates all the record batches associated with a BatchArrowRecord. It provides efficient methods for setting & getting the record batches by payload type. This has been integrated into the decoder code.
  • Adds new otap::transform module, methods for sorting record batch by parent ID and removing delta encoding.
  • Adds helper methods for updating schema/field metadata, and invokes these methods to update the metadata with the current state of the record batches. (state including things like the encoding of the parent ID column, and the column sort order).

The scope of this PR has somewhat changed. I'll leave the original description below, for posterity.


Original Description:

Restores some of the code from #447 , but with a slightly different implementation of the "Version 2" attribute store.

  • This new version assumes that the record batch it receives is sorted by the parent ID.
  • This new store also lazily materializes the KeyValues, by returning an iterator from it's attribute_by_delta_id method (similar to what we did in [WIP] AttributesStore optimization and/or OTAP pdata research #447).
  • Note that this new attribute store implementation does not support random access. It expects attribute_by_delta_id to be called with the delta ID of each parent ID.

The benchmark results are interesting.. The v2 store gets slightly worse performance for small batch sizes (128), but gets much better performance for larger batch sizes (8092), which is encouraging!

materialize_parent_ids/v1_attr_store/128
                        time:   [7.6742 µs 7.6967 µs 7.7190 µs]

materialize_parent_ids/v2_attr_store/128
                        time:   [10.495 µs 10.515 µs 10.534 µs]

materialize_parent_ids/v1_attr_store/1536
                        time:   [118.21 µs 118.76 µs 119.32 µs]

materialize_parent_ids/v2_attr_store/1536
                        time:   [89.421 µs 89.582 µs 89.765 µs]

materialize_parent_ids/v1_attr_store/8092
                        time:   [1.2816 ms 1.2888 ms 1.2966 ms]

materialize_parent_ids/v2_attr_store/8092
                        time:   [464.49 µs 465.22 µs 466.00 µs]

Still very much WIP. One thing that needs to be sorted is where/when we apply this transform materialize parent IDs and sort the record batch, and how we track the state of the batch. This PR is currently doing it decode::decoder::Consumer::consume_bar, which may not be the right place.

We might consider not merging all the code in this PR straight away, as some of this work is exploratory/proof of concept

@albertlockett albertlockett changed the title Attribute store optimizer [WIP] Optimized attribute store using sorted record batch May 20, 2025
Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 93.91144% with 33 lines in your changes missing coverage. Please review.

Project coverage is 62.91%. Comparing base (a629271) to head (de776c9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #468      +/-   ##
==========================================
+ Coverage   62.27%   62.91%   +0.63%     
==========================================
  Files         190      193       +3     
  Lines       27291    27696     +405     
==========================================
+ Hits        16995    17424     +429     
+ Misses       9760     9737      -23     
+ Partials      536      535       -1     
Components Coverage Δ
otap-dataflow 73.76% <ø> (ø)
beaubourg 67.19% <ø> (ø)
otel-arrow-rust 67.37% <93.91%> (+3.07%) ⬆️
query_abstraction 81.42% <ø> (ø)
syslog_cef_receivers 99.17% <ø> (ø)
otel-arrow-go 52.93% <ø> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@albertlockett
Copy link
Member Author

@jmacd please take a look when you get a chance? This is some followup from last week's SIG meeting

@albertlockett
Copy link
Member Author

One thing that needs to be sorted is where/when we apply this transform materialize parent IDs and sort the record batch, and how we track the state of the batch.

Link to thread about answering some of these questions: https://cloud-native.slack.com/archives/C08RRSJR7FD/p1747847973678329

@albertlockett albertlockett force-pushed the attribute-store-optimizer branch from 487e6ff to 15c033c Compare May 22, 2025 18:11
@albertlockett albertlockett force-pushed the attribute-store-optimizer branch from 15c033c to 1709fa5 Compare May 22, 2025 21:21
@albertlockett
Copy link
Member Author

Update 05/22 -- added some structure around OtapBatch and refactored decoder to use this. Started adding helper methods to update schema metadata when transforming record batches

/// keys for arrow schema/field metadata
pub mod metadata {
/// schema metadata for which columns the record batch is sorted by
pub const SORT_COLUMNS: &str = "sort_columns";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are multiple columns supported? I've seen this set to a single column, so far. Would it make sense to have SORT_COL0, SORT_COL1, ... to indicate the successive sort orders?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking maybe we could have some delimiter. E.g. I'm imagining how we'd represent the default sorting of attributes from the golang exporter, it would be type,key,value . Do you think that'd work?

@albertlockett
Copy link
Member Author

Update 05/23 - after discussion w/ @jmacd , decided it's probably best to merge only what we are pretty sure we'll need in this PR, which does not include the AttributeStoreV2 or the benchmark for it. I'm going to stash that code on a branch called attribute-store-optimization-2 on my fork: https://github.com/open-telemetry/otel-arrow/compare/main...albertlockett:otel-arrow:attribute-store-optimizer-2?expand=1

This PR doesn't need to include AttributeStoreV2. It's still unclear whether
or not we need Attribute Store at all to optimize encoding OTAP -> OTLP bytes.
Rather than include code we don't need, we'll delete this code for now.
@albertlockett albertlockett changed the title [WIP] Optimized attribute store using sorted record batch [WIP] Add state/structure to OTAP batch + sorting/delta decoding transforms May 23, 2025
@albertlockett albertlockett marked this pull request as ready for review May 23, 2025 18:27
@albertlockett albertlockett requested a review from a team as a code owner May 23, 2025 18:27
@albertlockett albertlockett changed the title [WIP] Add state/structure to OTAP batch + sorting/delta decoding transforms Add state/structure to OTAP batch + sorting/delta decoding transforms May 23, 2025
@jmacd jmacd merged commit ece6333 into open-telemetry:main May 23, 2025
41 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.

2 participants