leptris 1.9.424.0 → 1.9.425.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/leptris/vendor/aarch64-linux/libleptris.so +0 -0
  4. data/lib/leptris/vendor/aarch64-linux-musl/libleptris.so +0 -0
  5. data/lib/leptris/vendor/arm-linux/libleptris.so +0 -0
  6. data/lib/leptris/vendor/arm-linux-musl/libleptris.so +0 -0
  7. data/lib/leptris/vendor/arm64-darwin/libleptris.dylib +0 -0
  8. data/lib/leptris/vendor/ppc64le-linux/libleptris.so +0 -0
  9. data/lib/leptris/vendor/s390x-linux-musl/libleptris.so +0 -0
  10. data/lib/leptris/vendor/x86_64-darwin/libleptris.dylib +0 -0
  11. data/lib/leptris/vendor/x86_64-linux/libleptris.so +0 -0
  12. data/lib/leptris/vendor/x86_64-linux-musl/libleptris.so +0 -0
  13. data/lib/leptris/version.rb +1 -1
  14. data/vendor-src/README.md +1 -1
  15. data/vendor-src/libleptris/CHANGELOG.md +28 -0
  16. data/vendor-src/libleptris/CMakeLists.txt +1 -1
  17. data/vendor-src/libleptris/TODO.SOTA.md +40 -5
  18. data/vendor-src/libleptris/benchmarks/CMakeLists.txt +25 -0
  19. data/vendor-src/libleptris/benchmarks/dom/bench_zerocopy_text.c +118 -0
  20. data/vendor-src/libleptris/benchmarks/fixtures/generate_pipeline.rb +120 -0
  21. data/vendor-src/libleptris/benchmarks/fixtures/pipeline_config.xml +103 -0
  22. data/vendor-src/libleptris/benchmarks/fixtures/pipeline_feed.xml +166 -0
  23. data/vendor-src/libleptris/benchmarks/fixtures/pipeline_metanorma.xml +268 -0
  24. data/vendor-src/libleptris/benchmarks/fixtures/pipeline_records.xml +284 -0
  25. data/vendor-src/libleptris/benchmarks/workflows/bench_pipeline_shapes.cpp +693 -0
  26. data/vendor-src/libleptris/docs/MISSION-PLAN.md +5 -0
  27. data/vendor-src/libleptris/src/leptris/html/html_parse.c +10 -1
  28. data/vendor-src/libleptris/src/leptris/xpath/evaluator_path.c +8 -2
  29. data/vendor-src/libleptris/src/leptris/xpath/functions.c +15 -3
  30. data/vendor-src/libleptris/src/leptris/xslt/xslt_parse.c +36 -16
  31. data/vendor-src/libleptris/test/CMakeLists.txt +1 -1
  32. data/vendor-src/libleptris/test/differential/README.md +7 -7
  33. data/vendor-src/libleptris/test/differential/corpus/01-namespaces.xml +8 -0
  34. data/vendor-src/libleptris/test/differential/corpus/02-entities-predef.xml +1 -0
  35. data/vendor-src/libleptris/test/differential/corpus/03-entities-numeric.xml +1 -0
  36. data/vendor-src/libleptris/test/differential/corpus/04-cdata.xml +1 -0
  37. data/vendor-src/libleptris/test/differential/corpus/05-comments-pi.xml +3 -0
  38. data/vendor-src/libleptris/test/differential/corpus/06-doctype-internal.xml +6 -0
  39. data/vendor-src/libleptris/test/differential/corpus/07-unicode.xml +2 -0
  40. data/vendor-src/libleptris/test/differential/corpus/08-deep-nesting.xml +1 -0
  41. data/vendor-src/libleptris/test/differential/corpus/09-mixed-content.xml +1 -0
  42. data/vendor-src/libleptris/test/differential/corpus/10-big-attrs.xml +1 -0
  43. data/vendor-src/libleptris/test/differential/corpus/11-whitespace.xml +6 -0
  44. data/vendor-src/libleptris/test/differential/corpus/12-dup-xmlns.xml +1 -0
  45. data/vendor-src/libleptris/test/differential/corpus/13-custom-dtd-entity.xml +2 -0
  46. data/vendor-src/libleptris/test/differential/corpus/14-processing-instr-xml-decl.xml +2 -0
  47. data/vendor-src/libleptris/test/differential/corpus/15-empty-and-selfclose.xml +1 -0
  48. data/vendor-src/libleptris/test/differential/corpus/16-attrs-special-chars.xml +1 -0
  49. data/vendor-src/libleptris/test/differential/corpus/17-rss-like.xml +2 -0
  50. data/vendor-src/libleptris/test/differential/corpus/18-soap-like.xml +5 -0
  51. data/vendor-src/libleptris/test/differential/corpus/19-xinclude.xml +1 -0
  52. data/vendor-src/libleptris/test/differential/corpus/20-single-root.xml +1 -0
  53. data/vendor-src/libleptris/test/differential/corpus/21-text-only-elems.xml +1 -0
  54. data/vendor-src/libleptris/test/differential/corpus/22-long-text.xml +1 -0
  55. data/vendor-src/libleptris/test/differential/package.json +1 -1
  56. data/vendor-src/libleptris/test/differential/rs-runner/Cargo.lock +217 -0
  57. data/vendor-src/libleptris/test/differential/rs-runner/Cargo.toml +18 -0
  58. data/vendor-src/libleptris/test/differential/rs-runner/run.rs +94 -0
  59. data/vendor-src/libleptris/test/differential/run.mjs +44 -0
  60. data/vendor-src/libleptris/test/differential/run.py +44 -0
  61. data/vendor-src/libleptris/test/differential/run.rb +44 -0
  62. data/vendor-src/libleptris/test/fixtures/differential/01-namespaces.xml +8 -0
  63. data/vendor-src/libleptris/test/fixtures/differential/02-entities-predef.xml +1 -0
  64. data/vendor-src/libleptris/test/fixtures/differential/03-entities-numeric.xml +1 -0
  65. data/vendor-src/libleptris/test/fixtures/differential/04-cdata.xml +1 -0
  66. data/vendor-src/libleptris/test/fixtures/differential/05-comments-pi.xml +3 -0
  67. data/vendor-src/libleptris/test/fixtures/differential/06-doctype-internal.xml +6 -0
  68. data/vendor-src/libleptris/test/fixtures/differential/07-unicode.xml +2 -0
  69. data/vendor-src/libleptris/test/fixtures/differential/08-deep-nesting.xml +1 -0
  70. data/vendor-src/libleptris/test/fixtures/differential/09-mixed-content.xml +1 -0
  71. data/vendor-src/libleptris/test/fixtures/differential/10-big-attrs.xml +1 -0
  72. data/vendor-src/libleptris/test/fixtures/differential/11-whitespace.xml +6 -0
  73. data/vendor-src/libleptris/test/fixtures/differential/12-dup-xmlns.xml +1 -0
  74. data/vendor-src/libleptris/test/fixtures/differential/13-custom-dtd-entity.xml +2 -0
  75. data/vendor-src/libleptris/test/fixtures/differential/14-processing-instr-xml-decl.xml +2 -0
  76. data/vendor-src/libleptris/test/fixtures/differential/15-empty-and-selfclose.xml +1 -0
  77. data/vendor-src/libleptris/test/fixtures/differential/16-attrs-special-chars.xml +1 -0
  78. data/vendor-src/libleptris/test/fixtures/differential/17-rss-like.xml +2 -0
  79. data/vendor-src/libleptris/test/fixtures/differential/18-soap-like.xml +5 -0
  80. data/vendor-src/libleptris/test/fixtures/differential/19-xinclude.xml +1 -0
  81. data/vendor-src/libleptris/test/fixtures/differential/20-single-root.xml +1 -0
  82. data/vendor-src/libleptris/test/fixtures/differential/21-text-only-elems.xml +1 -0
  83. data/vendor-src/libleptris/test/fixtures/differential/22-long-text.xml +1 -0
  84. data/vendor-src/libleptris/test/fuzz/corpus/html_foreign_cdata_short_opener.bin +0 -0
  85. data/vendor-src/libleptris/test/fuzz/corpus/seed1 +1 -0
  86. data/vendor-src/libleptris/test/fuzz/corpus/seed2 +1 -0
  87. data/vendor-src/libleptris/test/fuzz/corpus/xslt_empty_match_template_leak.xml +1 -0
  88. data/vendor-src/libleptris/test/fuzz/corpus/xslt_union_number_head_segv.xml +0 -0
  89. data/vendor-src/libleptris/test/fuzz/fuzz_html.c +39 -0
  90. data/vendor-src/libleptris/test/fuzz/fuzz_xslt.c +36 -0
  91. data/vendor-src/libleptris/test/html/test_html.cpp +49 -0
  92. data/vendor-src/libleptris/test/xpath/test_xpath.cpp +32 -0
  93. data/vendor-src/libleptris/test/xpath/test_xslt.cpp +33 -0
  94. data/vendor-src/libleptris/vcpkg.json +1 -1
  95. metadata +62 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 454663cdfd106166fbad7c8d73a8bd664adc9fc2d655ccacdcf8902a9e59b49f
