Improve the overall speed and memory use of libOpenCOR#550
Merged
agarny merged 5 commits intoopencor:mainfrom Apr 15, 2026
Merged
Improve the overall speed and memory use of libOpenCOR#550agarny merged 5 commits intoopencor:mainfrom
agarny merged 5 commits intoopencor:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR targets issue #549 by reducing avoidable allocations/copies across libOpenCOR (SED-ML/Sed runtime, logging, utilities), and by enabling stronger native build optimisations.
Changes:
- Reduce transient allocations/copies by reserving capacity, building strings without chained
append(), and returning containers via new*Ref()accessors. - Update bindings (Python/JavaScript) to use the new reference-returning accessors to avoid container copies.
- Improve native build performance via optional IPO/LTO,
-O3for non-MSVC release builds, and update CI/CD runner images and libCellML package pins.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/support/sedml/sedmlfile.cpp | Avoid repeated string allocations and some container-copy patterns in SED-ML import/population. |
| src/support/combine/combinearchive.cpp | Reserve container sizes and reuse empty pointer singletons for out-of-range/null returns. |
| src/support/cellml/cellmlfileruntime.cpp | Reduce string concatenation overhead; improve NLA objective export handling; switch to unordered_set. |
| src/support/cellml/cellmlfile.cpp | Reuse an empty singleton pointer for early-return paths. |
| src/solver/solverodefixedstep.cpp | Reduce warning/error string construction overhead; factor unknown-parameter warning. |
| src/solver/solverkinsol.cpp | Reduce warning/error string construction overhead; factor unknown-parameter warning. |
| src/solver/solvercvode.cpp | Reduce warning/error string construction overhead; factor unknown-parameter warning. |
| src/sed/sedtask.cpp | Reduce repeated task error message construction. |
| src/sed/sedsimulation.cpp | Reduce repeated missing-solver error message construction. |
| src/sed/sedmodel_p.h | Change internal changes accessor to return by const reference. |
| src/sed/sedmodel.cpp | Return changes by const reference internally and add changesRef() public accessor. |
| src/sed/sedinstancetask.cpp | Use changesRef() and add several *Ref() accessors for result vectors; reuse empty singletons. |
| src/sed/sedinstance_p.h | Change internal tasks accessor to return by const reference. |
| src/sed/sedinstance.cpp | Use tasksRef() and reserve task instance container; add tasksRef() public accessor. |
| src/sed/seddocument_p.h | Change internal models/simulations/tasks accessors to return by const reference. |
| src/sed/seddocument.cpp | Avoid stringstream usage; add *Ref() accessors and reuse empty singletons for invalid indices. |
| src/sed/sedchangeattribute.cpp | Reduce repeated warning string construction and factor shared warning format. |
| src/misc/utils.h | Convert some globals to constexpr to reduce runtime overhead. |
| src/misc/utils.cpp | Optimize URL encoding and pointer-to-hex formatting; switch toString(int/size_t) to std::format. |
| src/misc/compiler.cpp | Reduce string churn in error construction and code assembly; minor cleanups. |
| src/logger/logger.cpp | Add empty singleton for invalid indices; add *Ref() accessors; reduce shared_ptr refcount churn in addIssue. |
| src/logger/issue.cpp | Reduce allocations in formatted issue description. |
| src/file/filemanager.cpp | Reduce temporary allocations when iterating children; reserve in files(); reuse empty singleton pointer. |
| src/file/file.cpp | Reuse empty singleton containers/pointers for “no child files” cases. |
| src/bindings/python/sed.cpp | Switch bindings to *Ref() accessors to avoid vector copies. |
| src/bindings/python/logger.cpp | Switch bindings to *Ref() accessors to avoid vector copies. |
| src/bindings/javascript/sed.cpp | Switch bindings to *Ref() accessors to avoid vector copies. |
| src/bindings/javascript/logger.cpp | Switch bindings to *Ref() accessors to avoid vector copies. |
| src/api/libopencor/sedmodel.h | Document/add changesRef() accessor. |
| src/api/libopencor/sedinstancetask.h | Document/add voiRef()/stateRef()/rateRef()/constantRef()/computedConstantRef()/algebraicVariableRef(). |
| src/api/libopencor/sedinstance.h | Document/add tasksRef() accessor. |
| src/api/libopencor/seddocument.h | Document/add modelsRef()/simulationsRef()/tasksRef(); extend friend access for SedInstance. |
| src/api/libopencor/logger.h | Document/add issuesRef()/errorsRef()/warningsRef() accessors. |
| src/CMakeLists.txt | Enable IPO/LTO for native release builds when supported. |
| src/3rdparty/libCellML/CMakeLists.txt | Update prebuilt/build-from-source libCellML pins/URLs. |
| cmake/packages.cmake | Update libCellML release download tag used for prebuilt retrieval. |
| VERSION.txt | Bump library version. |
| CMakeLists.txt | Update macOS deployment target and prefer -O3 for non-MSVC release builds. |
| .github/workflows/ci.yml | Move CI jobs from Ubuntu 22.04 to 24.04 (including ARM runners). |
| .github/workflows/cd.yml | Move CD jobs from Ubuntu 22.04 to 24.04 (including ARM runners). |
| .github/workflows/buildThirdPartyLibrary.yml | Move third-party build workflow from Ubuntu 22.04 to 24.04 (including ARM runners). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
da38ac6 to
6a997fe
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 80 out of 80 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Only support the three most recent versions of macOS.
So that we can get access to `std::format()`.
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.
Fixes #549.