Skip to content

Conversation

@reneSchm
Copy link
Member

@reneSchm reneSchm commented Jan 12, 2026

Changes and Information

A fairly small change to the index_of_type implementation results in a significant reduction in time and memory used during compilation of larger flow models. Tested on the off-repo sde_ui10 that uses ~400 flows, resulting in a speedup of 4 while using 1/5 of the memory. This is a rough measurement using /usr/bin/time on clean compiling the ui10 example, see the attached file for details.

Merge Request - Guideline Checklist

Please check our git workflow. Use the draft feature if the Pull Request is not yet ready to review.

Checks by code author

  • Every addressed issue is linked (use the "Closes #ISSUE" keyword below)
  • New code adheres to coding guidelines
  • No large data files have been added (files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • Tests are added for new functionality and a local test run was successful (with and without OpenMP)
  • Appropriate documentation within the code (Doxygen) for new functionality has been added in the code
  • Appropriate external documentation (ReadTheDocs) for new functionality has been added to the online documentation
  • Proper attention to licenses, especially no new third-party software with conflicting license has been added
  • (For ABM development) Checked benchmark results and ran and posted a local test above from before and after development to ensure performance is monitored.

Checks by code reviewer(s)

  • Corresponding issue(s) is/are linked and addressed
  • Code is clean of development artifacts (no deactivated or commented code lines, no debugging printouts, etc.)
  • Appropriate unit tests have been added, CI passes, code coverage and performance is acceptable (did not decrease)
  • No large data files added in the whole history of commits(files should in sum not exceed 100 KB, avoid PDFs, Word docs, etc.)
  • On merge, add 2-5 lines with the changes (main added features, changed items, or corrected bugs) to the merge-commit-message. This can be taken from the briefly-list-the-changes above (best case) or the separate commit messages (worst case).

@reneSchm reneSchm self-assigned this Jan 12, 2026
@reneSchm reneSchm added loc::backend This issue concerns the C++ backend implementation. class::improvement Cleanup that doesn't affect functionality labels Jan 12, 2026
@reneSchm reneSchm changed the title Improve compile time of Flows and TypeList Improve compile time of Flows Jan 12, 2026
@reneSchm reneSchm requested a review from HenrZu January 12, 2026 17:58
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.28%. Comparing base (616cf03) to head (727d82a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1475      +/-   ##
==========================================
- Coverage   97.31%   97.28%   -0.04%     
==========================================
  Files         187      187              
  Lines       16027    16017      -10     
==========================================
- Hits        15597    15582      -15     
- Misses        430      435       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@HenrZu HenrZu left a comment

Choose a reason for hiding this comment

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

Thank you for this great addition :) The head-tail iteration is really smart.
I have a few minor comments.

I just checked, and the maximum recursion depth is around 1000 (depending on the compiler). I know that this is a super artificial setup, but maybe its necessary at some point, we should perhaps leave a comment in the file that you can increase it with a flag. What do you think? (Especially considering the ODE model with fully continuous mobility, where we also have the spatial index).

reneSchm and others added 2 commits January 14, 2026 09:39
Co-authored-by: Henrik Zunker <69154294+HenrZu@users.noreply.github.com>
Co-authored-by: Henrik Zunker <69154294+HenrZu@users.noreply.github.com>
@reneSchm
Copy link
Member Author

I just checked, and the maximum recursion depth is around 1000 (depending on the compiler). I know that this is a super artificial setup, but maybe its necessary at some point, we should perhaps leave a comment in the file that you can increase it with a flag. What do you think?

Maybe it makes sense to mention in the rst documentation that FlowModels with >500 Flows are a questionable idea. But I don't think putting comments on compiler flags deep into the metaprogramming header will be very helpful. But the kind of errors you get when this fails are usually well searchable. Also, you will notice the compile time increase.

I lean towards not writing down anything. Web results are probably easier to find then our text, wherever we put it. Also, the flags vary by compiler (and maybe even version?).

@reneSchm reneSchm requested a review from HenrZu January 14, 2026 13:55
@reneSchm reneSchm closed this Jan 14, 2026
reneSchm added a commit that referenced this pull request Jan 14, 2026
Co-authored-by: Henrik Zunker <69154294+HenrZu@users.noreply.github.com>
@reneSchm reneSchm deleted the improve-compile-time-of-index_of_type branch January 14, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

class::improvement Cleanup that doesn't affect functionality loc::backend This issue concerns the C++ backend implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants