Skip to content

Conversation

@alexander-novo
Copy link
Collaborator

Description

Changed connection_nodes_ to an array to prevent tree searches in hot loops.

There are some virtual functions implemented by CircuitComponent which aren't marked final or const and are called in a couple of hot loops inside evaluateResidual(). The optimizer can't inline these functions or perform LICM, so these functions end up being called billions of times during the simulation, which contributes a few percents to the overall runtime of the simulation.

I've gone through and marked many of these functions as final and added const variants. These functions could probably be marked as const in Evaluator, but I didn't want to change something that would affect the phasor dynamics module without a thumbs up.

I've also manually performed LICM in the hot loops in evaluateResidual() because I don't want to depend on the optimizer getting this right - this could very easily regress in the future.

Closes #324

Proposed changes

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

@alexander-novo alexander-novo self-assigned this Jan 8, 2026
@alexander-novo alexander-novo added the enhancement New feature or request label Jan 8, 2026
@alexander-novo alexander-novo changed the title Minor improvements to PowerElectronics Minor improvements to PowerElectronics residual evaluation Jan 8, 2026
@alexander-novo alexander-novo changed the title Minor improvements to PowerElectronics residual evaluation Minor performance improvements to PowerElectronics residual evaluation Jan 8, 2026
Copy link
Collaborator

@pelesh pelesh left a comment

Choose a reason for hiding this comment

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

Great work! Please fix changeling conflict before merging.

Allow for (hopefully) better inlining and LICM by the optimizer when we're pointing to a CircuitComponent or PowerElectronicsModel
@alexander-novo alexander-novo force-pushed the alex/minor-powerelec-improvements branch from 8b314f1 to cefbb7c Compare January 9, 2026 20:46
@pelesh pelesh merged commit 61b657b into develop Jan 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Small performance improvements to power electronics module

4 participants