Skip to content

Conversation

@andygrove
Copy link
Member

@andygrove andygrove commented Dec 27, 2025

Which issue does this PR close?

Closes #2995

Rationale for this change

Sub-day truncations (MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR) are timezone-independent - truncating to the minute boundary is the same regardless of timezone display. This allows simple integer arithmetic instead of expensive DateTime conversions.

Sub-day Formats (Optimized with Arithmetic)

Format Before After Speedup
HOUR 957 µs 32 µs ~30x faster (96.6% improvement)
MINUTE 640 µs 32 µs ~20x faster (95% improvement)
SECOND 405 µs 32 µs ~12x faster (92% improvement)
MILLISECOND 430 µs 32 µs ~13x faster (92.6% improvement)
MICROSECOND 435 µs 27 µs ~16x faster (93.7% improvement)

Non-UTC Timezone (America/New_York)

Format Before After Speedup
SECOND 598 µs 35 µs ~17x faster (94.2% improvement)

What changes are included in this PR?

How are these changes tested?

@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.58%. Comparing base (f09f8af) to head (75a53cb).
⚠️ Report is 803 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2996      +/-   ##
============================================
+ Coverage     56.12%   59.58%   +3.46%     
- Complexity      976     1377     +401     
============================================
  Files           119      167      +48     
  Lines         11743    15493    +3750     
  Branches       2251     2569     +318     
============================================
+ Hits           6591     9232    +2641     
- Misses         4012     4962     +950     
- Partials       1140     1299     +159     

☔ View full report in Codecov by Sentry.
📢 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.

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.

Improve performance of timestamp truncate

2 participants