Skip to content

[flags]: evaluation aggregation followup#3178

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
developfrom
typo/easy-lock
Feb 17, 2026
Merged

[flags]: evaluation aggregation followup#3178
gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
developfrom
typo/easy-lock

Conversation

@typotter

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR simplifies one of the aggregation lock holds and restarts the memory->storage flush timer.

Motivation

@dd-oleksii, legend

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@typotter
typotter requested a review from a team as a code owner February 13, 2026 15:31
@typotter
typotter requested review from Copilot and dd-oleksii and removed request for a team February 13, 2026 15:31
Base automatically changed from typo/FFL-1720-pr2-aggregation to feature/flags-evaluations-logging February 13, 2026 15:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies the lock handling in the evaluation aggregation system and ensures the periodic flush timer is restarted after auto-drain events. The changes address a performance optimization by removing redundant lock acquisitions and fix a missing timer restart when aggregations are automatically flushed due to reaching the maximum threshold.

Changes:

  • Simplified lock acquisition in EvaluationAggregator.record() to use a single critical section instead of releasing and re-acquiring the lock
  • Added reschedulePeriodicFlush() call in EvaluationEventsProcessor.processEvaluation() when auto-drain occurs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
features/dd-sdk-android-flags/src/main/kotlin/com/datadog/android/flags/internal/aggregation/EvaluationAggregator.kt Simplified lock handling by consolidating the record and drain operations into a single critical section, removing the previous pattern that released and re-acquired the lock
features/dd-sdk-android-flags/src/main/kotlin/com/datadog/android/flags/internal/EvaluationEventsProcessor.kt Added timer restart after auto-drain to ensure periodic flush scheduling is reset, making behavior consistent with manual flush

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +55 to 58
val drained = mapLock.withLock {
@Suppress("UnsafeThirdPartyFunctionCall") // Only throws if null is passed
val existing = aggregationMap.get(key) ?: AggregationStats(
aggregationKey = key,

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

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

The documentation at lines 28-30 states "Uses double-check locking to avoid spurious flushes when multiple threads reach the threshold simultaneously. The size is checked without a lock first (fast path), then re-checked while holding the write lock before draining." However, this change removes the double-check locking pattern - the implementation now acquires the lock once and performs all operations (record + size check + drain) within a single critical section. The documentation should be updated to reflect this change.

Copilot uses AI. Check for mistakes.

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.

fixed

dd-oleksii
dd-oleksii previously approved these changes Feb 13, 2026
Comment on lines +74 to +75
writer.writeAll(drainedEvents)
reschedulePeriodicFlush()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor: we don't need to wait for write to finish, we can reschedule first (similar to how we do in regular flush)

Suggested change
writer.writeAll(drainedEvents)
reschedulePeriodicFlush()
reschedulePeriodicFlush()
writer.writeAll(drainedEvents)

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.

done

@datadog-datadog-prod-us1

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Feb 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.37%. Comparing base (a90ef93) to head (b22e4c9).
⚠️ Report is 265 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3178      +/-   ##
===========================================
+ Coverage    71.27%   71.37%   +0.10%     
===========================================
  Files          929      929              
  Lines        34450    34455       +5     
  Branches      5817     5816       -1     
===========================================
+ Hits         24554    24592      +38     
+ Misses        8257     8247      -10     
+ Partials      1639     1616      -23     
Files with missing lines Coverage Δ
...ndroid/flags/internal/EvaluationEventsProcessor.kt 95.24% <100.00%> (+0.08%) ⬆️
...flags/internal/aggregation/EvaluationAggregator.kt 100.00% <100.00%> (ø)

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

0xnm
0xnm previously approved these changes Feb 16, 2026
@typotter
typotter changed the base branch from feature/flags-evaluations-logging to develop February 17, 2026 17:10
@typotter
typotter dismissed 0xnm’s stale review February 17, 2026 17:10

The base branch was changed.

@typotter

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Feb 17, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-02-17 17:10:22 UTC ℹ️ Start processing command /merge


2026-02-17 17:10:30 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-02-17 19:50:08 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in develop is approximately 1h (p90).


2026-02-17 20:59:00 UTC ℹ️ MergeQueue: This merge request was merged

@typotter
typotter requested a review from 0xnm February 17, 2026 17:12
@typotter

Copy link
Copy Markdown
Contributor Author

Base changed (feature is merged) and merged the latest from developer. PTAL, @0xnm

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 22c2444 into develop Feb 17, 2026
27 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the typo/easy-lock branch February 17, 2026 20:58
@ncreated
ncreated restored the typo/easy-lock branch April 9, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants