Skip to content

Add vparquet4 encoding - #3368

Merged
stoewer merged 38 commits into
grafana:mainfrom
stoewer:add-vparquet4-encoding
May 7, 2024
Merged

Add vparquet4 encoding#3368
stoewer merged 38 commits into
grafana:mainfrom
stoewer:add-vparquet4-encoding

Conversation

@stoewer

@stoewer stoewer commented Feb 6, 2024

Copy link
Copy Markdown
Contributor

What this PR does:
This adds a new encoding vParquet4 to Tempo (the default encoding remains unchanged). The new encoding improves support for links, events, and attributes with array values. This is a prerequisite better support of links, events, and arrays in TraceQL as proposed by the TraceQL Extensions design proposal.

The vParquet4 encoding is considered experimental for now.

There are still some things missing from this PR, those will be subject to separate PRs:

  • A CLI to analyze blocks in order to find good candidates for dedicated attributes
  • Documentation about how to enable vParquet4

Hints for reviewers: This PR was created from the commits to the vparquet3 directory in the branch main-vparquet4 (diff). Since this PR adds a whole new directory vparquet4, it can be helpful to review the individual PRs in order to see the differences between vParquet3 and vParquet4.

Which issue(s) this PR fixes:
Fixes grafana/tempo-squad#384

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@stoewer
stoewer force-pushed the add-vparquet4-encoding branch from 6ff9743 to feb53f0 Compare February 6, 2024 23:46
@stoewer stoewer changed the title Add vparquet4 encoding [wip] Add vparquet4 encoding Feb 7, 2024
@ie-pham

ie-pham commented Feb 7, 2024

Copy link
Copy Markdown
Contributor

Screenshot 2024-02-07 at 2 24 35 PM
Screenshot 2024-02-07 at 2 24 58 PM
Ingester and querier memory usage is up

stoewer and others added 12 commits February 8, 2024 10:52
At this point vParquet3 and vParquet4 are identical
* Count dropped attributes and store them in separate column

* Remove current support for arrays and kv-lists
* Store per-trace service statistics in vparquet4 blocks

* Update pkg/traceql/combine.go

* Update modules/frontend/search_progress.go

* Update pkg/traceql/engine.go

* Pre-allocate finalSpanset.ServiceStats

* drop MaxServiceStats limit

---------

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Co-authored-by: A. Stoewer <adrian@stoewer.me>
* Fix skipping of dropped attributes

The attribute dropping introduced in grafana#3123 wans't implemented
correctly

* Implement single values as arrays and introduce type column

* Add support for array attributes

* Tests more array values and fix attribute conversion

* Replace individual pointer helper functions

* Use a combination of snappy and delta for ValueType

* Vendor module google/go-cmp/cmp/cmpopts

* Use all types of array attributes in TestTraceToParquet

* Improve TestFieldsAreCleared
* links and events schema changes

* update tests

* update test

* lint

* fixed tests after rebase

* lint

* addressed comments

* lint version

* reduce span to just start time for events conversion
* Add attributes to instrumentation scope

Attributes are not filled as they are not supported in current proto

* Populate instrumentation scope in test data

* Use delta encoding for dropped attributes count columns

* More consistent naming
@stoewer
stoewer force-pushed the add-vparquet4-encoding branch from 72c01b2 to 580d50f Compare February 8, 2024 01:00
The test use values are tuned to current blocks from ops in
order to have correct matching / non-matching queries

@joe-elliott joe-elliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adding comments, but I'm not 100% done. I'm quite close and only have the second half of schema.go left

Comment thread .golangci.yml
Comment thread CHANGELOG.md
Comment thread modules/frontend/search_progress.go Outdated
Comment thread pkg/traceql/combine.go
Comment thread pkg/traceql/engine.go
Comment thread tempodb/encoding/vparquet4/schema.go Outdated
Comment thread tempodb/encoding/vparquet4/block_traceql.go Outdated
Comment thread tempodb/encoding/vparquet4/combiner.go Outdated
Comment thread tempodb/encoding/vparquet4/schema.go Outdated
Comment thread tempodb/encoding/vparquet4/schema.go
@stoewer
stoewer marked this pull request as ready for review February 14, 2024 00:29

@joe-elliott joe-elliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've made a full pass of the PR now and all concerns are currently in unresolved conversations.

#3)

* Recalculate ServiceStats in combiner by moving it to assignNestedSetModelBounds()
* add additional tests

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
* Move serviceStats iterator to second pass

* fix nil map assignment

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
@stoewer
stoewer force-pushed the add-vparquet4-encoding branch from a1bbc66 to 9ab5514 Compare April 12, 2024 07:23

@joe-elliott joe-elliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was well reviewed a month or so back. A few questions and thoughts but this is quite close.

