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

Abierto
#477 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@astruebi ya está trabajando en esto.

Desde el 5/6/2026.

  • #478 de @astruebi — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
r
Área
performance

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
R
Estrellas
227
Forks
86
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de r-lib/xml2

Todos los issues de r-lib/xml2

Issues similares

Más issues de R

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.