Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Inefficient de-registering of objects when plotting and using TPad

Đang mở
#20,604 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@hageboeck đang làm issue này rồi.

Từ ngày 2/12/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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

Ngôn ngữ chính
C++
Star
3.3k
Fork
1.6k
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
188

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của root-project/root

Tất cả issue của root-project/root

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.