root icon indicating copy to clipboard operation
root copied to clipboard

TTreeProcessorMP processes events multiple times when there are more threads than entries

Open iguinn opened this issue 1 year ago • 0 comments

Check duplicate issues.

  • [X] Checked for duplicates

Description

TTreeProcessorMP process events multiple times when you read multiple files using TChain, and some of the files have fewer entries than there are threads. This has been observed using TChain and TSelector, but I haven't tried it out with any other methods of using TTreeProcessorMP.

The attached reproducer minimally shows this bug by showing that the Process method is run more than it should be. Another observations that are not shown in the reproducer is that the additional events are repeats of existing events. In the code where I first observed this, we frequently have files where one thread is processing multiple events (5-10ish), and most of them are real events, with the last few being repeats. It also seems like it always tries to process at least 15 events for each file if you use 16 threads, even if those events don't exist; if there are more than 15 events than it seems to behave as expected.

Reproducer

mp_bug.zip Run:

mkdir files
root FillRootFiles.C
root TestMP.C+

This will create 100 root files with 1 entry each called files/f_0###.root. It will then use TTreeProcessorMP with 16 threads to read through the files and count the number of events read. This should be 100; instead it is 1500.

ROOT version

v6.28/06 and 6.26/10

Installation method

Built from source

Operating system

Ubuntu 22.04

Additional context

No response

iguinn avatar May 06 '24 22:05 iguinn