leptris 1.9.457.0 → 1.9.460.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/CONTEXT.md +9 -3
- data/README.adoc +28 -17
- data/Rakefile +1 -1
- data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
- data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
- data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/document.rb +75 -48
- data/lib/leptris/xml/ffi.rb +8 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +54 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/README.adoc +19 -0
- data/vendor-src/libleptris/benchmarks/CMakeLists.txt +23 -2
- data/vendor-src/libleptris/benchmarks/README.adoc +15 -0
- data/vendor-src/libleptris/benchmarks/README.md +17 -4
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_decomp.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_first_access.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_many_attrs.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_memory.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_parse.cpp +2 -2
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_parse_ops.cpp +8 -4
- data/vendor-src/libleptris/benchmarks/comprehensive/benchmark_write.cpp +4 -2
- data/vendor-src/libleptris/benchmarks/dom/dom_benchmark_v2.cpp +8 -4
- data/vendor-src/libleptris/benchmarks/fixtures/serialbench_users_medium.xml +13004 -0
- data/vendor-src/libleptris/benchmarks/matrix/bench_matrix.cpp +21 -76
- data/vendor-src/libleptris/benchmarks/matrix/bench_matrix_fused.cpp +31 -0
- data/vendor-src/libleptris/benchmarks/matrix/bench_rows.h +94 -0
- data/vendor-src/libleptris/benchmarks/modification/bench_append_attr_pugixml.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/parse/bench_parse_ab.cpp +2 -1
- data/vendor-src/libleptris/benchmarks/twins/generation_users.sh +49 -0
- data/vendor-src/libleptris/benchmarks/twins/generation_users_fixture.h +78 -0
- data/vendor-src/libleptris/benchmarks/twins/generation_users_leptris.c +122 -0
- data/vendor-src/libleptris/benchmarks/twins/generation_users_pugixml.cpp +231 -0
- data/vendor-src/libleptris/benchmarks/twins/parse_pugixml.cpp +1 -1
- data/vendor-src/libleptris/benchmarks/twins/parse_users_ab.cpp +158 -0
- data/vendor-src/libleptris/benchmarks/workflows/bench_pipeline_shapes.cpp +12 -4
- data/vendor-src/libleptris/benchmarks/xpath/bench_pugixml.cpp +2 -1
- data/vendor-src/libleptris/cli/CLI_ARCHITECTURE.md +9 -1
- data/vendor-src/libleptris/cli/commands/diff.c +26 -28
- data/vendor-src/libleptris/cli/commands/format.c +3 -1
- data/vendor-src/libleptris/cli/commands/parse.c +3 -1
- data/vendor-src/libleptris/cli/commands/validate.c +22 -24
- data/vendor-src/libleptris/cli/commands/xpath.c +9 -1
- data/vendor-src/libleptris/cli/commands/xquery.c +12 -3
- data/vendor-src/libleptris/cli/commands/xslt.c +24 -8
- data/vendor-src/libleptris/cli/error.c +91 -0
- data/vendor-src/libleptris/cli/error.h +84 -0
- data/vendor-src/libleptris/cli/man/leptris-parse.1.adoc +21 -10
- data/vendor-src/libleptris/cli/man/leptris.1.adoc +19 -0
- data/vendor-src/libleptris/cli/output.c +18 -9
- data/vendor-src/libleptris/cli/output.h +17 -0
- data/vendor-src/libleptris/src/CMakeLists.txt +3 -0
- data/vendor-src/libleptris/src/include/leptris/types.h +25 -1
- data/vendor-src/libleptris/src/include/leptris/xquery/xquery.h +9 -1
- data/vendor-src/libleptris/src/include/leptris.h +48 -3
- data/vendor-src/libleptris/src/leptris/common/entities.c +2 -2
- data/vendor-src/libleptris/src/leptris/common/entities.h +8 -2
- data/vendor-src/libleptris/src/leptris/common/port.h +62 -0
- data/vendor-src/libleptris/src/leptris/common/uri_base.c +284 -0
- data/vendor-src/libleptris/src/leptris/common/uri_base.h +62 -0
- data/vendor-src/libleptris/src/leptris/core.c +33 -2
- data/vendor-src/libleptris/src/leptris/dom/compact.h +51 -0
- data/vendor-src/libleptris/src/leptris/dom/element.c +18 -0
- data/vendor-src/libleptris/src/leptris/dom/element.h +201 -12
- data/vendor-src/libleptris/src/leptris/dom/element_modify.c +611 -210
- data/vendor-src/libleptris/src/leptris/dom/element_query.c +72 -1
- data/vendor-src/libleptris/src/leptris/dom/name_intern.c +3 -1
- data/vendor-src/libleptris/src/leptris/dtd/model.c +13 -0
- data/vendor-src/libleptris/src/leptris/dtd/model.h +95 -6
- data/vendor-src/libleptris/src/leptris/dtd/resolver.c +302 -215
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.c +801 -294
- data/vendor-src/libleptris/src/leptris/leptris.c +20 -5
- data/vendor-src/libleptris/src/leptris/leptris_internal.h +68 -22
- data/vendor-src/libleptris/src/leptris/serialize/serialize.c +289 -57
- data/vendor-src/libleptris/src/leptris/xinclude/xinclude.c +14 -125
- data/vendor-src/libleptris/src/leptris/xpath/evaluator.c +105 -41
- data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +11 -8
- data/vendor-src/libleptris/src/leptris/xpath/functions_ext31.c +188 -24
- data/vendor-src/libleptris/src/leptris/xpath/vm.c +3 -1
- data/vendor-src/libleptris/src/leptris/xquery/xquery.c +5 -0
- data/vendor-src/libleptris/src/leptris/xsd/compile.c +272 -41
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +338 -196
- data/vendor-src/libleptris/src/leptris/xsd/xsd_internal.h +27 -0
- data/vendor-src/libleptris/test/CMakeLists.txt +53 -0
- data/vendor-src/libleptris/test/abi/test_public_surface.cpp +37 -0
- data/vendor-src/libleptris/test/cli/test_cli.cpp +228 -0
- data/vendor-src/libleptris/test/common/hang_guard.h +179 -0
- data/vendor-src/libleptris/test/dom/test_compact.cpp +46 -0
- data/vendor-src/libleptris/test/dom/test_mut_append_contracts.cpp +173 -0
- data/vendor-src/libleptris/test/dom/test_mut_set_attr_contracts.cpp +771 -7
- data/vendor-src/libleptris/test/fixtures/entity_limits/good.xml +100 -0
- data/vendor-src/libleptris/test/fixtures/entity_limits/good_attr.xml +100 -0
- data/vendor-src/libleptris/test/fixtures/entity_limits/lol_classic.xml +51 -0
- data/vendor-src/libleptris/test/fixtures/entity_limits/lol_ig_attr.xml +23 -0
- data/vendor-src/libleptris/test/fixtures/entity_limits/lol_ig_content.xml +23 -0
- data/vendor-src/libleptris/test/fixtures/entity_limits/lol_long_name.xml +23 -0
- data/vendor-src/libleptris/test/memory/test_oom_injection.cpp +63 -0
- data/vendor-src/libleptris/test/memory/test_synth_graveyard.cpp +207 -0
- data/vendor-src/libleptris/test/parser/test_entity_limits.cpp +404 -0
- data/vendor-src/libleptris/test/parser/test_parser.cpp +126 -0
- data/vendor-src/libleptris/test/serializer/test_serialize.cpp +491 -0
- data/vendor-src/libleptris/test/xpath/test_base_uri.cpp +368 -0
- data/vendor-src/libleptris/test/xpath/test_xpath.cpp +86 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs97_w3c/addB034.xml +1 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs97_w3c/addB034.xsd +13 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs97_w3c/addB136.xml +4 -0
- data/vendor-src/libleptris/test/xsd/libxml2-cases/rs97_w3c/addB136.xsd +15 -0
- data/vendor-src/libleptris/test/xsd/test_rs97_regression.cpp +132 -0
- data/vendor-src/libleptris/test/xsd/test_xsd11_base_uri.cpp +145 -0
- data/vendor-src/libleptris/test/xsd/test_xsd11_conformance.cpp +23 -5
- data/vendor-src/libleptris/test/xsd/test_xsd11_cta_context.cpp +385 -0
- data/vendor-src/libleptris/test/xsd/test_xsd11_cta_set.cpp +201 -0
- data/vendor-src/libleptris/test/xsd/test_xsd11_opencontent_set.cpp +245 -0
- data/vendor-src/libleptris/test/xsd/xsd-dispositions/README.md +8 -3
- data/vendor-src/libleptris/test/xsd/xsd11-all/all-restrict.xsd +3 -2
- data/vendor-src/libleptris/test/xsd/xsd11-all/all-wildcard.xsd +3 -2
- data/vendor-src/libleptris/test/xsd/xsd11-cases/MANIFEST.tsv +19 -2
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0003.n01.xml +5 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0003.v01.xml +4 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0003.xsd +46 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0006.v01.xml +6 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0006.xsd +83 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0017.v01.xml +3 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0017.xsd +36 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0021.n01.xml +3 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0021.v01.xml +3 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0021.xsd +36 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0023.v01.xml +3 -0
- data/vendor-src/libleptris/test/xsd/xsd11-cases/saxonData/CTA/cta0024.xsd +40 -0
- data/vendor-src/libleptris/test/xsd/xsd11-dispositions/README.md +67 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +43 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c78f0b34fb47fd6c2c2ff07f35f57d1520a4cb1a6a1100829e5d32a76b860547
|
|
4
|
+
data.tar.gz: d7c06d83210824baf3e3e244cc36485edb6cd6acadb3be43b020c2af6b8ca593
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ea2bc04d0edb9fce2593fb92876f6c9c8eba565b9b68b4ba22ce228590591e39baa9c0a9542bccb6d58a180ae88b9d545f21a340e48683acee123ecbbf7cb48
|
|
7
|
+
data.tar.gz: 6a2c86b99192dee06bc3755b58509353d23a75a9108d044249de8464f2d5e8b5f799022c110746884e1eaf78e921df0965df5898b9e97032667a29786bea6fcd
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
### Fixed
|
|
4
4
|
|
|
5
|
+
- **`Document.parse` rides the strict native fast path for every
|
|
6
|
+
caller; `recover: true` (the Nokogiri-parity default) is the
|
|
7
|
+
fallback (leptris-ruby#697).** The recover lane was the whole
|
|
8
|
+
default path — the fast path was gated on `options.nil? && !recover`,
|
|
9
|
+
never true for default callers — so every default parse paid the
|
|
10
|
+
error-tolerant lane (the issue's probe: 4.4 ms vs 2.9 ms for
|
|
11
|
+
`recover: false` on serialbench medium.xml). Now the strict parse
|
|
12
|
+
runs first and only failed input is re-run through the recover
|
|
13
|
+
lane (the previous default, byte for byte); the default lane
|
|
14
|
+
measures within noise of `recover: false` (process CPU time on
|
|
15
|
+
darwin arm64: 0.98–0.99x on medium.xml, 1.01x on a 354 B document
|
|
16
|
+
where the recover lane's per-call setup had cost 1.29–1.30x).
|
|
17
|
+
Well-formed input builds the identical DOM
|
|
18
|
+
under both lanes — pinned over a shape battery in
|
|
19
|
+
`spec/xml/recover_fast_path_spec.rb` and probed over 827 corpus
|
|
20
|
+
inputs (0 divergences) — and malformed input recovers exactly as
|
|
21
|
+
before (13 recovered-tree pins, including the unrecoverable
|
|
22
|
+
empty-document cases). The `options:` lane takes the same
|
|
23
|
+
fast-first shape (flags first, the recover struct on failure). Side
|
|
24
|
+
effect: a UTF-16 document passed as a String now parses on the
|
|
25
|
+
default lane (the recover lane's FFI string marshalling rejected it
|
|
26
|
+
with ArgumentError; `recover: false` always parsed it).
|
|
5
27
|
- RelaxNG: a `combine="interleave"` define can add an element between
|
|
6
28
|
the members of a base sequence again (regression in 1.9.428.0, fixed
|
|
7
29
|
by engine 1.9.429; leptris/leptris#2094). Regression spec with the
|
data/CONTEXT.md
CHANGED
|
@@ -34,6 +34,12 @@ is one PR (version.rb + Rakefile pin + CHANGELOG) then the release
|
|
|
34
34
|
workflow; ffi.rb mirrors the public header so the attached-vs-
|
|
35
35
|
exported audit (`nm -gU`) catches drift.
|
|
36
36
|
|
|
37
|
-
**The recover mode** —
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
**The recover mode** — malformed input is recovered by DEFAULT
|
|
38
|
+
(Nokogiri parity, ruby#465/#478): a best-effort tree — or an empty
|
|
39
|
+
document when nothing can be salvaged — with the recovery diagnostics
|
|
40
|
+
on `doc.errors` and the failure on the thread-global last error (+
|
|
41
|
+
position), instead of raising ParseError; `recover: false` /
|
|
42
|
+
`strict: true` raise. Recover is a FALLBACK, not the lane (ruby#697):
|
|
43
|
+
every parse rides the strict native fast path first and only failed
|
|
44
|
+
input is re-run through the recover lane, so the default costs
|
|
45
|
+
nothing on well-formed input.
|
data/README.adoc
CHANGED
|
@@ -134,25 +134,31 @@ doc = Leptris::XML.parse_file("books.xml")
|
|
|
134
134
|
This is the direct Nokogiri equivalent of `Nokogiri::XML(...)`. The
|
|
135
135
|
returned object is a `Leptris::XML::Document`.
|
|
136
136
|
|
|
137
|
-
Malformed input
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
Malformed input is RECOVERED by default — Nokogiri parity
|
|
138
|
+
(leptris-ruby#465/#478): `Leptris::XML.parse("<a><b></a>")` never
|
|
139
|
+
raises, hands back libxml2's `XML_PARSE_RECOVER` shape (a best-effort
|
|
140
|
+
tree, or an empty document for input with nothing to salvage), and
|
|
141
|
+
exposes the recovery diagnostics on `doc.errors`:
|
|
141
142
|
|
|
142
143
|
[source,ruby]
|
|
143
144
|
----
|
|
144
|
-
doc = Leptris::XML.parse("<a><b></a>"
|
|
145
|
+
doc = Leptris::XML.parse("<a><b></a>")
|
|
145
146
|
doc.root.name # => "a"
|
|
146
|
-
doc.errors.first.message # => "
|
|
147
|
+
doc.errors.first.message # => "Element b closed implicitly by </a>"
|
|
147
148
|
----
|
|
148
149
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
Pass `recover: false` (or `strict: true`) for the raise-on-malformed
|
|
151
|
+
behavior: `Leptris::XML::ParseError` carries the engine's failure
|
|
152
|
+
detail, and `Document#last_error_position` the `[line, column]`.
|
|
153
|
+
|
|
154
|
+
**Recover is a fallback, not the lane (leptris-ruby#697).** Every parse
|
|
155
|
+
rides the strict native fast path first; only when that parse fails
|
|
156
|
+
does a `recover: true` parse re-run the input through the
|
|
157
|
+
error-tolerant lane. Well-formed input builds the identical DOM under
|
|
158
|
+
both lanes (pinned by `spec/xml/recover_fast_path_spec.rb`), so the
|
|
159
|
+
default pays nothing for its tolerance — `recover: false` buys no
|
|
160
|
+
speed on well-formed input, and the double parse lands only on
|
|
161
|
+
malformed input.
|
|
156
162
|
|
|
157
163
|
== HTML parsing
|
|
158
164
|
|
|
@@ -900,10 +906,15 @@ Notable differences:
|
|
|
900
906
|
* Expanded-name attribute access: `Element#attribute_ns(uri, local)` /
|
|
901
907
|
`#has_attribute_ns?(uri, local)` — XML Namespaces 1.0 semantics
|
|
902
908
|
(cross-prefix match, nil URI matches no-namespace, xmlns invisible).
|
|
903
|
-
* `Leptris::XML.parse(xml
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
909
|
+
* `Leptris::XML.parse(xml)` recovers malformed input by default
|
|
910
|
+
(Nokogiri parity): a best-effort tree with the recovery diagnostics
|
|
911
|
+
on `doc.errors`, or an empty document when nothing can be salvaged
|
|
912
|
+
— libxml2 `XML_PARSE_RECOVER` semantics, never a raise. The strict
|
|
913
|
+
fast path runs first and recover is the fallback
|
|
914
|
+
(leptris-ruby#697), so the default costs nothing on well-formed
|
|
915
|
+
input; `recover: false` / `strict: true` raise `ParseError` instead.
|
|
916
|
+
The companion `Document#last_error_position` returns `[line, column]`
|
|
917
|
+
of the most recent failure on the thread.
|
|
907
918
|
* `Leptris::XML.parse(xml, readonly: true)` (or `Document#readonly!`)
|
|
908
919
|
freezes the document for reading: mutations raise ReadOnlyError, read
|
|
909
920
|
methods memoize aggressively. Faster steady state; no Nokogiri
|
data/Rakefile
CHANGED
|
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
8
8
|
# Pin for `rake compile` and the platform-gem builds. Keep in lockstep
|
|
9
9
|
# with .github/workflows/build.yml (which calls `rake compile`) and the
|
|
10
10
|
# CHANGELOG when libleptris releases.
|
|
11
|
-
LIBLEPTRIS_VERSION = "1.9.
|
|
11
|
+
LIBLEPTRIS_VERSION = "1.9.460"
|
|
12
12
|
|
|
13
13
|
# THE SSOT for the per-minor native bundle list (ruby#645): one line,
|
|
14
14
|
# space-separated, consumed by the Rakefile, the per-minor builder's
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/document.rb
CHANGED
|
@@ -144,6 +144,16 @@ class Leptris::XML::Document
|
|
|
144
144
|
# default — a best-effort tree plus doc.errors, never a raise.
|
|
145
145
|
# Pass `strict: true` (or rescue ParseError) for the historical
|
|
146
146
|
# raise-on-malformed behavior.
|
|
147
|
+
#
|
|
148
|
+
# ruby#697: recover is the FALLBACK, not the lane. Every parse rides
|
|
149
|
+
# the strict native fast path FIRST; only when that parse fails does
|
|
150
|
+
# a recover: true parse re-run the input through the error-tolerant
|
|
151
|
+
# lane (the pre-#697 default). Well-formed input — the overwhelmingly
|
|
152
|
+
# common case — builds the identical DOM under both lanes
|
|
153
|
+
# (spec/xml/recover_fast_path_spec.rb pins the equivalence), so the
|
|
154
|
+
# semantics are unchanged and the fast path is reachable by default
|
|
155
|
+
# again (~1.5x on serialbench medium). The double parse lands only
|
|
156
|
+
# on malformed input, which is already an error path.
|
|
147
157
|
def self.parse(xml_or_io, options: nil, readonly: false,
|
|
148
158
|
recover: true, strict: false)
|
|
149
159
|
recover = false if strict
|
|
@@ -151,67 +161,84 @@ class Leptris::XML::Document
|
|
|
151
161
|
if xml.empty?
|
|
152
162
|
raise Leptris::XML::ParseError, "empty input"
|
|
153
163
|
end
|
|
154
|
-
# The default path (no options
|
|
155
|
-
#
|
|
156
|
-
#
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
raise Leptris::XML::ParseError,
|
|
167
|
-
"leptris_parse_string failed: " +
|
|
168
|
-
Leptris::XML::FFI.leptris_last_error.to_s if doc.nil?
|
|
169
|
-
return doc.tap { |d| d.readonly! if readonly }
|
|
164
|
+
# The default path (no options) allocates nothing: ParseOptions.new
|
|
165
|
+
# here would only discover flags==0 (#187 — per-call overhead is
|
|
166
|
+
# most of a small-document parse). A given options object is
|
|
167
|
+
# normalized exactly as before: recover: true merges into it, and
|
|
168
|
+
# its own recover? flag stays authoritative (recover: false passed
|
|
169
|
+
# alongside a recovering options object still recovers).
|
|
170
|
+
if options.nil?
|
|
171
|
+
flags = 0
|
|
172
|
+
recovering = recover
|
|
173
|
+
else
|
|
174
|
+
unless options.is_a?(Leptris::XML::ParseOptions)
|
|
175
|
+
raise ArgumentError, "options must be a Leptris::XML::ParseOptions"
|
|
170
176
|
end
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
options = options | Leptris::XML::ParseOptions.new(recover: true) if
|
|
178
|
+
recover && !options.recover?
|
|
179
|
+
flags = options.flags
|
|
180
|
+
recovering = options.recover?
|
|
181
|
+
end
|
|
182
|
+
doc = parse_strict(xml, flags)
|
|
183
|
+
if doc.nil?
|
|
184
|
+
unless recovering
|
|
173
185
|
raise Leptris::XML::ParseError,
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
"leptris_parse_string failed: " +
|
|
187
|
+
Leptris::XML::FFI.leptris_last_error.to_s
|
|
176
188
|
end
|
|
177
|
-
|
|
189
|
+
doc = parse_recovering(xml, options)
|
|
178
190
|
end
|
|
179
|
-
if
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
doc.tap { |d| d.readonly! if readonly }
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# The strict lane: leptris_parse_string (flags == 0) or
|
|
195
|
+
# leptris_parse_string_flags, through the native face when the
|
|
196
|
+
# compiled layer is loaded. Returns the wrapped document, or nil when
|
|
197
|
+
# the parse fails (the failure detail is in the thread-local
|
|
198
|
+
# leptris_last_error). Never raises.
|
|
199
|
+
def self.parse_strict(xml, flags)
|
|
200
|
+
if defined?(Leptris::XML::NATIVE_FAST) && flags.zero?
|
|
201
|
+
# TODO.perf/35: parse + wrapper + lifetime handle in one C
|
|
202
|
+
# dispatch.
|
|
203
|
+
return Leptris::XML::Native.parse_binding_document(xml)
|
|
185
204
|
end
|
|
186
|
-
# The status out-param is nullable; the thread-local last error
|
|
187
|
-
# carries failure detail, and skipping the per-parse MemoryPointer
|
|
188
|
-
# is measurable on small documents.
|
|
189
205
|
raw =
|
|
190
|
-
if
|
|
191
|
-
# Recover is a struct field, not a parse flag — the options
|
|
192
|
-
# struct path (leptris_parse_string_ex) is the only carrier.
|
|
193
|
-
options_struct = options.to_c_struct
|
|
194
|
-
Leptris::XML::FFI.leptris_parse_string_ex(
|
|
195
|
-
xml, xml.bytesize, options_struct.pointer, nil)
|
|
196
|
-
elsif options.flags.zero?
|
|
206
|
+
if flags.zero?
|
|
197
207
|
Leptris::XML::FFI.leptris_parse_string(xml, xml.bytesize, nil)
|
|
198
208
|
else
|
|
199
209
|
Leptris::XML::FFI.leptris_parse_string_flags(
|
|
200
|
-
xml, xml.bytesize,
|
|
210
|
+
xml, xml.bytesize, flags, nil)
|
|
201
211
|
end
|
|
212
|
+
raw.null? ? nil : wrap(raw)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# The recover lane (ruby#697 fallback; ruby#465 semantics): the
|
|
216
|
+
# options-struct entry is the only carrier — recover is a struct
|
|
217
|
+
# field, not a parse flag. +options+ carries the caller's flags (nil
|
|
218
|
+
# = the default lane). Always rides FFI: the struct's strict_mode /
|
|
219
|
+
# max_depth are -1 / 0 (keep the thread defaults) where the native
|
|
220
|
+
# face's recover branch pins strict_mode, and this path runs only
|
|
221
|
+
# after a parse already failed — there is no hot path to protect.
|
|
222
|
+
# The engine answers an empty document rather than NULL under
|
|
223
|
+
# recover; a NULL here means that contract changed — fail loudly.
|
|
224
|
+
def self.parse_recovering(xml, options)
|
|
225
|
+
options ||= Leptris::XML::ParseOptions.new(recover: true)
|
|
226
|
+
options = options | Leptris::XML::ParseOptions.new(recover: true) unless
|
|
227
|
+
options.recover?
|
|
228
|
+
# The status out-param is nullable; the thread-local last error
|
|
229
|
+
# carries failure detail, and skipping the per-parse MemoryPointer
|
|
230
|
+
# is measurable on small documents.
|
|
231
|
+
raw = Leptris::XML::FFI.leptris_parse_string_ex(
|
|
232
|
+
xml, xml.bytesize, options.to_c_struct.pointer, nil)
|
|
202
233
|
if raw.null?
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"leptris_parse_string_ex returned NULL under recover"
|
|
208
|
-
end
|
|
209
|
-
raise Leptris::XML::ParseError,
|
|
210
|
-
"leptris_parse_string failed: " +
|
|
211
|
-
Leptris::XML::FFI.leptris_last_error.to_s
|
|
234
|
+
# Unreachable in practice: recover returns an empty document
|
|
235
|
+
# rather than NULL; kept so a contract change fails loudly.
|
|
236
|
+
raise Leptris::XML::Error,
|
|
237
|
+
"leptris_parse_string_ex returned NULL under recover"
|
|
212
238
|
end
|
|
213
|
-
wrap(raw)
|
|
239
|
+
wrap(raw)
|
|
214
240
|
end
|
|
241
|
+
private_class_method :parse_strict, :parse_recovering
|
|
215
242
|
|
|
216
243
|
def self.parse_file(path, readonly: false)
|
|
217
244
|
raw = Leptris::XML::FFI.leptris_parse_file(path, nil)
|
data/lib/leptris/xml/ffi.rb
CHANGED
|
@@ -674,6 +674,14 @@ attach_function :leptris_parse_string,
|
|
|
674
674
|
[:leptris_document, :string], :leptris_status
|
|
675
675
|
attach_function :leptris_document_set_standalone,
|
|
676
676
|
[:leptris_document, :int], :leptris_status
|
|
677
|
+
# 1.9.459 (#2278): the document URI — parse_file records the
|
|
678
|
+
# resolved path; an in-memory parse carries NONE until set.
|
|
679
|
+
# The document-uri property fn:document-uri() answers and what
|
|
680
|
+
# the root fn:base-uri() resolves xml:base against.
|
|
681
|
+
attach_function :leptris_document_uri,
|
|
682
|
+
[:leptris_document], UTF8_STRING
|
|
683
|
+
attach_function :leptris_document_set_uri,
|
|
684
|
+
[:leptris_document, :string], :leptris_status
|
|
677
685
|
attach_function :leptris_document_set_doctype,
|
|
678
686
|
[:leptris_document, :string, :string, :string], :leptris_doctype
|
|
679
687
|
attach_function :leptris_document_append_pi,
|
data/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.460] - 2026-12-04
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Big-endian regression in 1.9.459's word store (leptris-ruby#699's ride gate).** The S9 short-string window (#2274) packed strings into a word logically but stored them with a raw `memcpy` — string order only on little-endian. On s390x a mutation-created attribute's value read back empty and serialization truncated at the attribute (`<r><book `); parse-built attributes were unaffected. The word↔string boundary now converts byte order at every store and load (`leptris_word8_store/_load`, `LEPTRIS_BSWAP64` in `common/port.h`); little-endian codegen is unchanged (zero `bswap` instructions in the object dump). Two red-first specs: the dialect pair driven on the test host (the assertion a BE host fails without the fix) and the public mutation→serialize round trip over the reported shape.
|
|
8
|
+
- **The s390x CI leg never ran big-endian.** `docker run` in the test workflow lacked `--platform`, so the x86_64 runner executed amd64 and the "big-endian" gate tested little-endian code — which is how the regression above reached a release. The leg now runs `--platform linux/s390x` on `ubuntu:24.04` (debian:bookworm publishes no s390x manifest), LTO off under QEMU. This release's leg is genuine: binfmt installs `qemu-s390x`, 2861/2861 under emulation, both new specs green there.
|
|
9
|
+
|
|
10
|
+
Nothing else changed: every 1.9.459 fix and performance row stands (XSD 1.1 = 2211/2211, XSD 1.0 = 1046/1056). 1.9.459 reached no runtime registry — the ruby and PyPI rides' emulated legs blocked it — so this is the first 459-wave release on the registries.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [1.9.459] - 2026-12-04
|
|
14
|
+
|
|
15
|
+
The correctness-and-every-row release: nine PRs in one wave — the beat-pugixml scoreboard flips, the schema/XPath conformance lane gains four fixes, and the billion-laughs denial-of-service class is closed.
|
|
16
|
+
|
|
17
|
+
### Performance — every-row campaign (#2255, #2279)
|
|
18
|
+
|
|
19
|
+
- **The comparison law** (#2276): every pugixml benchmark parse now runs `parse_ws_pcdata` so both engines build the same tree. An unflagged comparison let pugixml drop whitespace-only nodes — a ~2x node handicap on indented documents, a tree-shape difference reported as parser cost. Written into `benchmarks/README.{md,adoc}` as the same-tree law.
|
|
20
|
+
- **Text serialization: 1.65x behind → ~1.9x AHEAD** (#2274). The escape pre-scan was 81% of the row (a 2MB scalar byte loop before any SIMD ran); long spans now decide ctrl-vs-plain with one vector pass and bulk-copy.
|
|
21
|
+
- **Attr-heavy parse: flipped** (#2286): 1.43-1.22x behind → **0.93-0.98x** (the fast loop owns its add-inline; register-resident per-element state). Whitespace parse −6% on top of the earlier −32%. Also fixed a real hang the users fixture exposed: an unguarded stop-class store through a NULL out-param on the PI/DOCTYPE path hit every document with an `<?xml …?>` declaration.
|
|
22
|
+
- **set-attribute 2k: 1.10x behind → parity (0.99-1.005x)** (#2287). The attribute index went element-local — a pool-carved per-document directory of packed per-element tables, probe and insert in one cache line; small-N stays on the chain. 10 new contract specs caught a real bug mid-development; the ASAN and ILP32 gates caught two more before merge.
|
|
23
|
+
- **Records parse 1.60x → 1.29-1.35x** (#2280): the element-open floor (lazy element-name hash, stale-guard close-tag strip, typed wiring, branchless colon probe). **Append 10k: parity** (#2273, plus contract pins and a harness codegen fix). **Users generation 1.89x → 1.50x** (#2288: close-tag fusion, one-pass short-text emitter; the parse half improved 2.27x → 1.55x via the waves above — tracked in #2279).
|
|
24
|
+
- XSD validation stays **2.1x ahead of libxml2-xsd**; the text-heavy parse and XPath rows keep their wins.
|
|
25
|
+
|
|
26
|
+
### Correctness — schema & XPath
|
|
27
|
+
|
|
28
|
+
- **CTA test-context isolation + fn:root** (#2277): the XSD 1.1 §3.12.4 data model is materialized for every test-carrying chain (the detached, parentless, childless copy of E) and `fn:root` is registered — `empty(..)`, `(. is root())`, `empty(following::*)` hold by construction. cta0017 flips; saxon CTA 100→101/113.
|
|
29
|
+
- **Document base/document URIs** (#2278): `leptris_parse_file` records the resolved path; `base-uri()` resolves the xml:base chain, `document-uri()` returns it, `static-base-uri()` is the static context's base (the schema's URI inside XSD tests). cta0021 (valid/invalid by URI) and cta0024 adopt — **XSD 1.1 floor 2206 → 2211/2211** (CTA 130/130); XSD 1.0 held 1046/1056.
|
|
30
|
+
- **Close tags must match the open QName** (#2282): `<a>t1</p:a>` is no longer accepted; strict reports the mismatch, recover matches libxml2 (stray-drop). Two XSD fixtures that were never well-formed were repaired; the measured ~2.5-4% cost on unprefixed names is documented (a faster variant measured no better and was dropped).
|
|
31
|
+
- **XML namespace undeclaration survives detach** (#2294/#2295): `set_namespace(elem, "")` on a detached element now carries `xmlns=""` through attach (a persistent flag bit, 15 red-first pins) — a blank child can no longer silently join the parent's default namespace. The issue's literal repro proved consumer-side (lutaml-model's plan serializer); routed.
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
|
|
35
|
+
- **Billion-laughs closed** (#2281): a single bounded walk with libxml2-aligned limits (nesting depth 20/40, 10 MB per node, amplification ≤ max(1 MB, 5×input)) — the three fixtures that hung forever now fail fast with a named error in ~1 s; the classic document that was silently mangled now errors instead. Opt-in `LEPTRIS_PARSE_ALLOW_HUGE_EXPANSION`; hang-proof specs (fork + alarm) so the suite can never hang.
|
|
36
|
+
|
|
37
|
+
### CLI & bindings
|
|
38
|
+
|
|
39
|
+
- **CLI surfaces the engine diagnostic** (#2291): every command prints `file:line:col: error: <message>` (JSON: a structured error object) from `leptris_last_error()` instead of a generic line.
|
|
40
|
+
- **Ruby: the default parse takes the fast path** (#697): strict-first with recover fallback — well-formed input (the common case) parses on the native fast lane with an identical DOM (827-input, zero-divergence evidence; 13 recovered-tree pins); malformed input under `recover: true` recovers exactly as before. Ships as gem 1.9.459.0.
|
|
41
|
+
|
|
42
|
+
Floors: **XSD 1.1 = 2211/2211 (100%)**, XSD 1.0 = 1046/1056, XPath 438/438, libxslt 205/205, full suite 2858 green. The bindings ride in lockstep (gem 1.9.459.0, PyPI 1.9.459.0, npm 0.1.96).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [1.9.458] - 2026-12-01
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **The serialbench CI-leg deaths — root cause found, and it predates the whole suspect window** (#2265, PR #2269). A Linux-container differential (serialbench-shaped driver, verbatim fixtures and schedule) between v1.9.448 and v1.9.456 showed byte-identical growth — +938,912 KB arena-live on the xslt30-medium leg on BOTH — proving the defect shipped long before 449. The culprit is 1.9.428's dispose-parking change (8a19a0ba): every disposed owned synthetic node (attribute/namespace/text) parked on an **uncapped thread-local graveyard** drained only at thread exit, replacing the real free. The serialbench xml leg's xslt30 op carries `$labels` through `xsl:iterate` + `xsl:next-iteration`, so the engine rebuilds the accumulated sequence per item — O(n²) disposals, **~190 MB parked per apply**, TLS-rooted (LSan and leaks(1) both blind to it), and Linux glibc retains the freed pages until the runner OOMs ~6 minutes into the leg. This is why 1.9.385 passes 46/46, why every 44x+ wave died, why the #2246 fix changed nothing, and why the darwin probes looked clean. Fix: the graveyard is a **bounded ring** (`SYNTH_PARK_CAP 4096`, ~500 KB/thread) — newest disposals keep the 428 alias shield unchanged; the entry that falls off the ring pays the pre-428 real free, sound under the same commit's ownership-flag law. Post-fix: +372 KB on the same leg, zero delta on all later legs, full-size run completes at 48 MB RSS where it previously died inside one apply; ASAN clean. The permanent gate (`test/memory/test_synth_graveyard.cpp`) was proven RED on both anchors at ~370× the 512 KB/op bound and GREEN post-fix on Linux and darwin. The issue's three named candidates (attr fast path, packed TLS memo, XSD caches) are exonerated in the PR with evidence.
|
|
50
|
+
|
|
51
|
+
- **Attribute-prohibition false-rejects on 1.9.457** (leptris-rs#97, PR #2268). The issue's bisect attribution pointed at #2262, but the real culprit is **#2185 (v1.9.449)**: its present-rejection in `validate_attributes` made a `use="prohibited"` attribute declaration govern instance attributes — yet XSD 1.0 §3.2.2 says a local prohibited declaration "corresponds to nothing at all" (§3.4.2 Note: no interaction with wildcards). The suite pins both consequences: attruse_0_2 (prohibited, no wildcard) stays INVALID — the attribute is undeclared — while addB034.v/addB136.v (prohibited beside `anyAttribute ##local lax`) are VALID — the wildcard admits. Prohibited rows are now inert everywhere: skipped in the declared-row walk, never declaring for the strict walk (`attr_row_admits`), and a restriction's prohibited spelling still EXCLUDES the base's same-name use from the derived {attribute uses} (§3.4.2 cl. 3.2 — cta0044.n01 stays invalid; the #1923 chain walk must not resurrect it). Extensions keep every folded base use (derivation-ok-extension_0's twin stays valid). Full-corpus sweep: all 8 schemas carrying prohibited+wildcard validate per pinned verdict. rs#92's elemT058/elemT071 regressions remain green and untouched.
|
|
52
|
+
|
|
53
|
+
- **CTA union-selector alternatives and openContent suffix through the schema-set face** (#2266 + #2267, PR #2270; consumer issues lutaml/moxml#622/#625). Both families failed for the same reason: `leptris_xsd_compile_set` — moxml's multi-schema entry — never ran the per-document machinery the file face always ran. The version + 1.1-evidence preamble never armed, so an inline alternative type's `xs:assert` silently vanished through `xsd_set` (ibm test3_2 accepted B=11 against `B mod 2 = 0`) and the openContent capture gate (`version_11 || saw_open_content`) never fired — sets compiled with NO suffix wildcard, the exact filed verdict "children do not match the content model (at 'extra')" on valid open001.v1. The set face now reads the version dials from the first member (entry-root contract), OR-re-arms the 1.1-evidence flags per member (include-chase posture), registers each member as its own unit (the chase's first push collided with unit 0, fusing per-unit defaultAttributes scoping — open044/045), and runs `xsd_oc_finalize` (open027/047 derivation) and `xsd_apply_default_attrs` (open201/202/205/035/044) in the single-doc order. The Linux ASAN CI gate caught the late defaultAttributes pass walking member DOM that `xsd_set` callers free after their compile step — fixed at the root by capturing the per-unit targetNamespace and group wildcards while each document is alive (stash on the def, `elem_live` gate; no document-retention contract change). Set-face sweeps verdict-identical with the file face: cta 69/69, openContent 130/130, assertions 164/164. +18 specs, red-first.
|
|
54
|
+
|
|
55
|
+
Floors byte-exact on every change: **XSD 1.1 = 2206/2206 (100%)** — assertions 296/296, cta 125/125, override 87/87, openContent 205/205, core 1493/1493; **XSD 1.0 = 1046/1056** (10 pinned reds intact). Full suite 2756 green (3 pre-existing skips). The bindings ride in lockstep (gem 1.9.458.0, PyPI 1.9.458.0, npm 0.1.95).
|
|
56
|
+
|
|
3
57
|
## [1.9.457] - 2026-11-30
|
|
4
58
|
|
|
5
59
|
### Fixed
|
|
@@ -769,6 +769,25 @@ references (numeric character references stay text, per XML 1.0
|
|
|
769
769
|
value. Probe `LEPTRIS_CAP_ENTITY_REF_NODES` before relying on the
|
|
770
770
|
mode.
|
|
771
771
|
|
|
772
|
+
Entity-expansion limits (the "billion laughs" guard, `#2281`): custom
|
|
773
|
+
entities from the internal subset expand under libxml2's
|
|
774
|
+
non-`XML_PARSE_HUGE` defaults, measured per parse — nesting depth 20,
|
|
775
|
+
one expanded text node or attribute value at most 10,000,000 bytes,
|
|
776
|
+
and output plus 20 bytes per reference at most
|
|
777
|
+
`max(1,000,000, 5 × input bytes)`. A document that breaches any of them
|
|
778
|
+
FAILS (`LEPTRIS_ERROR_PARSE`, `leptris_last_error` naming the limit)
|
|
779
|
+
instead of expanding without bound; there is no partial tree, not even
|
|
780
|
+
with `LEPTRIS_PARSE_RECOVER`. The five predefined entities never
|
|
781
|
+
count. `LEPTRIS_PARSE_ALLOW_HUGE_EXPANSION` opts a trusted document out
|
|
782
|
+
of the size limits (the depth cap rises to 40):
|
|
783
|
+
|
|
784
|
+
[source,c]
|
|
785
|
+
----
|
|
786
|
+
LeptrisStatus st;
|
|
787
|
+
LeptrisDocument doc = leptris_parse_string_flags(
|
|
788
|
+
xml, len, LEPTRIS_PARSE_ALLOW_HUGE_EXPANSION, &st);
|
|
789
|
+
----
|
|
790
|
+
|
|
772
791
|
The bits: `LEPTRIS_CAP_PARSE`, `LEPTRIS_CAP_DOM`, `LEPTRIS_CAP_XPATH`,
|
|
773
792
|
`LEPTRIS_CAP_XQUERY`, `LEPTRIS_CAP_DTD`, `LEPTRIS_CAP_SAX`,
|
|
774
793
|
`LEPTRIS_CAP_HTML`, `LEPTRIS_CAP_XINCLUDE`, `LEPTRIS_CAP_DIFF`,
|
|
@@ -111,8 +111,13 @@ leptris_add_benchmark(bench_doc_lifecycle dom/bench_document_lifecycle.c utils.
|
|
|
111
111
|
endif()
|
|
112
112
|
|
|
113
113
|
# Full-feature matrix: leptris vs pugixml vs libxml2 (YAML + HTML report).
|
|
114
|
+
# The fused append row compiles in its own TU (bench_matrix_fused.cpp):
|
|
115
|
+
# the mutation rows are tight ~120 µs loops whose measured time swings
|
|
116
|
+
# double-digit percent with the TU's link-layout dice — one TU per row
|
|
117
|
+
# family keeps a new row's codegen from re-rolling the others'.
|
|
114
118
|
if(PUGIXML_AVAILABLE AND LIBXML2_AVAILABLE)
|
|
115
|
-
leptris_add_benchmark(bench_matrix CXX matrix/bench_matrix.cpp
|
|
119
|
+
leptris_add_benchmark(bench_matrix CXX matrix/bench_matrix.cpp
|
|
120
|
+
matrix/bench_matrix_fused.cpp)
|
|
116
121
|
target_compile_definitions(bench_matrix PRIVATE
|
|
117
122
|
HAVE_PUGIXML=1 HAVE_LIBXML2=1
|
|
118
123
|
LEPTRIS_BENCH_VERSION="${PROJECT_VERSION}")
|
|
@@ -125,7 +130,8 @@ if(PUGIXML_AVAILABLE AND LIBXML2_AVAILABLE)
|
|
|
125
130
|
target_include_directories(bench_matrix PRIVATE ${LIBXML2_INCLUDE_DIR})
|
|
126
131
|
target_link_libraries(bench_matrix PRIVATE ${LIBXML2_LIBRARY})
|
|
127
132
|
elseif(PUGIXML_AVAILABLE)
|
|
128
|
-
leptris_add_benchmark(bench_matrix CXX matrix/bench_matrix.cpp
|
|
133
|
+
leptris_add_benchmark(bench_matrix CXX matrix/bench_matrix.cpp
|
|
134
|
+
matrix/bench_matrix_fused.cpp)
|
|
129
135
|
target_compile_definitions(bench_matrix PRIVATE HAVE_PUGIXML=1
|
|
130
136
|
LEPTRIS_BENCH_VERSION="${PROJECT_VERSION}")
|
|
131
137
|
if(PUGIXML_TARGET)
|
|
@@ -274,6 +280,21 @@ if(PUGIXML_AVAILABLE)
|
|
|
274
280
|
target_include_directories(bench_parse_ab PRIVATE ${PUGIXML_INCLUDE_DIR})
|
|
275
281
|
target_link_libraries(bench_parse_ab PRIVATE ${PUGIXML_LIBRARY})
|
|
276
282
|
endif()
|
|
283
|
+
|
|
284
|
+
# The serialbench `users` PARSE op (leptris#2279): the canonical
|
|
285
|
+
# element-heavy + whitespace-node fixture, paired same-process A/B at
|
|
286
|
+
# ws_pcdata parity. The fixture path is baked in so the binary runs
|
|
287
|
+
# from any cwd; argv[1] overrides it.
|
|
288
|
+
leptris_add_benchmark(bench_parse_users_ab CXX twins/parse_users_ab.cpp)
|
|
289
|
+
target_compile_definitions(bench_parse_users_ab PRIVATE
|
|
290
|
+
HAVE_PUGIXML=1
|
|
291
|
+
LEPTRIS_USERS_FIXTURE="${CMAKE_SOURCE_DIR}/benchmarks/fixtures/serialbench_users_medium.xml")
|
|
292
|
+
if(PUGIXML_TARGET)
|
|
293
|
+
target_link_libraries(bench_parse_users_ab PRIVATE ${PUGIXML_TARGET})
|
|
294
|
+
else()
|
|
295
|
+
target_include_directories(bench_parse_users_ab PRIVATE ${PUGIXML_INCLUDE_DIR})
|
|
296
|
+
target_link_libraries(bench_parse_users_ab PRIVATE ${PUGIXML_LIBRARY})
|
|
297
|
+
endif()
|
|
277
298
|
endif()
|
|
278
299
|
|
|
279
300
|
# ----------------------------------------------------------------------------
|
|
@@ -12,6 +12,21 @@ The Leptris benchmark suite compares performance against libxml2 and pugixml acr
|
|
|
12
12
|
* Serialization
|
|
13
13
|
* XPath queries (all 13 axes)
|
|
14
14
|
|
|
15
|
+
== The Comparison Law (same tree shape)
|
|
16
|
+
|
|
17
|
+
When benchmarking against pugixml, ALWAYS parse with
|
|
18
|
+
`pugi::parse_default | pugi::parse_ws_pcdata`. pugixml's default
|
|
19
|
+
DISCARDS whitespace-only text nodes, so an unflagged comparison lets
|
|
20
|
+
pugixml skip building the nodes leptris must build — the row then
|
|
21
|
+
measures a tree-shape handicap, not parser efficiency (on indented
|
|
22
|
+
documents that is a ~2x node-count handicap, which is not a real
|
|
23
|
+
gap). Every pugixml parse in this directory carries the flag; the
|
|
24
|
+
only exceptions are rows whose OUTPUT LABEL says so (e.g. `DROP_WS`
|
|
25
|
+
diagnostics, which exist to show the delta explicitly, never as a
|
|
26
|
+
scoreboard claim). The same principle applies to any competitor
|
|
27
|
+
option that changes the DOM content: configure the competitor to
|
|
28
|
+
build the SAME tree, then compare speed.
|
|
29
|
+
|
|
15
30
|
== Building Benchmarks
|
|
16
31
|
|
|
17
32
|
[source,bash]
|
|
@@ -65,10 +65,23 @@ cd build/benchmarks
|
|
|
65
65
|
## Benchmark Design Principles
|
|
66
66
|
|
|
67
67
|
1. **Fair Comparison**: Same XML, same operations, same iterations
|
|
68
|
-
2. **
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
2. **Same Tree Shape (THE COMPARISON LAW)**: when benchmarking against
|
|
69
|
+
pugixml, ALWAYS parse with `pugi::parse_default |
|
|
70
|
+
pugi::parse_ws_pcdata`. pugixml's default DISCARDS whitespace-only
|
|
71
|
+
text nodes, so an unflagged comparison lets pugixml skip building
|
|
72
|
+
the nodes leptris must build — the row then measures a tree-shape
|
|
73
|
+
handicap, not parser efficiency (on indented documents that is a
|
|
74
|
+
~2x node-count handicap, which is not a real gap). Every pugixml
|
|
75
|
+
parse in this directory carries the flag; the only exceptions are
|
|
76
|
+
rows whose OUTPUT LABEL says so (e.g. `DROP_WS` diagnostics, which
|
|
77
|
+
exist to show the delta explicitly, never as a scoreboard claim).
|
|
78
|
+
The same principle applies to any competitor option that changes
|
|
79
|
+
the DOM content: configure the competitor to build the SAME tree,
|
|
80
|
+
then compare speed.
|
|
81
|
+
3. **Realistic Workloads**: Representative of actual usage patterns
|
|
82
|
+
4. **Statistical Rigor**: Multiple runs, calculate mean/stddev/min/max
|
|
83
|
+
5. **Apples-to-Apples**: Measure equivalent operations only
|
|
84
|
+
6. **MECE Structure**: Each benchmark has single, clear purpose
|
|
72
85
|
|
|
73
86
|
## DOM Benchmarks
|
|
74
87
|
|
|
@@ -29,7 +29,8 @@ static void bench(const char* label, const char* xml, size_t n, int iters=30) {
|
|
|
29
29
|
}
|
|
30
30
|
double pt=1e18;
|
|
31
31
|
for(int r=0;r<iters;r++){
|
|
32
|
-
double t0=now_us(); pugi::xml_document pd;
|
|
32
|
+
double t0=now_us(); pugi::xml_document pd;
|
|
33
|
+
pd.load_buffer(xml,n,pugi::parse_default|pugi::parse_ws_pcdata);
|
|
33
34
|
double dt=now_us()-t0; if(dt<pt)pt=dt;
|
|
34
35
|
}
|
|
35
36
|
printf("%-28s %6zuKB leptris=%8.1fus pugi=%8.1fus ratio=%.2fx (leptris %.2f GB/s)\n",
|
|
@@ -148,7 +148,8 @@ static Stats benchmark_pugixml_first_access(int iterations) {
|
|
|
148
148
|
for (int i = 0; i < iterations; i++) {
|
|
149
149
|
// Parse (in-place modification, strings ready)
|
|
150
150
|
pugi::xml_document doc;
|
|
151
|
-
doc.load_buffer(test_xml, len
|
|
151
|
+
doc.load_buffer(test_xml, len,
|
|
152
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
152
153
|
pugi::xml_node root = doc.child("root");
|
|
153
154
|
|
|
154
155
|
// MEASURE: First access operations
|
|
@@ -98,7 +98,8 @@ Stats bench_pugixml(const std::string& xml, int iterations) {
|
|
|
98
98
|
for (int i = 0; i < iterations; i++) {
|
|
99
99
|
auto t0 = std::chrono::high_resolution_clock::now();
|
|
100
100
|
pugi::xml_document doc;
|
|
101
|
-
doc.load_buffer(xml.data(), xml.size()
|
|
101
|
+
doc.load_buffer(xml.data(), xml.size(),
|
|
102
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
102
103
|
auto t1 = std::chrono::high_resolution_clock::now();
|
|
103
104
|
double us = std::chrono::duration<double, std::micro>(t1 - t0).count();
|
|
104
105
|
samples.push_back(us);
|
|
@@ -115,7 +115,8 @@ static void measure_pugixml_memory() {
|
|
|
115
115
|
size_t baseline = get_current_memory();
|
|
116
116
|
|
|
117
117
|
pugi::xml_document doc;
|
|
118
|
-
doc.load_buffer(test_xml, strlen(test_xml)
|
|
118
|
+
doc.load_buffer(test_xml, strlen(test_xml),
|
|
119
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
119
120
|
size_t post_parse = get_current_memory();
|
|
120
121
|
|
|
121
122
|
pugi::xml_node root = doc.child("root");
|
|
@@ -171,14 +171,14 @@ static Stats benchmark_pugixml_parse(const char* xml, size_t len, int iterations
|
|
|
171
171
|
// Warmup
|
|
172
172
|
for (int i = 0; i < 3; i++) {
|
|
173
173
|
pugi::xml_document doc;
|
|
174
|
-
doc.load_buffer(xml, len);
|
|
174
|
+
doc.load_buffer(xml, len, pugi::parse_default | pugi::parse_ws_pcdata);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
// Measure
|
|
178
178
|
for (int i = 0; i < iterations; i++) {
|
|
179
179
|
uint64_t start = Timer::now_ns();
|
|
180
180
|
pugi::xml_document doc;
|
|
181
|
-
doc.load_buffer(xml, len);
|
|
181
|
+
doc.load_buffer(xml, len, pugi::parse_default | pugi::parse_ws_pcdata);
|
|
182
182
|
uint64_t end = Timer::now_ns();
|
|
183
183
|
|
|
184
184
|
times_ns.push_back(end - start);
|