Skip to content

Improve the overall speed and memory use of libOpenCOR#550

Merged
agarny merged 5 commits intoopencor:mainfrom
agarny:issue549
Apr 15, 2026
Merged

Improve the overall speed and memory use of libOpenCOR#550
agarny merged 5 commits intoopencor:mainfrom
agarny:issue549

Conversation

@agarny
Copy link
Copy Markdown
Contributor

@agarny agarny commented Apr 14, 2026

Fixes #549.

Copilot AI review requested due to automatic review settings April 14, 2026 12:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, -O3 for 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.

Comment thread src/sed/sedinstancetask.cpp Outdated
Comment thread src/misc/utils.cpp
Comment thread src/sed/seddocument.cpp Outdated
Comment thread src/support/cellml/cellmlfileruntime.cpp
@agarny agarny force-pushed the issue549 branch 8 times, most recently from da38ac6 to 6a997fe Compare April 15, 2026 09:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/logger/issue.cpp Outdated
Comment thread src/api/libopencor/logger.h
Comment thread src/misc/utils.cpp
Comment thread CMakeLists.txt
@agarny agarny merged commit a12d25e into opencor:main Apr 15, 2026
24 checks passed
@agarny agarny deleted the issue549 branch April 15, 2026 12:56
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.

Improve the overall speed and memory use of libOpenCOR

2 participants