Skip to content

docs(dao): add batch-upsert long-tail latency analysis - #630

Open
jphui wants to merge 6 commits into
masterfrom
jhui/batch-aspect-upsert-long-tail-work
Open

docs(dao): add batch-upsert long-tail latency analysis#630
jphui wants to merge 6 commits into
masterfrom
jhui/batch-aspect-upsert-long-tail-work

Conversation

@jphui

@jphui jphui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds docs/batch-aspect-upsert-long-tail-latency.md, a code-level root-cause analysis of the
batch-upsert write path's long-tail latency behavior.

Production latency data from the MGA batch-upsert ramp shows BatchUpsert=true wins decisively at
higher aspect counts (CountBucket >= 2) but is flat or slightly slower than the existing
per-aspect dao.add() path at CountBucket = 1 — most visibly on dataset and datasetinstance,
which dominate MGA's write volume.

The doc captures the production evidence and traces both code paths
(BaseLocalDAO.addManyBatchInternal / EbeanLocalAccess.batchUpsert vs.
aspectUpdateHelper / addWithOptimisticLocking) to attribute the single-aspect (N=1) overhead
to constant-factor Java work — duplicated AspectKey/classNames derivation, extra
collection/stream allocation in the old-value read wrapping, and a full-string String.format
scan over the assembled multi-column upsert SQL — rather than reflection or extra DB round-trips.
It closes with suggested follow-ups in priority order (N=1 fast-path, de-duplicated derivation,
allocation trims) and a note on validating with allocation profiling / a JMH microbenchmark.

Docs-only change — no production code is modified.

Testing Done

N/A — documentation-only change. Analysis was derived from reading the existing DAO code paths and
72h production latency data; no code behavior changes.

Checklist

🤖 Generated with GitHub Copilot CLI

jphui and others added 3 commits July 14, 2026 22:49
Document production evidence that BatchUpsert=true regresses or is flat
at CountBucket=1 (notably dataset/datasetinstance, MGA's dominant write
volume) while winning decisively at CountBucket>=2, and trace the root
cause through EbeanLocalAccess.batchUpsert()/prepareMultiColumnInsert()
vs. the existing single-aspect add() path: a generic batch-get read path,
duplicated classNames/AspectKey derivation, and a String.format scan over
the fully-assembled SQL string, none of which the single-aspect path pays.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Trim production-evidence prose, condense code-level comparison to concise
per-hypothesis summaries, correct the old-value read finding (single-aspect
and batch paths share the same batchGetUnion / per-aspect-column read), and
add a 'why not do anything now' section concluding the net workload win
outweighs the ~100-200us dataset bucket-1 regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a TODO in EbeanLocalAccess.batchUpsert() pointing to
docs/batch-aspect-upsert-long-tail-latency.md for the N=1 fixed-overhead
follow-up, and apply spotless markdown formatting to the analysis doc.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.93%. Comparing base (769f7e3) to head (7c074e6).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #630   +/-   ##
=========================================
  Coverage     66.93%   66.93%           
  Complexity     1889     1889           
=========================================
  Files           148      148           
  Lines          7280     7280           
  Branches        883      883           
=========================================
  Hits           4873     4873           
  Misses         2021     2021           
  Partials        386      386           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

jphui and others added 3 commits July 21, 2026 02:11
Reduce the production-evidence table to the dataset bucket-1 row (MGA's
highest-volume write) and correct it to the actual measured regression:
per-aspect 0.308 ms to batch-upsert 0.441 ms (+43.2%). Clarify that a
positive Avg % delta denotes a regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the raw production-evidence section and internal service names,
generalize the summary and 'why not do anything now' rationale to avoid
specific numbers/counts, and drop the concrete latency figure and entity
names from the batchUpsert TODO.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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