Skip to content

Make comp flattening more efficient - #516

Merged
fbergmann merged 10 commits into
developmentfrom
fix-comp-check-linear
Nov 12, 2026
Merged

fbergmann merged 10 commits into
developmentfrom
fix-comp-check-linear

Conversation

@luciansmith

Copy link
Copy Markdown
Member
  • Reduces the flattening time from exponential to linear (Mattias's fix)
  • Further reduces redundant validation of 'dummy' model during flattening.
  • Fixes plugin object copying, removing redundant copies, preventing adding additional copies, and preventing adding the wrong plugin for comp ModelDefinition objects.

Tests added for some of the new copying fixes, plus Matthias's earlier test fix, plus simply not crashing on other changes.

matthiaskoenig and others added 9 commits November 2, 2026 17:04
CompSBMLDocumentPlugin::checkConsistency set mCheckingDummyDoc and
mFlattenAndCheck on the plugin of the document it checks, to make the
dummy documents it copies from it skip their model definitions and their
flat model. mCheckingDummyDoc was never reset, and mFlattenAndCheck not
after an error in a model definition, so a second check of the document
and a copy of it skipped the model definitions, and after such an error
also the flat model. The flags are now set on the dummy document only.

Refs #505.
Every modelDefinition was checked in a copy of the whole document, so a
document of N modelDefinitions was copied N times and the check was
quadratic in N, also with every check category disabled. One dummy
document is copied now and used for all modelDefinitions: its model is
swapped for the modelDefinition under check, which is held out of its
modelDefinitions during the check and put back afterwards, and the model
of the document is added to its modelDefinitions once. The dummy also
keeps the documents of the externalModelDefinitions it resolved, which
every copy read again.

Refs #505.
Merge Mattias's changes to local branch
The intent of 'enablePackage' was to give the model the comp plugins again, but it didn't; we need enablePackageInternal instead.
Main change: don't double-validate the dummy comp model during flattening.

Other changes:  don't call 'loadPlugins' more than once.  Went ahead and fixed this globally; we fixed this once before, but not everywhere, it seems.  This fixed a latent infinite (!) 'operator=' bug, and copying comp objects no longer keeps adding a new plugin object every time it gets copied.  Also, the plugins were *only* getting created when copied, instead of when they were constructed.  This is now fixed.

@fbergmann fbergmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!, unfortunately that leaves some merge conflicts

@fbergmann
fbergmann merged commit 55c6da1 into development Nov 12, 2026
35 checks passed
@fbergmann
fbergmann deleted the fix-comp-check-linear branch November 12, 2026 12: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.

3 participants