Skip to content

[ntuple] Add ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS - #23110

Merged
jblomer merged 3 commits into
root-project:masterfrom
albfsg:metrics_expansion
Sep 1, 2026
Merged

jblomer merged 3 commits into
root-project:masterfrom
albfsg:metrics_expansion

Conversation

@albfsg

@albfsg albfsg commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

This Pull request:

Changes or fixes:

  • Changes ROOT_EXPORT_RNTUPLE_METRICS into ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS
  • Fixes a bug in the implementation of GetMetricsExportPath
  • Adds a new RNTupleMetrics API in which setting ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS to a .root file automatically enables the metrics and saves them in the .root file.

Checklist:

  • tested changes locally <- ntuple_metrics unit tests and roottest-root-ntuple-metrics integration tests
  • updated the docs (if necessary) <- header of RNTupleMetrics

This PR fixes #

None

albfsg added 2 commits August 19, 2026 13:04
The export path was memoized in a local static variable, so it was
fixed by the first call and ignored later changes.

I triggered this bug when needed to set ROOT_EXPORT_RNTUPLE_METRICS via
gSystem->Setenv().
@albfsg
albfsg force-pushed the metrics_expansion branch from b6c0db4 to da685c9 Compare August 19, 2026 12:10
@albfsg albfsg changed the title Metrics expansion [ntuple] Add functionality to R__EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS Aug 19, 2026
@albfsg albfsg changed the title [ntuple] Add functionality to R__EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS [ntuple] Add R__EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS Aug 19, 2026
@albfsg albfsg changed the title [ntuple] Add R__EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS [ntuple] Add ROOT_EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS Aug 19, 2026
@albfsg albfsg changed the title [ntuple] Add ROOT_EXPERIMENTAL_ROOT_EXPORT_RNTUPLE_METRICS [ntuple] Add ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS Aug 19, 2026
@albfsg
albfsg force-pushed the metrics_expansion branch from da685c9 to 5a22dd7 Compare August 19, 2026 12:50
@albfsg
albfsg force-pushed the metrics_expansion branch from 5a22dd7 to 60c58eb Compare August 24, 2026 12:17
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 2h 58m 59s ⏱️
 3 859 tests  3 858 ✅ 0 💤 1 ❌
72 314 runs  72 313 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 455e753.

♻️ This comment has been updated with latest results.

@jblomer jblomer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work!

The commit message of the last commit should reflect the change of the environment variable.

Comment thread tree/ntuple/src/RNTupleMetrics.cxx Resolved
Comment thread tree/ntuple/src/RNTupleMetrics.cxx Resolved
Comment thread tree/ntuple/src/RNTupleMetrics.cxx Resolved
Comment thread tree/ntuple/src/RNTupleMetrics.cxx Resolved
Comment thread tree/ntuple/src/RNTupleMetrics.cxx Resolved
Comment thread tree/ntuple/test/ntuple_metrics.cxx Resolved
Comment thread tree/ntuple/test/ntuple_metrics.cxx Resolved
Comment thread tree/ntuple/test/ntuple_metrics.cxx Resolved
Comment thread tree/ntuple/test/ntuple_metrics.cxx Resolved
Comment thread tree/ntuple/test/ntuple_metrics.cxx Resolved
@albfsg

albfsg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the comments @jblomer.

@albfsg
albfsg force-pushed the metrics_expansion branch from 60c58eb to 84b6430 Compare August 25, 2026 13:04
Implement the desired behaviour of
`ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS`. Previously it just enabled
all metrics automatically, ignoring the value passed to the variable.

As of this commit, the new environment variable to allow the user to
state its intention to activate metrics and where to store them in a
usable way which doesn't require source code modifications.

If the environment variable `ROOT_EXPERIMENTAL_EXPORT_RNTUPLE_METRICS`
is set,
metrics are automatically:

- Enabled on construction, and any counter added afterwards through
MakeCounter() is enabled as well.
- Stored in the `.root` file path (relative or absolute) set by
`ROOT_EXPORT_RNTUPLE_METRICS` on destruction

The generated .root file will contain one RNTuple for each component
with its metrics enabled. Each RNTuple will have a flat schema
consisting of fully qualified counter names, such as
RPageSinkFile_timeCpuZip. There is one entry per counter, which means if
a counter appears more than once in a given RNTuple, all instances will
be merged.

Comes with a unit test.

Modifies the output of the integration test
roottest-root-ntuple-metrics-metrics_env_enabled, as the implementation
of the automatic metrics storage uses the RNTupleMerger under the hood,
which triggers a warning message.
@albfsg
albfsg force-pushed the metrics_expansion branch from 84b6430 to 455e753 Compare August 27, 2026 10:19
@jblomer
jblomer merged commit 3de9c79 into root-project:master Sep 1, 2026
30 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants