perf: index usage rollups#120
Closed
felixvippp-ai wants to merge 5 commits into
Closed
Conversation
Contributor
|
thanks for the effort @felixvippp-ai 🙏 this issue isn't assigned to you — please claim an open unassigned issue first, then open your PR. closing for now, hope to see it back 🙌 |
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.
Closes #59
Summary
usageStorescans on metrics, stats, agent rollups, service rollups, top agents, and protocol billing totals with maintained usage indexes.usageStorewrapper that keepsbyAgent,byService, per-agent totals, per-service totals, and protocol-wide outstanding request totals in sync onset,delete, andclear.${agent}::${serviceId}.assertUsageIndexesConsistent()for test-only brute-force parity checks.Validation
npm.cmd run build$env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.jsnpm.cmd run lintnpx.cmd prettier --check src/store/state.ts src/routes/usage.ts src/routes/services.ts src/routes/metrics.ts src/usage-index.test.tsgit diff --checkFull test result from the Windows-compatible equivalent of
npm test:Note: the repository
npm testscript uses POSIXNODE_ENV=testsyntax, which Windowscmd.execannot execute directly. I ran the same built test set with PowerShell's$env:NODE_ENV='test'before invokingnode --test.Complexity Note
Before this change, hot read paths repeatedly scanned every usage key and split string keys per request. After this change:
/api/v1/metricsand/api/v1/statsread maintained totals directly./api/v1/agents,/api/v1/agents/:agent/total, and/api/v1/agents/:agent/usageuse agent indexes./api/v1/services/:serviceId/usage,/api/v1/services/:serviceId/agents, and/api/v1/services/:serviceId/agents/topuse service indexes./api/v1/billing/totaliterates per-service totals instead of every agent/service pair.