Comment thread tempodb/encoding/vparquet4/block_traceql.go Outdated
Comment thread tempodb/encoding/vparquet4/block_traceql.go Outdated
Comment thread pkg/traceql/storage.go Outdated
Comment thread tempodb/encoding/vparquet4/schema_test.go

func attrToParquetTypeUnsupported(a *v1.KeyValue, p *Attribute) {
jsonBytes := &bytes.Buffer{}
_ = jsonMarshaler.Marshal(jsonBytes, a.Value) // deliberately marshalling a.Value because of AnyValue logic

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should we do proto marshalling here for perf?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We use json for ValueKVList and ValueArray in vParquet3. Those columns are mostly empty and therefore I don't expect a big performance impact here.

Using JSON has the advantage that it is a bit easier to inspect those columns with parquet-cli

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks like we swapped span links and event attributes to proto but left others as json?

https://github.com/grafana/tempo/blob/main/tempodb/encoding/vparquet3/schema.go#L558
https://github.com/grafana/tempo/blob/main/tempodb/encoding/vparquet3/schema.go#L671

i'm fine with leaving these as json. likely they will be rare. we should keep an eye on profiles as we roll this out to see if there is significant impact on resource usage.

Comment thread tempodb/encoding/vparquet4/schema.go
Comment thread pkg/traceql/enum_attributes.go Outdated
@joe-elliott

Copy link
Copy Markdown
Collaborator

@stoewer @andreasgerstmayr this is very close. thank you for your work. there are 3 threads left to resolve. two of which are covered by andreas's PR: stoewer#5

if we push on this i think we can get it quite soon. let me know when you're ready for a final review 🙏

* make ServiceStats an intrinsic

* skip allocating ServiceStats in rebatchIterator if already allocated

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Comment thread tempodb/encoding/vparquet4/block_traceql.go
@stoewer
stoewer merged commit fc33ae5 into grafana:main May 7, 2024
joe-elliott pushed a commit to joe-elliott/tempo that referenced this pull request May 7, 2024
* Copy vparquet3 to vparquet4 folder

* Create initial vParquet4 encoding

* vParquet4: handle unsupported / dropped attributes (grafana#3123)

* Count dropped attributes and store them in separate column

* Remove current support for arrays and kv-lists

* Store per-trace service statistics in vparquet4 blocks (grafana#2941)

* Add support for attributes with array values (grafana#3221)

* Implement single values as arrays and introduce type column

* Add support for array attributes

* Tests more array values and fix attribute conversion

* Use a combination of snappy and delta for ValueType

* Vendor module google/go-cmp/cmp/cmpopts

* Use all types of array attributes in TestTraceToParquet

* Improve TestFieldsAreCleared

* links and events schema changes (grafana#3163)

* Add attributes to instrumentation scope (grafana#3322)

* Fix typo in vParquet4 event name enconding (grafana#3336)

* Precalculate and reuse the vParquet4 schema before opening blocks

* Convert block in vparquet4/test-data directory

* CHANGELOG.md

* Update test cases in BenchmarkBackendBlockTraceQL

* Unsupported attribute values are no longer dropped

* Replace ValueType column with IsArray column

* Skip service stats map allocation when none are present

---------

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Co-authored-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Co-authored-by: Jennie Pham <94262131+ie-pham@users.noreply.github.com>
Co-authored-by: Andreas Gerstmayr <andreas@gerstmayr.me>
@stoewer
stoewer deleted the add-vparquet4-encoding branch March 13, 2025 06:24
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
* Copy vparquet3 to vparquet4 folder

* Create initial vParquet4 encoding

* vParquet4: handle unsupported / dropped attributes (grafana#3123)

* Count dropped attributes and store them in separate column

* Remove current support for arrays and kv-lists

* Store per-trace service statistics in vparquet4 blocks (grafana#2941)

* Add support for attributes with array values (grafana#3221)

* Implement single values as arrays and introduce type column

* Add support for array attributes

* Tests more array values and fix attribute conversion

* Use a combination of snappy and delta for ValueType

* Vendor module google/go-cmp/cmp/cmpopts

* Use all types of array attributes in TestTraceToParquet

* Improve TestFieldsAreCleared

* links and events schema changes (grafana#3163)

* Add attributes to instrumentation scope (grafana#3322)

* Fix typo in vParquet4 event name enconding (grafana#3336)

* Precalculate and reuse the vParquet4 schema before opening blocks

* Convert block in vparquet4/test-data directory

* CHANGELOG.md

* Update test cases in BenchmarkBackendBlockTraceQL

* Unsupported attribute values are no longer dropped

* Replace ValueType column with IsArray column

* Skip service stats map allocation when none are present

---------

Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Co-authored-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Co-authored-by: Jennie Pham <94262131+ie-pham@users.noreply.github.com>
Co-authored-by: Andreas Gerstmayr <andreas@gerstmayr.me>
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.

4 participants