Skip to content

[aggregator] more efficiently reference previously consumed values#3841

Open
rallen090 wants to merge 6 commits into
masterfrom
ra/agg-cpu-improve
Open

[aggregator] more efficiently reference previously consumed values#3841
rallen090 wants to merge 6 commits into
masterfrom
ra/agg-cpu-improve

Conversation

@rallen090

@rallen090 rallen090 commented Oct 14, 2021

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Improve a CPU inefficiency in the aggregator consume path.

On any aggregate Consume(t timestamp) call, identifying the timestamp directly preceding t required a full scan of a map of all data points in that aggregate's buffer past (see previousTimestamp(...)). We already have ordered datapoints in memory, and so now use that to identify a preceding datapoint instead of this extraneous map.

image

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


@rallen090 rallen090 changed the title Ra/agg cpu improve [aggregator] more efficiently reference previously consumed values Oct 14, 2021
@codecov

codecov Bot commented Oct 14, 2021

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.8%. Comparing base (9a2f021) to head (c711a63).
⚠️ Report is 313 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #3841     +/-   ##
========================================
- Coverage    57.0%   56.8%   -0.2%     
========================================
  Files         552     552             
  Lines       63129   63123      -6     
========================================
- Hits        36033   35906    -127     
- Misses      23907   24018    +111     
- Partials     3189    3199     +10     
Flag Coverage Δ
aggregator 63.3% <ø> (-0.1%) ⬇️
cluster ∅ <ø> (∅)
collector 58.4% <ø> (ø)
dbnode 60.5% <ø> (-0.3%) ⬇️
m3em 46.4% <ø> (ø)
metrics 19.7% <ø> (ø)
msg 74.2% <ø> (-0.3%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a2f021...c711a63. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

require.Equal(t, 0, len(*forwardRes))
require.Equal(t, 0, len(*onForwardedFlushedRes))
require.Equal(t, 1, len(e.values))
require.Equal(t, 2, len(e.values))

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.

Why is this changing, shouldn't we still be consuming a value?

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.

Ah ok so the first one should have onConsumeExpired set on it, worth checking that here?

timeNanos,
prevTimeNanos,
e.toConsume[i].lockedAgg,
e.toConsume[i],

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.

nit: fix the comment if a previous timestamps was dirty to if a previous timestamp was dirty

@arnikola arnikola 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.

Looks good!

@@ -118,11 +117,14 @@ type timedAggregation struct {
startAtNanos int64 // start time of an aggregation window
lockedAgg *lockedAggregation
onConsumeExpired bool

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.

move this to the bottom of the struct to avoid 7 bytes of padding

@ryanhall07 ryanhall07 removed their request for review June 18, 2026 12:31
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.

3 participants