Skip to content

Enhancement: Make t8code around 16% faster - #2566

Merged
Davknapp merged 7 commits into
mainfrom
enhancement-speedup_t8code
Oct 21, 2026
Merged

Davknapp merged 7 commits into
mainfrom
enhancement-speedup_t8code

Conversation

@sandro-elsweijer

@sandro-elsweijer sandro-elsweijer commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Closes #2567

Describe your changes here:
This PR uses the dispatch method rather than the std:visit method used before. This drastically reduces calls and lookups for the scheme functions.
To make this even more effective, it adds a build option, which links t8code internal functions at link time instead of runtime.
Running the time forest partition benchmark wit the following command results in the following runtimes:

Serial command ./t8_time_forest_partition -b -C -l3 -r3 -x0 -X1 -T1 -D0.1 -o
Parallel command mpirun -np 8 ./t8_time_forest_partition -b -C -l3 -r3 -x0 -X1 -T1 -D0.1 -o -g

Execution mode Branch Runtime average over 3 runs Speedup
Serial main 12,07 s
optimized 9,93 s 17,7%
Parallel main 15,67 s
optimized 13,43 14,3%

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

All these boxes must be checked by the REVIEWERS before merging the pull request:

As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.

General

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation. Make sure to add a file documentation for each file!
  • README.md files are updated if necessary.
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.
  • The code coverage of the project (reported in the CI) should not decrease. If coverage is decreased, make sure that this is reasonable and acceptable.
  • Valgrind doesn't find any bugs in the new code. This script can be used to check for errors; see also this wiki article.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the scripts/internal/find_all_source_files.sh to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

License

  • The author added a BSD statement to doc/ (or already has one).

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.54%. Comparing base (980e92a) to head (79ba32b).
⚠️ Report is 292 commits behind head on main.

Files with missing lines Patch % Lines
src/t8_schemes/t8_scheme.hxx 96.55% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2566      +/-   ##
==========================================
+ Coverage   83.05%   83.54%   +0.49%     
==========================================
  Files         139      147       +8     
  Lines       21573    21960     +387     
==========================================
+ Hits        17917    18347     +430     
+ Misses       3656     3613      -43     

☔ View full report in Codecov by Harness.
📢 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.

@Davknapp Davknapp self-assigned this Oct 15, 2026

@Davknapp Davknapp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the macro __builtin_unreachable is compiler specific. For our julia- wrapper we have to run it on windows, too.
Can you double-check if this is applicable to windows, too?

Comment thread src/t8_schemes/t8_scheme.hxx Outdated

@Davknapp Davknapp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I added some suggestions to make it more robust and not to trip over something that is only mentioned in the documentation in the future.

All in all: Very nice addition, thak you .

Comment thread src/t8_schemes/t8_scheme.hxx Outdated
Comment thread src/t8_schemes/t8_scheme.hxx Outdated
Comment thread src/t8_schemes/t8_scheme.hxx
Comment thread src/t8_schemes/t8_scheme.hxx
Comment thread src/t8_schemes/t8_scheme.hxx
@Davknapp
Davknapp added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit df1b3bb Oct 21, 2026
41 checks passed
@Davknapp
Davknapp deleted the enhancement-speedup_t8code branch October 21, 2026 10:09
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.

Enhancement: Make t8code around 16% faster

2 participants