Skip to content

perf: add #[inline] to Reader::read_event_impl chain (fixes #678) - #1012

Open
dhimasardinata wants to merge 1 commit into
tafia:masterfrom
dhimasardinata:perf/inline-chain-678
Open

perf: add #[inline] to Reader::read_event_impl chain (fixes #678)#1012
dhimasardinata wants to merge 1 commit into
tafia:masterfrom
dhimasardinata:perf/inline-chain-678

Conversation

@dhimasardinata

Copy link
Copy Markdown

Fixes #678

Non-cascaded #[inline] breaks cross-crate inlining. read_event_into (src/reader/mod.rs:411) has #[inline] but calls read_event_impl (src/reader/mod.rs:1006) and read_until_close (src/reader/mod.rs:1013) without it.

Bench on 1.3GB XML (from #678, Xeon, 10 runs):

  • master 5.94s
  • +#[inline] 5.23s (-12%)
  • +#[inline(always)] 4.23s (-28%)
    Even with lto=true: 4.62s -> 4.14s (-10%)

This PR adds #[inline] (not always) to keep binary size conservative, matching maintainer preference.

Verif:

  • cargo test --lib pass (hot 8s)
  • cargo bench --bench microbenches -- "read_event" --sample-size 10 shows improvement on sample_rss.xml:194K

Related: #405, #718

Non-cascaded #[inline] breaks cross-crate inlining.
read_event_into has #[inline] but calls read_event_impl/read_until_close without it.
Bench on 1.3GB XML (issue tafia#678):
 master 5.94s -> inline 5.23s (-12%) -> always 4.23s (-28%)
Even with lto=true still wins 4.62s -> 4.14s.

Verif: cargo test --lib + cargo bench --bench microbenches read_event
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.16%. Comparing base (e00ae5c) to head (99ff24b).
⚠️ Report is 74 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1012      +/-   ##
==========================================
- Coverage   57.31%   55.16%   -2.15%     
==========================================
  Files          46       51       +5     
  Lines       18197    18791     +594     
==========================================
- Hits        10429    10366      -63     
- Misses       7768     8425     +657     
Flag Coverage Δ
unittests 55.16% <ø> (-2.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Mingun Mingun added enhancement optimization Issues related to reducing time needed to parse XML or to memory consumption labels Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement optimization Issues related to reducing time needed to parse XML or to memory consumption

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-Cascaded #[inline] Propagation

3 participants