Optimize memory usage in ShardBulkInferenceActionFilter#124313
Merged
jimczi merged 15 commits intoelastic:mainfrom Mar 14, 2025
Merged
Optimize memory usage in ShardBulkInferenceActionFilter#124313jimczi merged 15 commits intoelastic:mainfrom
jimczi merged 15 commits intoelastic:mainfrom
Conversation
This refactor improves memory efficiency by processing inference requests in batches, capped by a max input length. Changes include: - A new dynamic operator setting to control the maximum batch size in bytes. - Dropping input data from inference responses when the legacy semantic text format isn’t used, saving memory. - Clearing inference results dynamically after each bulk item to free up memory sooner. This is a step toward enabling circuit breakers to better handle memory usage when dealing with large inputs.
Collaborator
|
Pinging @elastic/search-inference-team (Team:Search - Inference) |
Collaborator
|
Pinging @elastic/search-eng (Team:SearchOrg) |
Collaborator
|
Pinging @elastic/search-relevance (Team:Search - Relevance) |
Collaborator
|
Hi @jimczi, I've created a changelog YAML for you. |
Collaborator
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
kderusso
approved these changes
Mar 7, 2025
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Show resolved
Hide resolved
jan-elastic
approved these changes
Mar 7, 2025
Contributor
jan-elastic
left a comment
There was a problem hiding this comment.
LGTM. Few small code comments, and I think there's still an inefficiency (but that's also prior to this PR).
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
| // ignore delete request | ||
| continue; | ||
| if (useLegacyFormat) { | ||
| var newDocMap = indexRequest.sourceAsMap(); |
Contributor
There was a problem hiding this comment.
I'll close my PR; it conflicts badly with this.
I'll check whether this resolves the inefficiency I spotted and let you know.
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Show resolved
Hide resolved
Mikep86
approved these changes
Mar 7, 2025
Contributor
Mikep86
left a comment
There was a problem hiding this comment.
Looks good overall, I left a few non-blocking comments
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/xpack/inference/action/filter/ShardBulkInferenceActionFilter.java
Outdated
Show resolved
Hide resolved
7cb386f to
06a96e9
Compare
Collaborator
|
Hi @jimczi, I've created a changelog YAML for you. |
Collaborator
💚 Backport successful
|
elasticsearchmachine
pushed a commit
that referenced
this pull request
Mar 14, 2025
…24863) This refactor improves memory efficiency by processing inference requests in batches, capped by a max input length. Changes include: - A new dynamic operator setting to control the maximum batch size in bytes. - Dropping input data from inference responses when the legacy semantic text format isn’t used, saving memory. - Clearing inference results dynamically after each bulk item to free up memory sooner. This is a step toward enabling circuit breakers to better handle memory usage when dealing with large inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This refactor improves memory efficiency by processing inference requests in batches, capped by a max input length.
Changes include:
This is a step toward enabling circuit breakers to better handle memory usage when dealing with large inputs.