Skip to content

#14493 Speed up deleting a summary ensemble - #14494

Merged
magnesj merged 2 commits into
OPM:devfrom
magnesj:summary-ensemble-clear-curve-sets
Aug 10, 2026
Merged

#14493 Speed up deleting a summary ensemble#14494
magnesj merged 2 commits into
OPM:devfrom
magnesj:summary-ensemble-clear-curve-sets

Conversation

@magnesj

@magnesj magnesj commented Aug 8, 2026

Copy link
Copy Markdown
Member

Deleting a summary ensemble did work proportional to the number of realizations, in two independent places. Fixes #14493.

Measured

Deleting an ensemble from a project with many plots, in the running application. Before is 2322d9e97f on dev.

Measurement Before After Change
deleteSummaryCaseCollection 2.1 s 0 ms eliminated
~RimSummaryEnsemble 1.3 s 704 ms 1.85 x
Total 3.5 s 835 ms 4.2 x, 2.7 s saved

Before the change the two sections account for 3.4 s of the 3.5 s total, so nothing significant sits outside them. See #14493 (comment) for the full notes.

Delete curves for all cases in one pass

deleteSummaryCaseCollection() looped over every case, and for each case scanned every summary plot and called updateConnectedEditors() on every multi plot. Each plot was scanned once per realization, and the connected editors were updated once per realization and multi plot.

deleteCurvesAssosiatedWithCase() is replaced by deleteCurvesAssosiatedWithCases(), which takes a set of cases and returns whether anything was deleted. Each plot is scanned once, and the connected editors of a multi plot are updated only when that multi plot actually lost a curve.

This drops to 0 ms because nothing matches. The realization curves belong to RimEnsembleCurveSet::m_realizationCurves, not to the plot's RimSummaryCurveCollection::m_curves, so no curve is deleted and no editor is updated. Before the change, that same empty result cost 2.1 s.

RicCloseSummaryCaseFeature and RicCloseObservedDataFeature are updated to the new signature. RicCloseSummaryCaseFeature also scans each plot once instead of once per case.

Clear the referring curve sets instead of reloading them

~RimSummaryEnsemble() deletes the cases and then calls updateReferringCurveSets(), which runs RimEnsembleCurveSet::loadDataAndUpdate() on every referring curve set. Calling it after the cases are deleted is intentional, the curve sets are meant to end up empty, but reloading the curve data has nothing to read at that point. The reload also syncs UI fields, reloads the curve filters, rebuilds the address list, recomputes statistics over an empty case set and updates three legends, and it calls updateAll() on the parent plot once per curve set instead of once per plot.

clearReferringCurveSets() deletes the ensemble and statistics curves directly and updates each affected plot once.

The referring objects are queried as RimEnsembleCurveSet instead of walking all referring objects and casting. The previous loop discarded everything that was not a curve set, so the behaviour is unchanged.

curveSet->filterChanged.send() is kept, so RimAbstractCorrelationPlot, RimEnsembleWellLogCurveSet and RimEnsembleSurface still get the same notification as before. Sending a filter change while the ensemble is being deleted is questionable and it is the first thing to try if the remaining 704 ms is worth chasing, but removing it is a behaviour change and is left out of this fix.

Note

This touches ~RimSummaryEnsemble() and so conflicts with #14492, which replaces m_cases.deleteChildrenAsync() with m_cases.deleteChildren() in the same destructor. The resolution is to keep both changes, they are independent.

A dozen other types hold a PdmPtrField<RimSummaryEnsemble*>, among them RimAnalysisPlotDataEntry, RimParameterRftCrossPlot, RimRftTornadoPlot, RimOpmFlowJob and the ensemble histogram data sources. None of them are notified when the ensemble is deleted, before or after this change.

@magnesj magnesj self-assigned this Aug 10, 2026
@magnesj
magnesj requested a review from kriben August 10, 2026 05:57
@magnesj
magnesj marked this pull request as ready for review August 10, 2026 05:57
…eted

The destructor called updateReferringCurveSets(), which runs loadDataAndUpdate() on every referring curve set. At that point the summary cases are already deleted, so reloading the curve data has nothing to read. The reload also syncs UI fields, reloads the curve filters, rebuilds the address list, recomputes statistics over an empty case set and updates three legends, and it calls updateAll() on the parent plot once per curve set instead of once per plot.

Add clearReferringCurveSets(), which deletes the ensemble and statistics curves directly and updates each affected plot once. For an ensemble with many realizations spread over several curve sets in the same plot this removes most of the work done while deleting.

Query the referring objects as RimEnsembleCurveSet instead of walking all referring objects and casting. The previous loop discarded everything that was not a curve set, so the behavior is unchanged.
…mary ensemble

deleteSummaryCaseCollection() looped over every case in the ensemble, and for each case scanned every summary plot and called updateConnectedEditors() on every multi plot. For an ensemble with many realizations this scanned each plot once per realization, and updated the connected editors once per realization and multi plot. This showed up as a hot spot in the profiler.

Replace deleteCurvesAssosiatedWithCase() with deleteCurvesAssosiatedWithCases(), which takes a set of cases and returns whether anything was deleted. Each plot is now scanned once, and the connected editors of a multi plot are updated only when that multi plot actually lost a curve.

RicCloseSummaryCaseFeature and RicCloseObservedDataFeature are updated to the new signature. RicCloseSummaryCaseFeature also scans each plot once instead of once per case.
@magnesj
magnesj force-pushed the summary-ensemble-clear-curve-sets branch from 4799dc1 to eb1af64 Compare August 10, 2026 09:20
@magnesj
magnesj merged commit 1660e33 into OPM:dev Aug 10, 2026
10 checks passed
@magnesj
magnesj deleted the summary-ensemble-clear-curve-sets branch August 10, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Summary: deleting an ensemble does work proportional to the number of realizations

2 participants