Skip to content

Conversation

luigidellaquila
Copy link
Contributor

@luigidellaquila luigidellaquila commented May 30, 2025

Try to reduce the overhead introduced by #120302
The changes are minimal, but they are on the critical execution path of date histogram calculation.

@luigidellaquila luigidellaquila requested a review from bpintea June 6, 2025 07:54
@luigidellaquila luigidellaquila marked this pull request as ready for review June 6, 2025 07:54
@luigidellaquila luigidellaquila requested a review from a team as a code owner June 6, 2025 07:54
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 6, 2025
@elasticsearchmachine
Copy link
Collaborator

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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...

Copy link
Contributor

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.

Copy link
Contributor

@bpintea bpintea left a 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) {
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

@luigidellaquila luigidellaquila enabled auto-merge (squash) June 10, 2025 08:52
@luigidellaquila luigidellaquila merged commit aa87f46 into elastic:main Jun 10, 2025
17 of 18 checks passed
@luigidellaquila
Copy link
Contributor Author

We got a confirmation from the nightlies, this worked.

valeriy42 pushed a commit to valeriy42/elasticsearch that referenced this pull request Jun 12, 2025
luigidellaquila added a commit to luigidellaquila/elasticsearch that referenced this pull request Jun 19, 2025
@luigidellaquila
Copy link
Contributor Author

Manual backport in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants