Skip to content

[geom] Added optional persistence for TGeoTessellated optimization#21707

Draft
agheata wants to merge 3 commits intoroot-project:masterfrom
agheata:tess_bvh_quad
Draft

[geom] Added optional persistence for TGeoTessellated optimization#21707
agheata wants to merge 3 commits intoroot-project:masterfrom
agheata:tess_bvh_quad

Conversation

@agheata
Copy link
Copy Markdown
Member

@agheata agheata commented Mar 26, 2026

Persistence capability of the bvh::v2::Bvh data structure is now enabled. It can be controlled by TGeoTessellated::fgStreamOptimization, which is set to false (not streaming) by default, because although there is a gain in speed (2-3x faster), it is still fast to create the optimization on the fly, even for complex cases (1M facets).

co-authored by @pcanal

This Pull request:

Changes or fixes:

Optionally enables persistence for the tessellated acceleration structure

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

Persistence capability of the bvh::v2::Bvh data structure is now enabled. It can be controlled by TGeoTessellated::fgStreamOptimization, which is set to false (not streaming) by default, because although there is a gain in speed, it is still fast to create the optimization on the fly even for complex cases (1M facets).
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Test Results

     4 files       4 suites   11h 31m 45s ⏱️
 3 767 tests  3 767 ✅ 0 💤 0 ❌
13 283 runs  13 283 ✅ 0 💤 0 ❌

Results for commit 970b15e.

♻️ This comment has been updated with latest results.

@pcanal pcanal added the clean build Ask CI to do non-incremental build on PR label Mar 27, 2026
@pcanal pcanal closed this Mar 27, 2026
@pcanal pcanal reopened this Mar 27, 2026
@dpiparo
Copy link
Copy Markdown
Member

dpiparo commented Mar 28, 2026

The changes seem to have triggered a problem in the creation of the precompiled modules. A proposal to move forward could be to

  1. isolate the behaviour in a reproducer, open an issue
  2. if possible, simplify the template used in this PR to converge towards its merging

Does it make sense?

@agheata
Copy link
Copy Markdown
Member Author

agheata commented Mar 30, 2026

The changes seem to have triggered a problem in the creation of the precompiled modules. A proposal to move forward could be to

  1. isolate the behaviour in a reproducer, open an issue
  2. if possible, simplify the template used in this PR to converge towards its merging

Does it make sense?

The simplification of the template is not an option, as this optimization package is meant to remain an opaque external implementation for BVH. @pcanal is looking into this. If it really does not work, I think we will drop the persistence because the creation of the data structure on the fly is quite fast, so persistence would only benefit setups with a very large number of complex tessellations.

@agheata agheata marked this pull request as draft March 30, 2026 07:40
@pcanal
Copy link
Copy Markdown
Member

pcanal commented Apr 1, 2026

@aaronj0 The PR fails during the generation of the modules.idx triggers the assert:

#9  0x00007f426d5135e4 in DefinitionFinder::Register (this=0x7ffdae8f8be8, ND=0x37d5998, AddSingleEntry=false) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1186
1186                      assert(FE->getName().contains("input_line_"));
(gdb) p FE
$6 = {Storage = {<clang::FileMgr::MapEntryOptionalStorage<clang::FileEntryRef>> = {MaybeRef = {ME = 0x2e18a80}}, <No data fields>}}
(gdb) l
1181    #ifndef NDEBUG
1182                      SourceManager &SM = ND->getASTContext().getSourceManager();
1183                      SourceLocation Loc = ND->getLocation();
1184                      OptionalFileEntryRef FE = SM.getFileEntryRefForID(SM.getFileID(Loc));
1185                      (void)FE;
1186                      assert(FE->getName().contains("input_line_"));
1187    #endif
1188                      return;
1189                   }
1190

The stack trace is below. The ND namespace is bvh which is a namespace that contains, intentionally, two forward declared class template (used for one specific instantiation for a persistent pointer).

Do you know how we can solve this issue?

cd /github/home/ROOT-CI/build/lib && ROOT_INCLUDE_PATH= ROOTIGNOREPREFIX=1 ROOT_HIST=0 /github/home/ROOT-CI/build/bin/root.exe -l -q -b
root.exe: /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1186: void loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder::Register(const clang::NamedDecl*, bool): Assertion `FE->getName().contains("input_line_")' failed.
make[2]: *** [CMakeFiles/modules_idx.dir/build.make:182: lib/modules.idx] Aborted (core dumped)
#9  0x00007f426d5135e4 in DefinitionFinder::Register (this=0x7ffdae8f8be8, ND=0x37d5998, AddSingleEntry=false) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1186
#10 0x00007f426d513489 in DefinitionFinder::VisitNamedDecl (this=0x7ffdae8f8be8, ND=0x37d5998) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1167
#11 0x00007f426d5b137c in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::WalkUpFromNamedDecl (this=0x7ffdae8f8be8, D=0x37d5998)
    at /github/home/ROOT-CI/build/interpreter/llvm-project/llvm/tools/clang/include/clang/AST/DeclNodes.inc:120
#12 0x00007f426d567dc6 in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::WalkUpFromNamespaceDecl (this=0x7ffdae8f8be8, D=0x37d5998)
    at /github/home/ROOT-CI/build/interpreter/llvm-project/llvm/tools/clang/include/clang/AST/DeclNodes.inc:176
#13 0x00007f426d53e128 in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::TraverseNamespaceDecl (this=0x7ffdae8f8be8, D=0x37d5998)
    at /github/home/ROOT-CI/src/interpreter/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1685
#14 0x00007f426d535ec8 in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::TraverseDecl (this=0x7ffdae8f8be8, D=0x37d5998)
    at /github/home/ROOT-CI/build/interpreter/llvm-project/llvm/tools/clang/include/clang/AST/DeclNodes.inc:176
#15 0x00007f426d55da26 in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::TraverseDeclContextHelper (this=0x7ffdae8f8be8, DC=0x1e16f40)
    at /github/home/ROOT-CI/src/interpreter/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1544
#16 0x00007f426d53b05b in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::TraverseTranslationUnitDecl (this=0x7ffdae8f8be8, D=0x1e16f18)
    at /github/home/ROOT-CI/src/interpreter/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h:1649
#17 0x00007f426d535a66 in clang::RecursiveASTVisitor<loadGlobalModuleIndex(cling::Interpreter&)::DefinitionFinder>::TraverseDecl (this=0x7ffdae8f8be8, D=0x1e16f18)
    at /github/home/ROOT-CI/build/interpreter/llvm-project/llvm/tools/clang/include/clang/AST/DeclNodes.inc:24
#18 0x00007f426d51338c in DefinitionFinder::DefinitionFinder (this=0x7ffdae8f8be8, IDs=..., TU=0x1e16f18) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1152
#19 0x00007f426d513965 in loadGlobalModuleIndex (interp=...) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1203
#20 0x00007f426d513e35 in RegisterCxxModules (clingInterp=...) at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1274
#21 0x00007f426d516494 in TCling::TCling (this=0x1d89f00, name=0x7f4276062f2b "C++", title=0x7f4276062f15 "cling C++ Interpreter", argv=0x7ffdae8f9be0, interpLibHandle=0x1d17ec0)
    at /github/home/ROOT-CI/src/core/metacling/src/TCling.cxx:1612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR improvement in:Geometry priority:low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants