⚡ Optimize hourly heatmap generation via caching and fast path parsing#115
⚡ Optimize hourly heatmap generation via caching and fast path parsing#115
Conversation
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 58 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request optimizes the buildHourlyHeatmapFromCommitDates function by introducing a weekday cache and a fast-path for standard ISO 8601 date strings, alongside new unit tests for getMostActiveHour. Review feedback highlights a critical issue where manually parsed hours lack validation, potentially leading to out-of-bounds array access, and suggests simplifying the timezone detection logic. There is also a recommendation to refactor redundant fallback logic into a helper function to improve code maintainability.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed review feedback in : added hour-range guard for fast-path parsing, simplified UTC fast-path check to , and extracted fallback date parsing into a helper to remove duplication. Pushed in cc25d5b and resolved addressed threads. |
Acknowledged. Thanks for resolving the feedback threads and pushing the updates! |
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/yearInReviewUtils.ts`:
- Around line 18-49: The fast-path in the loop (where you use dayCache,
incrementFromFullDate, and heatmap) accepts timestamps with invalid
minutes/seconds (e.g. "2024-03-01T12:99:99Z"); restrict the fast-path to only
truly valid UTC timestamps by validating the minute and second fields and the
':' separators (or match the full pattern YYYY-MM-DDTHH:MM:SSZ) before
incrementing heatmap[day][hour]; if validation fails, call
incrementFromFullDate(dateString) as the fallback so only valid parsed dates are
counted.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e242323b-a433-494a-a6d0-7e823b9c10bc
📒 Files selected for processing (2)
patch.diffsrc/lib/yearInReviewUtils.ts
💤 Files with no reviewable changes (1)
- patch.diff
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed the follow-up CodeRabbit issue by tightening the fast path to strict validation and validating minute/second ranges before incrementing heatmap; invalid UTC-like strings now correctly fall back/skip. Added regression test for malformed UTC timestamp (). Pushed in , added ❤️ reaction, and resolved the thread. |
Acknowledged. Thanks for resolving the remaining feedback and updating the tests! |
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
💡 What:
Optimized
buildHourlyHeatmapFromCommitDatesinsidesrc/lib/yearInReviewUtils.ts. Instead of usingnew Date()for every commit string in the loop to compute thegetUTCDay()andgetUTCHours(), this adds a fast path for typical ISO 8601 strings ending in Z.It manually parses the hour via fast
charCodeAtmath and extracts the YYYY-MM-DD date part. Crucially, it caches thedaycalculation using theYYYY-MM-DDstring as the key. This avoids repeated expensivenew Date()calls for each commit on the same day. Any string with timezone offsets or non-standard format gracefully falls back to the nativenew Date()parser.🎯 Why:
The previous code executed multiple array traversals via
new Date(dateString)repeatedly for every element incommitDates.new Date()parsing is notoriously slow when executed 10k-100k times. By leveraging a Map cache and simple string manipulation, we reduce object allocations and string parsing overhead, significantly speeding up the stats generation.📊 Measured Improvement:
On a benchmark consisting of 100,000 standard GitHub API ISO
Zstrings, running 10 iterations:PR created automatically by Jules for task 11919669200318792480 started by @is0692vs