-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Run3 PromptReco] Many memory allocations CaloSubdetectorGeometry::cellGeomPtr()
#46433
Comments
assign Geometry/CaloGeometry |
New categories assigned: geometry @bsunanda,@civanch,@Dr15Jones,@kpedro88,@makortel,@mdhildreth you have been requested to review this Pull request/Issue and eventually sign? Thanks |
cms-bot internal usage |
A new Issue was created by @makortel. @Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks. cms-bot commands are listed here |
type performance-improvements |
I see the interface was changed in #21808 from returning a raw pointer to returning a |
I fail to understand the difference between std::shared_ptr(ptr, do_not_delete); and a raw pointer |
#include <memory>
#include <iostream>
int const* get1() {
static const int val = 1;
return &val;
}
std::shared_ptr<int const> get2() {
static const int val = 1;
static const auto do_not_delete = [](const void*) {};
return std::shared_ptr<int const>(&val, do_not_delete);
}
std::shared_ptr<int const> get3() {
static const int val = 1;
return std::make_shared<int>(val);
}
int main() {
int sum = 0;
constexpr int N = 1000;
for (int i=0; i<N; ++i) {
auto ptr = get2();
sum += *ptr;
}
std::cout << sum << std::endl;
return 0;
} compiled with
|
I think this API is problematic in any case. If Then if |
#46507 has a proposal for reducing the number of memory allocations |
Just to note the memory cost of the "truly owning |
Continuing from #46040 (comment). The
CaloSubdetectorGeometry::cellGeomPtr()
leads to 1.44 million allocations per event on average in Run 3 Prompt Reco. From GitHub search I found my earlier analysis in #42672 (comment), where the main question was if the functioncmssw/Geometry/CaloGeometry/src/CaloSubdetectorGeometry.cc
Lines 260 to 265 in fe85c4c
could be changed to return
const CaloCellGeometry*
directly instead of ashared_ptr
?The text was updated successfully, but these errors were encountered: