Skip to content

fix: keep the object cache in the graphed TTree source - #1731

Merged
ariostas merged 1 commit into
scikit-hep:mainfrom
graphed-org:fix/graphed-source-object-cache
Sep 25, 2026
Merged

ariostas merged 1 commit into
scikit-hep:mainfrom
graphed-org:fix/graphed-source-object-cache

Conversation

@lgray

@lgray lgray commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Fixes #1730

_GraphedTTreeSource._open_directory no longer passes object_cache=None, so ReadOnlyFile's default (object_cache=100, as in uproot.open) applies. The file is already opened once per worker through resources.open_once; with its object cache, later partitions of that file reuse the TTree instead of deserializing it again. array_cache=None stays, so no arrays are held across partitions.

No caller setting is overridden: an explicit object_cache= passed to uproot.graphed is already rejected at construction by _util.regularize_object_path, which uproot.dask shares.

Timing

Events tree of Run2012B_SingleMu.root (CMS Open Data NanoAOD, 16 GB, 86 branches), first 2^21 entries as 4 explicit steps of 2^19; gak.sum(MET_pt) through graphed.aggregate_plan + SequentialRunner, median of 5 runs after one warm-up; Apple M1 Max, Python 3.13, graphed 0.0.5.

main (ca3a8a2) this PR
TTree reads for 4 partitions 4 1
open_tree per partition (ms) 20.9, 20.7, 19.9, 21.2 21.0, 0.0, 0.0, 0.0
sum of MET_pt, 4 partitions (s) 0.121 0.057

Test

tests/test_1730_graphed_tree_cache.py: two partitions of one file, opened through one LocalResources, get the same TTree object. It fails on main (assert second is first: two distinct TTree objects) and passes here.

@github-actions github-actions Bot added the type/fix PR title type: fix (set automatically) label Sep 24, 2026
@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.15%. Comparing base (ca3a8a2) to head (ededf64).

Additional details and impacted files
Files with missing lines Coverage Δ
src/uproot/_graphed.py 100.00% <ø> (ø)

@lgray

lgray commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@ariostas Here's another quick fix from doing higher level tests with the nanoevents integration built in scikit-hep/coffea#1637.

@ariostas ariostas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. The size of a tree object increases with the number of branches, but even with a "standard" NanoAOD with O(1000) branches it's only like 10MB, so it's probably fine.

Thank you, @lgray!

@ariostas
ariostas merged commit 32dadd9 into scikit-hep:main Sep 25, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/fix PR title type: fix (set automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

graphed TTree source re-deserializes the TTree on every partition (object_cache=None)

2 participants