Reuse existing aggregation when resolving summary vector blob id - #2
Merged
Merged
Conversation
Resolving the blob id for a summary vector triggered a new aggregation on Sumo on every call, taking around 5 seconds per vector even when the aggregation already existed. SearchContext.aggregation_async() looks for an existing aggregation by adding an aggregation filter to the context it is called on. Filters accumulate, so the per-realization context passed in here contributed a must clause on fmu.realization.id while the probe added one on fmu.aggregation.operation. No object carries both, so the probe matched nothing and the aggregation was always re-triggered. Probe for an existing aggregation on a separate context without the realization filter, and reuse it when it still covers all realizations. Triggering aggregation is unchanged and remains the fallback. Measured against a case with four vectors, blob id resolution went from around 5000 ms to around 600 ms per vector.
jorgenherje
self-requested a review
August 12, 2026 05:54
jorgenherje
approved these changes
Aug 12, 2026
jorgenherje
left a comment
Collaborator
There was a problem hiding this comment.
Tested and looks good. Made minor adjustments for readability
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.
Resolving the blob id for a summary vector triggered a new aggregation on Sumo on every call, costing around 5 seconds per vector even when the aggregation already existed. Loading four vectors for one well took 29 seconds, 21 of which was blob id resolution.
Cause
SearchContext.aggregation_async()looks for an existing aggregation by adding an aggregation filter to the context it is called on:Filters accumulate rather than replace, and
realizationandaggregationmap to different fields. The context passed in from_get_vector_agg_tablecarriedrealization=True, so the probe ended up requiring both:No FMU object is both a realization member and an aggregation, so the probe matched nothing for every vector on every call, and the code always fell through to
POST /aggregationsplus aRetry-Afterpoll. The fallback returns a correct result, so the only symptom was latency.The last line of
aggregation_asyncshows the implicit contract: it addsrealization=Trueitself for the trigger path, so it expects the context not to be realization-filtered already.Change
Probe for an existing aggregation on a separate context, without the realization filter:
The aggregation is reused only when
_is_aggregation_currentconfirms it still covers all realizations. That check mirrors whataggregation_asyncapplies before reusing an aggregation, so an aggregation made before further realizations were uploaded is not handed out. Triggering aggregation is unchanged and remains the fallback.Note that setting
realization=Falseinstead does not work:aggregate_asyncunconditionally re-addsrealization=True, giving a query that both requires and forbidsfmu.realization.id, and blob id resolution then returns nothing.Measurements
Case
e7f117b6-29fe-488f-989c-dbbc9bd03f09, ensembleiter-0, vectorsWOPR:A1,WGOR:A1,WWCT:A1,WWPR:A1, driven from ResInsight through the service.Downloaded payloads are byte identical before and after (71468 / 69169 / 71616 / 71612 bytes), and the blob ids match.
The fallback was verified separately on a vector with no existing aggregation:
WGPR:A4had no aggregation, triggered one, and the result was picked up by the fast path on the next call.Upstream
This is a workaround for what looks like a defect in fmu-sumo:
aggregation_async(and the syncaggregation) probe on whatever context they are called on, with no way to drop an inheritedrealizationclause, andassert numaggs <= 1cannot catch the case. A fix there would make this workaround unnecessary.