Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Inefficient de-registering of objects when plotting and using TPad

Abierto
#20,604 1 comentario 0 reacciones 1 asignado Ver en GitHub

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

improvement in:Core Libraries
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)

Image

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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de root-project/root

Todos los issues de root-project/root

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.