Inefficient de-registering of objects when plotting and using TPad
Los mantenedores suelen responder en 1 día
@hageboeck ya está trabajando en esto.
Desde el 2/12/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Explain what you would like to see improved and how.
Hello,
I did some profiling of the code performance when producing a lot of plots ~ 100k or so (note this is not that unusual in a real analysis).
The relevant code looks like this:
TCanvas c("c","c",800,600);
TPad pad0("pad0","pad0",0,0.30,1,1,0,0,0);
std::unique_ptr<TH1> nominal(...);
nominal->SetDirectory(nullptr);
nominal->Draw()
The code works well but the profiling shows that a lot of time is spent in the deleting/de-registering the objects, see this screenshot from VTune (a simplifed version of the real run)
After a lot of help from @hageboeck, one needs to use the following code to improve the situation:
TObject *obj;
TIter next(pad0.GetListOfPrimitives());
while ((obj = next())) {
if (auto hist = dynamic_cast<TH1*>(obj)) {
hist->SetBit(kMustCleanup, false);
}
if (auto tl = dynamic_cast<TLatex*>(obj)) {
tl->SetBit(kMustCleanup, false);
}
if (auto tli = dynamic_cast<TLine*>(obj)) {
tli->SetBit(kMustCleanup, false);
}
}
As you can see, this is not the most obvious code and it does not even solve the problem completely as there is still bottlenck coming from TPave destructor from TLegend. Using the same technique as above causes segfault.
There is probably no easy solution to this, I just wanted to open this issue so that these inefficiencies are not forgotten for the future updates.
ROOT version
ROOT Version: 6.39.01
Built for linuxx8664gcc on Nov 26 2025, 08:33:23
From heads/master@v6-39-01-296-gfac9b1c307b
Installation method
built from source
Operating system
Ubuntu 25.10
Additional context
No response
- Lenguaje dominante
- C++
- Estrellas
- 3.3k
- Forks
- 1.6k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 194
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de root-project/root
-
thisroot.sh: wrong ROOTSYS in zsh when the shell's command line has a newlinePosiblemente ocupada @dpiparo la tomó hace 3 días. Abiertobug in:Build System
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
root-project/root#23746 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[tmva][sofie] Inputs of unsupported type (e.g. float16) give code that does not compile instead of an errorPosiblemente ocupada @lmoneta la tomó hace 12 días. AbiertoAI-Assisted bug in:SOFIE
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
root-project/root#23655 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 71/100
root-project/root#23790 ·
Los mantenedores suelen responder en 1 día
-
bug in:Core Libraries
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
root-project/root#23777 ·
Los mantenedores suelen responder en 1 día
-
`TChain::GetEntries` internal caching ineffective?Posiblemente ocupada @pcanal la tomó hace 5 días. Abiertoimprovement in:TTree
root-project/root#23738 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de root-project/root
Issues similares
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Niko1221/Strata#3673 · 2 comentarios ·
Los mantenedores suelen responder en 3 días
-
bug P4
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
open-astro/AlpacaBridge#1520 ·
Los mantenedores suelen responder en 1 día
-
[Docs] CONTRIBUTING still says FreeType 2.14.3 and TabLabel.h says ImGui 1.92.9b after the bumpsPosiblemente ocupada @mgradwohl la tomó hoy. Abiertoagent:WSL documentation LOW
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día