Skip to content
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 XContent Object Parsers #78813

Merged

Conversation

original-brownbear
Copy link
Member

Optimize object parsers a little by extracting cold paths, removing some unecessary
lambda wrapping and some other small things.
Also, fixed a very expensive use of these APIs in Phase moving from a very hot stream
instantiation to a standard loop.

relates #77466

Optimize object parsers a little by extracting cold paths, removing some unecessary
lambda wrapping and some other small things.
Also, fixed a very expensive use of these APIs in Phase moving from a very hot stream
instantiation to a standard loop.
@original-brownbear original-brownbear added >non-issue :Core/Infra/Core Core issues without another label :Data Management/ILM+SLM Index and Snapshot lifecycle management v8.0.0 v7.16.0 labels Oct 7, 2021
@elasticmachine elasticmachine added Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team labels Oct 7, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

}
}
return new Phase(name, (TimeValue) a[0], map);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this kind of curious. I assume this is the very expensive / hot stream instantiation referred to in the description, right? I'm surprised that the declarative stream variant is less performant than the imperative loop. It could be worth extracting into a micro benchmark and getting some perf numbers for typical collection sizes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typical size here is literally 2 :) I think that's the problem.

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One query, but LGTM otherwise.

@@ -228,7 +229,7 @@ public void testReadStepKeys() {
" \"version\" : 1,\n" +
" \"modified_date_in_millis\" : 1578521007076\n" +
" }", "phase", null),
contains(new Step.StepKey("phase", "rollover", WaitForRolloverReadyStep.NAME),
containsInAnyOrder(new Step.StepKey("phase", "rollover", WaitForRolloverReadyStep.NAME),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that the order here doesn't matter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like it does and also this wasn't actually deterministic before either. As far as I can tell, it was just random luck that it would work out the way it did anyway. The map(s) that this is build from are just hashmaps in master as well. It's just that this PR makes them pre-sized more efficiently so the order of how stuff falls into place changes.

@original-brownbear
Copy link
Member Author

Thanks Alan!

@original-brownbear original-brownbear merged commit 0e8a00b into elastic:master Oct 21, 2021
@original-brownbear original-brownbear deleted the optimize-object-parsers branch October 21, 2021 11:00
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Oct 22, 2021
Optimize object parsers a little by extracting cold paths, removing some unnecessary
lambda wrapping and some other small things.
Also, fixed a very expensive use of these APIs in Phase moving from a very hot stream
instantiation to a standard loop.
original-brownbear added a commit that referenced this pull request Oct 22, 2021
Optimize object parsers a little by extracting cold paths, removing some unnecessary
lambda wrapping and some other small things.
Also, fixed a very expensive use of these APIs in Phase moving from a very hot stream
instantiation to a standard loop.
@original-brownbear original-brownbear restored the optimize-object-parsers branch April 18, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label :Data Management/ILM+SLM Index and Snapshot lifecycle management >non-issue Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team v7.16.0 v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants