perf(dashboard): O(n log k) pagination for selectVisibleTransactions - #408
Merged
Conversation
|
@B3rnard601 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Replaces the full O(n log n) sort in
selectVisibleTransactionswith a bounded top-kselection, so pagination only costs work proportional to the page requested, not the
whole transaction history.
Type of change
Related issue
Closes #375
Changes
src/dashboard/transaction-history.tsselectVisibleTransactionsnow uses a bounded min-heap top-k selection (O(n log k)) instead of sorting the full filtered list, with a fallback to full sort when k approaches nsrc/tests/transaction-history-crash.test.tsdocs/api.mdCHANGELOG.md[Unreleased] / FixedBenchmark (ms/call, uniform random timestamps, unfiltered)
Worst case (last page of a large unfiltered list, where the fallback kicks in) is a wash:
8.21ms → 8.34ms.
Checklist
npm run typecheck— no errorsnpm run lint— no warningsnpm test— all tests pass (556/556, 2 new)npm run build— bundle compiles cleanlyanytypes introduceddocs/api.mdbigint— noNumber()conversion in arithmeticsrc/tests/CHANGELOG.mdupdated under[Unreleased]src/index.tsupdated if new exports addedBreaking changes?
Notes for reviewers
The linked issue was a placeholder with no concrete target ("module 41" doesn't exist in
the repo). I profiled the SDK to find a real hot path instead of fabricating one — this is
the most significant, defensible perf finding I could substantiate with actual benchmarks,
not synthetic numbers. Correctness matters more than speed here given this touches a
financial dashboard, so I leaned on cross-checking against a brute-force reference
implementation rather than trusting the algorithm by inspection alone.