4
- data.tar.gz: 71708bb68d0391c5cd9deb885064de42977a5ff2f7e3905e7ba007ffc1a2a513
3
+ metadata.gz: 299dc4470c7c88b3c8bfe4f15d6851318ff2cd7b00eb504254f7b0141f6ff49a
4
+ data.tar.gz: 4146e7ee1842110b26c117b87e9fb5abc4e5bca0c057b24b3cfcbea28cde9189
5
5
  SHA512:
6
- metadata.gz: 82f013d613567f7f00263b2698825e214ae1c81c5d0caa100b89fe505be8f45bf6ae71fa8c6f7e57afbb806d50ec0fc5382299cd8c6c37b42de403723924b436
7
- data.tar.gz: 131a4e4a1d166a028812e327b8163be8fb98759ba7ac241709252a4e061fdd5fc1b46950c14ec898484f8785f8c74108159a8cc629788c8235342d95cb90039e
6
+ metadata.gz: 5b1b0c185ba45e4f17f8db85b6f3556a7f3e32b5a950491211db9d308347c62ae97d559b945a3dd0d693ea623796d8e25e7ac95473682bedf0d822022d807fe9
7
+ data.tar.gz: e682769b5de88536c776b00b17b7ca330a4ad668a3f0f598c87528169d01d8336922c65e5f6ad0f7f02ceb172bcc35c771aa9edd2b00e3772db58a0dd75baaf2
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.424"
11
+ LIBLEPTRIS_VERSION = "1.9.425"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.424.0"
4
+ VERSION = "1.9.425.0"
5
5
  end
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.424
4
+ - libleptris v1.9.425
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,33 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.425] - 2026-11-16
4
+
5
+ ### Fixed
6
+
7
+ - **html: the foreign-CDATA arm fired on any `<!` in SVG/MathML content** (#2059, found by fuzz_html in its first 30 seconds). The arm checked neither the `<![CDATA[` opener nor that it fit the remaining bytes, so a short `<!x` in foreign content wrapped a negative length into `leptris_text_create` — an ASan negative-size-param crash. It now requires a full opener that fits; every other `<!` takes the bogus-comment path per HTML5 §13.2.5.42. The crasher is pinned at `test/fuzz/corpus/html_foreign_cdata_short_opener.bin` with two regression specs.
8
+ - **xpath: the union operator's NULL-nodeset operand crashed — SEGV at 0x18** (#2064, found by fuzz_xslt on the main nightly, run 43848591647). A union whose left side is a path applied to a non-node atom (`0//i|em` in an `xsl:for-each`) dereferenced a NODESET-typed result whose union never received a nodeset: `evaluate_location_path`'s non-nodeset-head branch and the XQuery empty-sequence coercions in `floor`/`ceiling`/`round` all returned bare `xpath_result_new(NODESET)` results, and the union's #514 ownership transfer was the first consumer to deref without a guard. The producers now hand back a real empty nodeset — identical observable semantics for every guarding consumer, correct for the strict ones. Crasher pinned (`xslt_union_number_head_segv.xml`), spec pins both operand orders.
9
+
10
+ ### Fixed (memory)
11
+
12
+ - **xslt: the union-split's empty-alternative continue leaked the part string** (fuzz_xslt, leak-f4fb611c). An empty alternative in `match="a| |b"` skipped the loop tail's `free`; both the empty-alternative and pattern-calloc paths now free their part.
13
+ - **xslt: an empty `match=""` template dropped its body and ns context** (nightly 43840763745). `add_template` built `t->ns` and `t->body` before validating the match, then the abort freed the bare `XsltTemplate` — the literal result instruction and the ns set leaked on every refusal. The teardown now lives in one `free_template` shared by the sheet free and the abort, so the next field added to the struct cannot reopen the gap; the refusal semantics (`match=""` is a static error) are unchanged and spec'd.
14
+
15
+ ### Performance
16
+
17
+ - **the B3 pipeline scoreboard shapes stand in-repo** (#2055, closes the SOTA B3 acceptance). Four whole-pipeline shapes — metanorma-compile, config-validation, feed-normalization, extract-transform — each a fixed committed corpus plus a fixed operation script (parse → query → mutate → serialize), measured with interleaved-median against libxml2 AND pugixml in one binary that rides the Benchmark workflow's three legs on every train. Every rig runs the same script — reads included — and gates on its own structural checks. First published rows: **0.195–0.386x of libxml2 (~2.6–5.1x faster) on every shape**; the pugixml rows land at 2.04–2.76x, the measured conformance floor. The zero-copy text lever verdict is recorded too (#2053): the parser's borrowed-text face beats the forced-copy face on both contested rows — **parse 2.66x, walk+read 2.39x** — closing the re-proposal loop with numbers.
18
+
19
+ ### CI
20
+
21
+ - **the universality gate grew its fourth leg: rust** (#2048). The leptris-rs crate runs the same 30-doc corpus through the same canonical contract; `differential.yml` now asserts ruby == python == wasm == rust byte-for-byte, linking the same engine tag the published pins carry. Verified locally: all 30 docs byte-identical against the published 1.9.424.0 gem.
22
+ - **the build manifest gained the reproducibility smoke** (#2050): the linux-amd64 leg builds twice from identical inputs and requires both library artifacts byte-identical — the standing proof that the manifest's hashes are re-derivable, not runner-mood.
23
+
24
+ ### Tooling
25
+
26
+ - **the fuzz lane grew the XSLT and HTML grammar families** (#2051): `fuzz_xslt` (compile + apply over attacker stylesheets) and `fuzz_html` (HTML5 and HTML4 faces over the same bytes, serialize + re-parse), seeded corpora and dedicated nightly legs. Three of this release's four fixes came out of it within two nights.
27
+
28
+
29
+
30
+
3
31
  ## [1.9.424] - 2026-11-15
4
32
 
5
33
  ### Performance
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.424
6
+ VERSION 1.9.425
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -23,6 +23,15 @@ Everything below is the task board for those four proofs. Every row
23
23
  ends with a dated measurement; the scoreboard lives in
24
24
  docs/MISSION-PLAN.md and is updated at every release.
25
25
 
26
+ > **SSOT rule (2026-11-15, issue #2049):** `docs/MISSION-PLAN.md` is
27
+ > the single source of truth for every measured number. This board
28
+ > links to it and records task state only — where a number appears
29
+ > here, it names the rig it came from, because two rigs can honestly
30
+ > disagree (see B1). The board is re-verified against the shipped
31
+ > state at every release train; stale boxes are findings, not
32
+ > footnotes (the A5 xpointer box outlived its own closure by three
33
+ > weeks).
34
+
26
35
  ---
27
36
 
28
37
  ## Gate A — Conformance: zero reds everywhere
@@ -70,7 +79,7 @@ older corpus datasets — reported, not gated.
70
79
  defaults, identity-constraint checks, derivation-ok attribute
71
80
  clauses; 1 oracle bug (bug322411) not chased)
72
81
 
73
- ### A4 DTD phase 8 (TODO 91)
82
+ ### A4 DTD phase 8 (TODO 91): DONE — both halves shipped
74
83
  - [x] ENTITY/ENTITIES attribute resolution (undeclared entity, parsed
75
84
  entity without NDATA, undeclared notation, bad ENTITIES token —
76
85
  all falsifiably spec'd; shipped bd21acc6/9d3b3a0e)
@@ -83,7 +92,11 @@ older corpus datasets — reported, not gated.
83
92
  ### A5 XInclude completeness (TODO 92)
84
93
  - [x] `parse="xml"` (ownership-transfer splice + canonical insert face,
85
94
  depth-guard resource-error fallback; verified by specs)
86
- - [ ] xpointer
95
+ - [x] xpointer — **closed 2026-10-22 (PR #1820)**: the schemes are
96
+ REC-conformant with pointer-miss=resource-error, implemented in
97
+ `src/leptris/xinclude/xinclude.c` and tested in
98
+ `test/xinclude/test_xinclude.cpp`. (This box was stale — it
99
+ predated #1820 and outlived it.)
87
100
 
88
101
  ### A6 The universality proof (differential corpus)
89
102
  - [ ] one curated corpus (the html5lib + QT3-winner + metanorma
@@ -97,7 +110,11 @@ older corpus datasets — reported, not gated.
97
110
 
98
111
  ## Gate B — Performance: every published row ≥1.00x
99
112
 
100
- ### B1 build row: ~2.9x → ≤1.0x (the #242 campaign)
113
+ ### B1 build row: trailing on the mission harness (~1.9x red; honest
114
+ baseline 2.72x — `wt/460-harness/build_bench.rb`), while the
115
+ scoreboard-table's 0.87x measures the round-trip rig — DIFFERENT
116
+ rigs, both named here so the boards stop contradicting. The #242
117
+ campaign carries the closure. (the #242 campaign)
101
118
  **Measured 2026-10-22: ~1.47-1.54x median after NINE merged levers**
102
119
  (honest baseline 2.72x; guard retirement −22%, namespace gate,
103
120
  nil-ivar priming, children-cache guard, mint direct-dispatch +
@@ -135,7 +152,17 @@ three interleaved-median runs (`wt/460-harness/pipeline_bench.rb`,
135
152
  finishes in 0.492-0.515x of Nokogiri's CPU time (~2x faster),
136
153
  three interleaved-median runs
137
154
  (`wt/460-harness/xslt_pipeline_bench.rb`)**
138
- - [ ] both to serialbench as the public scoreboard
155
+ - [x] the whole-pipeline SCOREBOARD SHAPES stand in-repo (#2055,
156
+ 2026-11-16): `benchmarks/workflows/bench_pipeline_shapes.cpp` —
157
+ four fixed-corpus shapes (metanorma-compile, config-validation,
158
+ feed-normalization, extract-transform), parse→query→mutate→
159
+ serialize, interleaved-median vs libxml2 AND pugixml, riding
160
+ the Benchmark workflow's three legs every train. First run
161
+ (macos leg): 0.195-0.386x of libxml2 (3-5x faster) on every
162
+ shape; pugixml rows 2.04-2.76x (the conformance floor, #1436).
163
+ The nokogiri binding-face rows above stay the wrapper-face
164
+ record; this binary is the engine face — same corpus both
165
+ faces, published in MISSION-PLAN.md's scoreboard of record.
139
166
 
140
167
  ### B4 durability
141
168
  - [ ] CI perf regression gates on the chokepoints (parse, walk,
@@ -155,7 +182,15 @@ three interleaved-median runs (`wt/460-harness/pipeline_bench.rb`,
155
182
  ~1.37x parse gap = conformance features pugixml doesn't do
156
183
  (dup detection, error positions, NUL writes) — the measured
157
184
  floor; owner decision in #1436.
158
- - [ ] zero-copy text lever (#1218) — adopt if it wins any row
185
+ - [x] zero-copy text lever (#1218/#2053) — **VERDICT 2026-11-16:
186
+ ADOPTED (and it already was).** The parser's text lanes have
187
+ carved borrowed views since TODO 115 / direct-parse round 8;
188
+ the measurement closes the re-proposal loop: borrowed beats
189
+ the forced-copy face on BOTH rows — parse 215.8us vs 573.9us
190
+ (2.66x) and walk+read 288.8us vs 689.3us (2.39x), ABBA x2
191
+ medians of 4, 200 iters/run, 520KB text-heavy corpus
192
+ (`benchmarks/dom/bench_zerocopy_text.c`). The copy lane stays
193
+ for the entity/mutation spans that require it.
159
194
 
160
195
  ## Gate C — Safety: trust is auditable
161
196
 
@@ -76,6 +76,7 @@ endfunction()
76
76
  # ----------------------------------------------------------------------------
77
77
  # DOM benchmarks (leptris vs libxml2)
78
78
  # ----------------------------------------------------------------------------
79
+ leptris_add_benchmark(bench_zerocopy_text dom/bench_zerocopy_text.c)
79
80
  if(LIBXML2_AVAILABLE)
80
81
  leptris_add_benchmark(bench_dom_leptris dom/bench_leptris.c)
81
82
  leptris_add_benchmark(bench_text_borrowed dom/bench_text_borrowed.c)
@@ -275,6 +276,30 @@ if(LIBXML2_AVAILABLE)
275
276
  target_link_libraries(bench_sax_libxml2 PRIVATE ${LIBXML2_LIBRARY})
276
277
  endif()
277
278
 
279
+ # ----------------------------------------------------------------------------
280
+ # B3 pipeline scoreboard shapes (#2055): parse → query → mutate →
281
+ # serialize over fixed corpora, interleaved-median vs libxml2 and
282
+ # pugixml. Needs C++ (pugixml.hpp); rows are machine-readable.
283
+ # ----------------------------------------------------------------------------
284
+ if(PUGIXML_AVAILABLE OR LIBXML2_AVAILABLE)
285
+ leptris_add_benchmark(bench_pipeline_shapes CXX
286
+ workflows/bench_pipeline_shapes.cpp)
287
+ if(PUGIXML_AVAILABLE)
288
+ target_compile_definitions(bench_pipeline_shapes PRIVATE HAVE_PUGIXML=1)
289
+ if(PUGIXML_TARGET)
290
+ target_link_libraries(bench_pipeline_shapes PRIVATE ${PUGIXML_TARGET})
291
+ else()
292
+ target_include_directories(bench_pipeline_shapes PRIVATE ${PUGIXML_INCLUDE_DIR})
293
+ target_link_libraries(bench_pipeline_shapes PRIVATE ${PUGIXML_LIBRARY})
294
+ endif()
295
+ endif()
296
+ if(LIBXML2_AVAILABLE)
297
+ target_compile_definitions(bench_pipeline_shapes PRIVATE HAVE_LIBXML2=1)
298
+ target_include_directories(bench_pipeline_shapes PRIVATE ${LIBXML2_INCLUDE_DIR})
299
+ target_link_libraries(bench_pipeline_shapes PRIVATE ${LIBXML2_LIBRARY})
300
+ endif()
301
+ endif()
302
+
278
303
  # ----------------------------------------------------------------------------
279
304
  # Print which targets will be built so CI logs are debuggable.
280
305
  # ----------------------------------------------------------------------------
@@ -0,0 +1,118 @@
1
+ /* benchmarks/dom/bench_zerocopy_text.c — SOTA #2053: the zero-copy
2
+ * text lever verdict. The parser's text lanes carve borrowed views
3
+ * out of the doc-owned buffer (TODO 115, direct-parse round 8); the
4
+ * copy lane exists for entity-laden spans.
5
+ *
6
+ * VERDICT (2026-11-16, ABBA x2, medians of 4, 200 iters/run,
7
+ * 520KB text-heavy corpus, RelWithDebInfo, apple-silicon):
8
+ * parse borrowed 215.8us vs copy 573.9us — borrow wins 2.66x
9
+ * walk+read borrowed 288.8us vs copy 689.3us — borrow wins 2.39x
10
+ * ADOPTED — the lever wins BOTH rows; the copy lane stays for the
11
+ * entity/mutation spans that require it, and the re-proposal loop is
12
+ * closed with these numbers.
13
+ *
14
+ * Reproducing the copy face: patch (scratch worktree, never commit)
15
+ * `leptris_text_create_borrowed` and `dp_text_create` to delegate to
16
+ * `leptris_text_create(content, len, pool, doc)` under a
17
+ * LEPTRIS_FORCE_COPY_TEXT define, then define it on both
18
+ * leptris_objects and this target. */
19
+ #include "benchmark.h"
20
+ #include <leptris.h>
21
+
22
+ #include <stdio.h>
23
+ #include <stdlib.h>
24
+ #include <string.h>
25
+
26
+ #ifndef LEPTRIS_FORCE_COPY_TEXT
27
+ #define LEPTRIS_FORCE_COPY_TEXT 0
28
+ #endif
29
+
30
+ #define PARAGRAPH_COUNT 4000
31
+
32
+ static const char PARAGRAPH[] =
33
+ "<p>The quick brown fox jumps over the lazy dog. "
34
+ "Pack my box with five dozen liquor jugs. "
35
+ "Sphinx of black quartz, judge my vow.</p>";
36
+
37
+ static char* g_xml;
38
+ static size_t g_len;
39
+
40
+ static void build_doc(void) {
41
+ size_t cap = PARAGRAPH_COUNT * (sizeof PARAGRAPH + 8) + 64;
42
+ g_xml = (char*)malloc(cap);
43
+ if (!g_xml) exit(2);
44
+ size_t off = (size_t)snprintf(g_xml, cap, "<article>");
45
+ for (int i = 0; i < PARAGRAPH_COUNT; i++)
46
+ off += (size_t)snprintf(g_xml + off, cap - off, "%s", PARAGRAPH);
47
+ off += (size_t)snprintf(g_xml + off, cap - off, "</article>");
48
+ g_len = off;
49
+ }
50
+
51
+ /* The walk+read row: parse, then read EVERY text node's content —
52
+ * the reads must touch the text (sum the lengths) or a dead-code
53
+ * fold would zero the row. */
54
+ static size_t walk_read(void) {
55
+ LeptrisStatus st = LEPTRIS_OK;
56
+ LeptrisDocument doc = leptris_parse_string(g_xml, g_len, &st);
57
+ if (!doc) return 0;
58
+ LeptrisElement root = leptris_document_root(doc);
59
+ if (!root) { leptris_document_free(doc); return 0; }
60
+ LeptrisXPathResult r = leptris_xpath_eval(doc, root, "//p");
61
+ if (!r) { leptris_document_free(doc); return 0; }
62
+ size_t n = leptris_xpath_result_count(r);
63
+ size_t total = 0;
64
+ for (size_t i = 0; i < n; i++) {
65
+ LeptrisElement p = leptris_xpath_result_get(r, i);
66
+ LeptrisNodeRef c = leptris_node_first_child(
67
+ leptris_element_as_node(p));
68
+ while (c) {
69
+ if (leptris_node_get_type(c) == LEPTRIS_NODE_TYPE_TEXT) {
70
+ const char* t = leptris_text_node_get_content(c);
71
+ if (t) total += strlen(t);
72
+ }
73
+ c = leptris_node_next_sibling(c);
74
+ }
75
+ }
76
+ leptris_xpath_result_free(r);
77
+ leptris_document_free(doc);
78
+ return total;
79
+ }
80
+
81
+ /* Parse-only row. */
82
+ static void bench_parse(void* unused) {
83
+ (void)unused;
84
+ LeptrisStatus st = LEPTRIS_OK;
85
+ LeptrisDocument doc = leptris_parse_string(g_xml, g_len, &st);
86
+ if (doc) leptris_document_free(doc);
87
+ }
88
+
89
+ static void bench_walk(void* unused) {
90
+ (void)unused;
91
+ size_t total = walk_read();
92
+ /* The read must have touched ~every paragraph's text; a fold to
93
+ * zero means the row measured nothing. */
94
+ if (total < 100) {
95
+ fprintf(stderr, "walk+read folded away (total=%zu)\n", total);
96
+ exit(3);
97
+ }
98
+ }
99
+
100
+ int main(int argc, char** argv) {
101
+ const char* face = LEPTRIS_FORCE_COPY_TEXT ? "copy" : "borrowed";
102
+ int iters = argc > 1 ? atoi(argv[1]) : 200;
103
+ build_doc();
104
+ bench_set_payload_size_kb((double)g_len / 1024.0);
105
+ printf("# zero-copy text verdict face=%s iters=%d bytes=%zu\n",
106
+ face, iters, g_len);
107
+
108
+ BenchResult rp = bench_run("parse-only", bench_parse, NULL,
109
+ (size_t)iters);
110
+ printf("row=parse face=%s mean_us=%.1f min_us=%.1f\n",
111
+ face, rp.mean_us, rp.min_us);
112
+ BenchResult rw = bench_run("walk+read", bench_walk, NULL,
113
+ (size_t)iters);
114
+ printf("row=walk_read face=%s mean_us=%.1f min_us=%.1f\n",
115
+ face, rw.mean_us, rw.min_us);
116
+ free(g_xml);
117
+ return 0;
118
+ }
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+ # Frozen output = false
3
+ # The B3 pipeline-shape corpora (SOTA #2055): four FIXED synthetic
4
+ # documents, one per consumer shape, committed alongside this
5
+ # generator for provenance. Re-running reproduces them byte-for-byte
6
+ # (deterministic LCG, no srand(Env)).
7
+ # pipeline_metanorma.xml — standards document: sections, terms,
8
+ # references (the metanorma compile shape)
9
+ # pipeline_config.xml — services config tree (the validation shape)
10
+ # pipeline_feed.xml — syndication feed with entries (the
11
+ # normalization shape)
12
+ # pipeline_records.xml — flat records with status (the
13
+ # extract-transform shape)
14
+
15
+ # Deterministic LCG so every run writes identical bytes.
16
+ class Lcg
17
+ def initialize(seed)
18
+ @s = seed
19
+ end
20
+
21
+ def rnd
22
+ @s = (@s * 1_103_515_245 + 12_345) & 0x7fff_ffff
23
+ @s
24
+ end
25
+
26
+ def word(n)
27
+ cons = %w[b c d f g h j k l m n p r s t v]
28
+ vows = %w[a e i o u]
29
+ w = (0...n).map { |i| i.even? ? cons[rnd % cons.size] : vows[rnd % vows.size] }.join
30
+ w
31
+ end
32
+
33
+ def pick(arr)
34
+ arr[rnd % arr.size]
35
+ end
36
+ end
37
+
38
+ def write(name, body)
39
+ File.write(File.join(__dir__, name), body)
40
+ puts "#{name}: #{body.bytesize} bytes"
41
+ end
42
+
43
+ # ---- metanorma shape -------------------------------------------------
44
+ rng = Lcg.new(2026_11_16)
45
+ out = +<<~HDR
46
+ <?xml version="1.0" encoding="UTF-8"?>
47
+ <!-- B3 fixed corpus (SOTA #2055): the metanorma-compile shape. -->
48
+ <standard version="1.0">
49
+ HDR
50
+ (1..12).each do |c|
51
+ out << " <clause id=\"clause-#{c}\"><title>Section #{rng.word(6)} #{c}</title>\n"
52
+ out << " <terms>\n"
53
+ (1..12).each do |t|
54
+ term = rng.word(5)
55
+ out << " <term><preferred>#{term}</preferred>" \
56
+ "<domain>#{rng.word(4)}</domain>" \
57
+ "<definition>#{rng.word(7)} #{rng.word(5)} #{rng.word(4)}.</definition></term>\n"
58
+ end
59
+ out << " </terms>\n <references>\n"
60
+ (1..4).each do |r|
61
+ out << " <ref bibitem=\"B#{c}-#{r}\">#{rng.word(8)} #{r}</ref>\n"
62
+ end
63
+ out << " </references>\n </clause>\n"
64
+ end
65
+ out << "</standard>\n"
66
+ write("pipeline_metanorma.xml", out)
67
+
68
+ # ---- config shape ----------------------------------------------------
69
+ rng = Lcg.new(777_001)
70
+ hosts = %w[web api db cache queue mail cdn auth metrics]
71
+ out = +<<~HDR
72
+ <?xml version="1.0" encoding="UTF-8"?>
73
+ <!-- B3 fixed corpus (SOTA #2055): the config-validation shape. -->
74
+ <config env="prod">
75
+ <defaults timeout="30" retries="3"/>
76
+ <services>
77
+ HDR
78
+ (1..96).each do |s|
79
+ host = rng.pick(hosts)
80
+ tls = s.even? ? " tls=\"true\"" : ""
81
+ out << " <service name=\"#{host}#{s}\" host=\"#{host}.svc\"" \
82
+ " port=\"#{8000 + rng.rnd % 900}\"#{tls}>" \
83
+ "<route path=\"/#{rng.word(4)}/#{s}\"/></service>\n"
84
+ end
85
+ out << " </services>\n </config>\n"
86
+ write("pipeline_config.xml", out)
87
+
88
+ # ---- feed shape ------------------------------------------------------
89
+ rng = Lcg.new(424_242)
90
+ out = +<<~HDR
91
+ <?xml version="1.0" encoding="UTF-8"?>
92
+ <!-- B3 fixed corpus (SOTA #2055): the feed-normalization shape. -->
93
+ <feed>
94
+ <title>the pipeline fixture feed</title>
95
+ <id>urn:leptris:pipeline:feed</id>
96
+ HDR
97
+ (1..160).each do |e|
98
+ out << " <entry id=\"e#{e}\"><title>#{rng.word(6)} #{rng.word(4)} #{e}</title>" \
99
+ "<link href=\"https://example.test/#{rng.word(5)}/#{e}\"/>" \
100
+ "<summary>#{rng.word(9)} #{rng.word(6)}.</summary>" \
101
+ "<category term=\"#{rng.word(4)}\"/></entry>\n"
102
+ end
103
+ out << " </feed>\n"
104
+ write("pipeline_feed.xml", out)
105
+
106
+ # ---- records shape ---------------------------------------------------
107
+ rng = Lcg.new(9_876_543)
108
+ statuses = %w[active active active pending archived]
109
+ out = +<<~HDR
110
+ <?xml version="1.0" encoding="UTF-8"?>
111
+ <!-- B3 fixed corpus (SOTA #2055): the extract-transform shape. -->
112
+ <records>
113
+ HDR
114
+ (1..280).each do |r|
115
+ out << " <record id=\"r#{r}\" status=\"#{rng.pick(statuses)}\"" \
116
+ " amount=\"#{(rng.rnd % 100_000) / 100.0}\">" \
117
+ "#{rng.word(6)}</record>\n"
118
+ end
119
+ out << " </records>\n"
120
+ write("pipeline_records.xml", out)
@@ -0,0 +1,103 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- B3 fixed corpus (SOTA #2055): the config-validation shape. -->
3
+ <config env="prod">
4
+ <defaults timeout="30" retries="3"/>
5
+ <services>
6
+ <service name="cache1" host="cache.svc" port="8267"><route path="/rinu/1"/></service>
7
+ <service name="cdn2" host="cdn.svc" port="8465" tls="true"><route path="/jego/2"/></service>
8
+ <service name="api3" host="api.svc" port="8383"><route path="/bate/3"/></service>
9
+ <service name="cdn4" host="cdn.svc" port="8713" tls="true"><route path="/nuli/4"/></service>
10
+ <service name="queue5" host="queue.svc" port="8551"><route path="/gudo/5"/></service>
11
+ <service name="metrics6" host="metrics.svc" port="8313" tls="true"><route path="/turi/6"/></service>
12
+ <service name="auth7" host="auth.svc" port="8247"><route path="/loje/7"/></service>
13
+ <service name="cache8" host="cache.svc" port="8281" tls="true"><route path="/dobe/8"/></service>
14
+ <service name="auth9" host="auth.svc" port="8803"><route path="/ranu/9"/></service>
15
+ <service name="web10" host="web.svc" port="8741" tls="true"><route path="/jage/10"/></service>
16
+ <service name="db11" host="db.svc" port="8199"><route path="/batu/11"/></service>
17
+ <service name="web12" host="web.svc" port="8809" tls="true"><route path="/nele/12"/></service>
18
+ <service name="metrics13" host="metrics.svc" port="8707"><route path="/gida/13"/></service>
19
+ <service name="cdn14" host="cdn.svc" port="8617" tls="true"><route path="/ture/14"/></service>
20
+ <service name="metrics15" host="metrics.svc" port="8207"><route path="/luju/15"/></service>
21
+ <service name="api16" host="api.svc" port="8157" tls="true"><route path="/debe/16"/></service>
22
+ <service name="auth17" host="auth.svc" port="8687"><route path="/rinu/17"/></service>
23
+ <service name="db18" host="db.svc" port="8297" tls="true"><route path="/jega/18"/></service>
24
+ <service name="db19" host="db.svc" port="8507"><route path="/bute/19"/></service>
25
+ <service name="api20" host="api.svc" port="8077" tls="true"><route path="/nole/20"/></service>
26
+ <service name="db21" host="db.svc" port="8547"><route path="/godu/21"/></service>
27
+ <service name="auth22" host="auth.svc" port="8033" tls="true"><route path="/tare/22"/></service>
28
+ <service name="metrics23" host="metrics.svc" port="8043"><route path="/luji/23"/></service>
29
+ <service name="cdn24" host="cdn.svc" port="8189" tls="true"><route path="/doba/24"/></service>
30
+ <service name="cdn25" host="cdn.svc" port="8411"><route path="/renu/25"/></service>
31
+ <service name="cdn26" host="cdn.svc" port="8369" tls="true"><route path="/juge/26"/></service>
32
+ <service name="db27" host="db.svc" port="8495"><route path="/bute/27"/></service>
33
+ <service name="api28" host="api.svc" port="8609" tls="true"><route path="/nulo/28"/></service>
34
+ <service name="mail29" host="mail.svc" port="8795"><route path="/godi/29"/></service>
35
+ <service name="metrics30" host="metrics.svc" port="8545" tls="true"><route path="/tero/30"/></service>
36
+ <service name="metrics31" host="metrics.svc" port="8007"><route path="/lajo/31"/></service>
37
+ <service name="queue32" host="queue.svc" port="8369" tls="true"><route path="/doba/32"/></service>
38
+ <service name="mail33" host="mail.svc" port="8635"><route path="/rone/33"/></service>
39
+ <service name="web34" host="web.svc" port="8533" tls="true"><route path="/jigo/34"/></service>
40
+ <service name="queue35" host="queue.svc" port="8759"><route path="/bute/35"/></service>
41
+ <service name="api36" host="api.svc" port="8473" tls="true"><route path="/noli/36"/></service>
42
+ <service name="api37" host="api.svc" port="8055"><route path="/gedu/37"/></service>
43
+ <service name="metrics38" host="metrics.svc" port="8769" tls="true"><route path="/toru/38"/></service>
44
+ <service name="mail39" host="mail.svc" port="8475"><route path="/laje/39"/></service>
45
+ <service name="metrics40" host="metrics.svc" port="8409" tls="true"><route path="/duba/40"/></service>
46
+ <service name="api41" host="api.svc" port="8519"><route path="/rene/41"/></service>
47
+ <service name="queue42" host="queue.svc" port="8585" tls="true"><route path="/jugi/42"/></service>
48
+ <service name="db43" host="db.svc" port="8787"><route path="/bitu/43"/></service>
49
+ <service name="auth44" host="auth.svc" port="8093" tls="true"><route path="/nole/44"/></service>
50
+ <service name="db45" host="db.svc" port="8395"><route path="/gida/45"/></service>
51
+ <service name="api46" host="api.svc" port="8377" tls="true"><route path="/toro/46"/></service>
52
+ <service name="auth47" host="auth.svc" port="8383"><route path="/lijo/47"/></service>
53
+ <service name="auth48" host="auth.svc" port="8513" tls="true"><route path="/dobo/48"/></service>
54
+ <service name="web49" host="web.svc" port="8295"><route path="/rona/49"/></service>
55
+ <service name="cdn50" host="cdn.svc" port="8725" tls="true"><route path="/jega/50"/></service>
56
+ <service name="db51" host="db.svc" port="8095"><route path="/buto/51"/></service>
57
+ <service name="cdn52" host="cdn.svc" port="8425" tls="true"><route path="/nile/52"/></service>
58
+ <service name="db53" host="db.svc" port="8175"><route path="/godo/53"/></service>
59
+ <service name="web54" host="web.svc" port="8645" tls="true"><route path="/tari/54"/></service>
60
+ <service name="cdn55" host="cdn.svc" port="8751"><route path="/leja/55"/></service>
61
+ <service name="queue56" host="queue.svc" port="8765" tls="true"><route path="/dabu/56"/></service>
62
+ <service name="web57" host="web.svc" port="8759"><route path="/rino/57"/></service>
63
+ <service name="cdn58" host="cdn.svc" port="8893" tls="true"><route path="/jige/58"/></service>
64
+ <service name="metrics59" host="metrics.svc" port="8799"><route path="/batu/59"/></service>
65
+ <service name="mail60" host="mail.svc" port="8545" tls="true"><route path="/nelu/60"/></service>
66
+ <service name="cdn61" host="cdn.svc" port="8531"><route path="/gida/61"/></service>
67
+ <service name="queue62" host="queue.svc" port="8517" tls="true"><route path="/tiru/62"/></service>
68
+ <service name="web63" host="web.svc" port="8627"><route path="/leji/63"/></service>
69
+ <service name="metrics64" host="metrics.svc" port="8205" tls="true"><route path="/dibo/64"/></service>
70
+ <service name="db65" host="db.svc" port="8495"><route path="/rini/65"/></service>
71
+ <service name="queue66" host="queue.svc" port="8589" tls="true"><route path="/jige/66"/></service>
72
+ <service name="cache67" host="cache.svc" port="8599"><route path="/boto/67"/></service>
73
+ <service name="db68" host="db.svc" port="8481" tls="true"><route path="/nile/68"/></service>
74
+ <service name="cache69" host="cache.svc" port="8055"><route path="/gedi/69"/></service>
75
+ <service name="mail70" host="mail.svc" port="8597" tls="true"><route path="/tura/70"/></service>
76
+ <service name="api71" host="api.svc" port="8455"><route path="/loje/71"/></service>
77
+ <service name="web72" host="web.svc" port="8613" tls="true"><route path="/dubu/72"/></service>
78
+ <service name="db73" host="db.svc" port="8611"><route path="/rino/73"/></service>
79
+ <service name="db74" host="db.svc" port="8113" tls="true"><route path="/joga/74"/></service>
80
+ <service name="auth75" host="auth.svc" port="8319"><route path="/batu/75"/></service>
81
+ <service name="api76" host="api.svc" port="8289" tls="true"><route path="/nulu/76"/></service>
82
+ <service name="mail77" host="mail.svc" port="8275"><route path="/godo/77"/></service>
83
+ <service name="cdn78" host="cdn.svc" port="8477" tls="true"><route path="/teri/78"/></service>
84
+ <service name="api79" host="api.svc" port="8511"><route path="/liji/79"/></service>
85
+ <service name="metrics80" host="metrics.svc" port="8341" tls="true"><route path="/debu/80"/></service>
86
+ <service name="cdn81" host="cdn.svc" port="8215"><route path="/ronu/81"/></service>
87
+ <service name="auth82" host="auth.svc" port="8697" tls="true"><route path="/jegu/82"/></service>
88
+ <service name="queue83" host="queue.svc" port="8127"><route path="/buta/83"/></service>
89
+ <service name="cache84" host="cache.svc" port="8185" tls="true"><route path="/nula/84"/></service>
90
+ <service name="web85" host="web.svc" port="8491"><route path="/gadu/85"/></service>
91
+ <service name="queue86" host="queue.svc" port="8669" tls="true"><route path="/toro/86"/></service>
92
+ <service name="db87" host="db.svc" port="8187"><route path="/loji/87"/></service>
93
+ <service name="cache88" host="cache.svc" port="8693" tls="true"><route path="/dibe/88"/></service>
94
+ <service name="web89" host="web.svc" port="8251"><route path="/rani/89"/></service>
95
+ <service name="mail90" host="mail.svc" port="8777" tls="true"><route path="/jige/90"/></service>
96
+ <service name="db91" host="db.svc" port="8619"><route path="/bite/91"/></service>
97
+ <service name="web92" host="web.svc" port="8781" tls="true"><route path="/nelu/92"/></service>
98
+ <service name="metrics93" host="metrics.svc" port="8451"><route path="/gadu/93"/></service>
99
+ <service name="web94" host="web.svc" port="8885" tls="true"><route path="/tura/94"/></service>
100
+ <service name="web95" host="web.svc" port="8823"><route path="/liju/95"/></service>
101
+ <service name="metrics96" host="metrics.svc" port="8709" tls="true"><route path="/dabi/96"/></service>
102
+ </services>
103
+ </config>