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

Đang mở
#477 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@astruebi đang làm issue này rồi.

Từ ngày 5/6/2026.

  • #478 của @astruebi — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
r
Lĩnh vực
performance

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
R
Star
227
Fork
86
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-lib/xml2

Tất cả issue của r-lib/xml2

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.