-
Notifications
You must be signed in to change notification settings - Fork 188
perf(ender:candles): precompute strings, simpler getCandle #3317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughRefactors candle start time representation from DateTime objects to ISO strings throughout the candles generator, consolidates BlockCandleUpdatesMap generation into createOrUpdatePostgresCandles, and updates method signatures to propagate ISO-based time usage consistently. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
DateTime.toISO()calls by pre-computing ISO string timestamps once duringCandlesGeneratorinitialization.getCandleto use optional chaining, simplifying cache lookup logic.blockCandleUpdatesMapfromupdateCandlesscope, inlineperpetualMarketslookup.Details
Performance optimization:
resolutionStartTimesISO: Map<CandleResolution, string>field to cache ISO timestamp strings alongside the existingresolutionStartTimesmap.startedAtISO: stringinstead ofDateTimeobjects, removing 10+.toISO()calls per block.getOpenInterestMapto avoid repeated conversions in tight loops.Code simplification:
getCandlewith optional chaining:candlesMap[ticker]?.[resolution].blockCandleUpdatesMapgeneration inline increateOrUpdatePostgresCandlesto clarify data flow.perpetualMarketsarray andperpetualMarketTickersto avoid repeated map value retrievals.Risk & Impact
Low risk: internal refactor with no behavior change.
toISO()overhead during candle generation for each block.Testing
No new tests added; existing coverage reused.
Deployed to testnet and internal-mainnet.