Skip to content

Conversation

original-brownbear
Copy link
Contributor

@original-brownbear original-brownbear commented Oct 26, 2024

The results instance does not need to be a field.
It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance.
This should give a bit of a speedup since it reduces GC by reducing the lifetime of the results and removing a mutation of the global context resources list.

Part of #115722

The results instance does not need to be a field. It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance. Part of elastic#115722
@original-brownbear original-brownbear added >non-issue :Search/Search Search-related issues that do not fall into other categories labels Oct 26, 2024
@elasticsearchmachine elasticsearchmachine added v9.0.0 Team:Search Meta label for search team labels Oct 26, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

Comment on lines +149 to +151
try (fetchResults) {
moveToNextPhase(fetchResults.getAtomicArray(), reducedQueryPhase);
}
Copy link
Member

Choose a reason for hiding this comment

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

This overall change makes sense to me. I dislike keeping an object around in the constructor and handling lifetimes like we did. Its always confusing.

Just calling out now that with this try (autoClose), we will now release the fetchResults AFTER context.executeNextPhase is called. I am not sure that is a big issue or not as generally the search phases do asynchronous actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's to some extend by design :D The aggressive closing of these things has been causing a leak (preexisting bug) to show at a higher rate. Let me deal with that bug in a separate PR today and then I'll reintroduce aggressive closing here again tomorrow or so.

@original-brownbear
Copy link
Contributor Author

Thanks Ben!

@original-brownbear original-brownbear merged commit f0adbc6 into elastic:main Oct 28, 2024
15 of 16 checks passed
@original-brownbear original-brownbear deleted the cleanup-fetch-search-phase branch October 28, 2024 13:18
@original-brownbear original-brownbear restored the cleanup-fetch-search-phase branch October 28, 2024 13:18
@original-brownbear original-brownbear deleted the cleanup-fetch-search-phase branch October 28, 2024 13:18
ioanatia pushed a commit to ioanatia/elasticsearch that referenced this pull request Nov 4, 2024
The results instance does not need to be a field. It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance. Part of elastic#115722
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Nov 4, 2024
The results instance does not need to be a field. It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance. Part of elastic#115722
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Nov 22, 2024
The results instance does not need to be a field. It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance. Part of elastic#115722
elasticsearchmachine pushed a commit that referenced this pull request Nov 22, 2024
The results instance does not need to be a field. It's state handling is fairly straight forward, it needs to be released once all fetches have been procesed. No need to even create it on any other path so I split up the method slightly to clearly isolate when and how we need the results instance. Part of #115722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.18.0 v9.0.0

3 participants