-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Optimize date rounding #128687
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
Optimize date rounding #128687
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
long roundFloor(long utcMillis, int multiplier) { | ||
return multiplier == 1 ? DateUtils.roundYear(utcMillis) : DateUtils.roundYearInterval(utcMillis, multiplier); | ||
assert multiplier == 1; | ||
return DateUtils.roundYear(utcMillis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm my understanding that this check was showing in profile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that one specifically, but the equivalent for WEEK_OF_YEAR
, in particular I see the cost of roundWeekIntervalOfWeekYear()
. It's smaller than the slowdown we are seeing in the nightlies though.
My doubt is that these methods are really small, so they are probably hard to sample and catch in flamegraphs.
On the other hand, in the commit diff there is really nothing apart from this change (all the rest is tests), so this is my only candidate...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My doubt is that these methods are really small, so they are probably hard to sample and catch in flamegraphs.
If they're small but called a lot, I would statistically expect them to still show up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand why the change would have a performance impact, practically, but I think we could give it a try.
Design-wise, we'll probably want to iterate further -- it'd be good to log an issue to come back to it.
return ratio; | ||
} | ||
}, | ||
YEARS_OF_CENTURY((byte) 9, "years", ChronoField.YEAR_OF_ERA, false, 12) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add these two new enums to the tests?
@Override | ||
long roundFloor(long utcMillis, int multiplier) { | ||
return DateUtils.roundWeekIntervalOfWeekYear(utcMillis, multiplier); | ||
assert multiplier == 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this change. If we want the change as a short term one, to profile the outcome in an integrated system, it's OK, but otherwise we would better change the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure either.
Yeah, that's the intention
long roundFloor(long utcMillis, int multiplier) { | ||
return multiplier == 1 ? DateUtils.roundYear(utcMillis) : DateUtils.roundYearInterval(utcMillis, multiplier); | ||
assert multiplier == 1; | ||
return DateUtils.roundYear(utcMillis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My doubt is that these methods are really small, so they are probably hard to sample and catch in flamegraphs.
If they're small but called a lot, I would statistically expect them to still show up.
We got a confirmation from the nightlies, this worked. |
Manual backport in progress |
Try to reduce the overhead introduced by #120302
The changes are minimal, but they are on the critical execution path of date histogram calculation.