Optimize xml_path() and xml_find_all() for large node sets

Aperta
#477 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@astruebi ci sta già lavorando.

Dal 5/6/2026.

  • #478 di @astruebi — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
r
Ambito
performance

Direzione di ricerca

Start with the xml_path() and xml_find_all.xml_node() entry points, then review the regression tests described in the issue. Confirm that batch xml_path() output matches per-node output and that single-context XPath node sets remain unique. Benchmark large node sets and attribute result sets to verify the optimization preserves semantics and improves materialization time.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

xml_path() and xml_find_all() can spend substantial time in wrapper-side work when operating on large node sets.

I have a local branch with two general optimizations, both intended to preserve existing semantics:

  1. Speed up xml_path() for large xml_nodesets by caching reusable ancestor paths within a single call.
  2. Speed up xml_find_all.xml_node() materialization by avoiding an unnecessary duplicate pass for single-context XPath node sets and reducing per-node R object construction overhead.

Is this a direction you would be open to reviewing as a PR?

Isolated benchmark results from my local machine:

  • xml_path() on a synthetic node set with 124,001 nodes:

    • before: ~0.77s
    • after: ~0.07s
  • xml_path() on a large real-world XML bundle with 415,022 selected nodes:

    • before: ~2.43s
    • after: ~0.28s
  • xml_find_all() / XPath result materialization on large attribute result sets:

    • synthetic 300k attributes: roughly 1.5-2x faster in the materialization-heavy path
    • real-world XML bundle, //@*, 155,009 attributes: roughly 1.6-2x faster in isolated runs

The changes are not specific to any particular XML schema or downstream package. They target repeated ancestor path construction and large XPath result materialization.

I added regression tests comparing batch xml_path() output to per-node xml_path() output, and checking that single-context xml_find_all() XPath node sets remain unique.

Lingua principale
R
Stelle
227
Fork
86
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di r-lib/xml2

Tutte le issue di r-lib/xml2

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.