Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of std::strcmp at TGeo slows down DD4hep geometry construction #8

Open
SanghyunKo opened this issue Oct 7, 2020 · 3 comments
Open

Comments

@SanghyunKo
Copy link
Collaborator

When placing volumes within DD4hep, dd4hep::volume::placeVolume (eventually TGeo of ROOT) uses std::strcmp to navigate around volumes. (dd4hep::Volume::placeVolumeTGeoVolume::_addNodeTGeoVolume::GetNodeTObjArray::FindObjectstd::strcmp)

Usually, this does not cause any problem when the number of daughter volume is small. However, if the number of daughter volume exceeds around O(10000), it significantly slows down to O(h) of whole geometry contruction of DD4hep application.

There would be some way to improve this kind of behaviour since it does not happen in the standalone GEANT4.

@SanghyunKo
Copy link
Collaborator Author

SanghyunKo commented Oct 7, 2020

To be clear, the use of std::strcmp itself is not a problem. However, it seems that somehow the complexity of the computation is not linear to the number of daughter volumes. I'll dig in and update the issue afterwards.

Edit: it turns out that the usage of std::strcmp is the main reason for slow down of DD4hep application (See slide 14-16 for the details [link]). For navigating geometry, DD4hep or TGeo uses std::strcmp while GEANT4 uses __gnu_cxx::__normal_iterator. Computing complexity of both methods are linear to (# of daughter volumes)^2. Still, there are almost O(100) differences between the cost of std::strcmp & __gnu_cxx::__normal_iterator.

@Chao1009
Copy link

We've encountered the same issue with implementing a detailed scintillating fiber detector (with over 100k fibers as daughter volumes). Any progress on this issue?

@SanghyunKo
Copy link
Collaborator Author

Hi @Chao1009, unfortunately not as far as I know. I made a presentation to DD4hep developers meeting last year, but it seems there is no easy solution since this is ROOT related problem.

FYI, a possible makeshift from the user's side for this problem (suggested at the meeting) is creating 'intermediate' volumes so that each volume does not contain a large number of daughter volumes.

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

No branches or pull requests

2 participants