leptris 1.9.458.0-arm-linux → 1.9.460.0-arm-linux
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/version.rb +1 -1
- data/lib/leptris/xml/document.rb +75 -48
- data/lib/leptris/xml/ffi.rb +8 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +42 -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 +3 -0
- 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 +59 -20
- data/vendor-src/libleptris/src/leptris/xsd/validate.c +291 -168
- data/vendor-src/libleptris/test/CMakeLists.txt +28 -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/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/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/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 +35 -2
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
#include "../common/bench_time.h"
|
|
23
23
|
|
|
24
|
+
#include "bench_rows.h" /* BenchResult/Library/run_bench — shared core */
|
|
25
|
+
|
|
24
26
|
#include <leptris.h>
|
|
25
27
|
#include <leptris/sax/sax.h>
|
|
26
28
|
|
|
@@ -36,14 +38,6 @@
|
|
|
36
38
|
// ----------------------------------------------------------------------------
|
|
37
39
|
// Helpers
|
|
38
40
|
|
|
39
|
-
static double now_us() {
|
|
40
|
-
return bench_wall_us();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static size_t current_rss_kb() {
|
|
44
|
-
return (size_t)bench_rss_current_kb();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
41
|
static char* slurp(const char* path, size_t* len) {
|
|
48
42
|
FILE* f = fopen(path, "rb");
|
|
49
43
|
if (!f) return NULL;
|
|
@@ -124,70 +118,7 @@ static Fixture gen_catalog(int n_items) {
|
|
|
124
118
|
}
|
|
125
119
|
|
|
126
120
|
// ----------------------------------------------------------------------------
|
|
127
|
-
// Result recording
|
|
128
|
-
|
|
129
|
-
struct BenchResult {
|
|
130
|
-
std::string id;
|
|
131
|
-
std::string feature;
|
|
132
|
-
std::string input;
|
|
133
|
-
size_t size_bytes;
|
|
134
|
-
int iterations;
|
|
135
|
-
double latency_us_min;
|
|
136
|
-
double latency_us_median;
|
|
137
|
-
double throughput_mbs; // 0 if not applicable
|
|
138
|
-
double cpu_user_ms;
|
|
139
|
-
double cpu_sys_ms;
|
|
140
|
-
size_t memory_peak_kb;
|
|
141
|
-
int applicable;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
struct Library {
|
|
145
|
-
std::string name;
|
|
146
|
-
std::string version;
|
|
147
|
-
std::vector<BenchResult> results;
|
|
148
|
-
void add(const BenchResult& r) { results.push_back(r); }
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
template<typename F>
|
|
152
|
-
BenchResult run_bench(const char* id, const char* feature, const char* input,
|
|
153
|
-
size_t size_bytes, int iterations, F&& fn) {
|
|
154
|
-
BenchResult r = {};
|
|
155
|
-
r.id = id;
|
|
156
|
-
r.feature = feature;
|
|
157
|
-
r.input = input;
|
|
158
|
-
r.size_bytes = size_bytes;
|
|
159
|
-
r.iterations = iterations;
|
|
160
|
-
r.applicable = 1;
|
|
161
|
-
|
|
162
|
-
// Warm-up
|
|
163
|
-
fn();
|
|
164
|
-
|
|
165
|
-
std::vector<double> times;
|
|
166
|
-
times.reserve(iterations);
|
|
167
|
-
BenchCpuSplit cpu_before, cpu_after;
|
|
168
|
-
bench_cpu_split_us(&cpu_before);
|
|
169
|
-
size_t rss_before = current_rss_kb();
|
|
170
|
-
|
|
171
|
-
for (int i = 0; i < iterations; i++) {
|
|
172
|
-
double t0 = now_us();
|
|
173
|
-
fn();
|
|
174
|
-
times.push_back(now_us() - t0);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
bench_cpu_split_us(&cpu_after);
|
|
178
|
-
size_t rss_after = current_rss_kb();
|
|
179
|
-
|
|
180
|
-
std::sort(times.begin(), times.end());
|
|
181
|
-
r.latency_us_min = times.front();
|
|
182
|
-
r.latency_us_median = times[times.size() / 2];
|
|
183
|
-
r.cpu_user_ms = (cpu_after.user_us - cpu_before.user_us) / 1000.0;
|
|
184
|
-
r.cpu_sys_ms = (cpu_after.sys_us - cpu_before.sys_us) / 1000.0;
|
|
185
|
-
r.memory_peak_kb = rss_after > rss_before ? rss_after - rss_before : 0;
|
|
186
|
-
r.throughput_mbs = (size_bytes > 0 && r.latency_us_min > 0.001)
|
|
187
|
-
? size_bytes / r.latency_us_min / 1000.0
|
|
188
|
-
: 0.0;
|
|
189
|
-
return r;
|
|
190
|
-
}
|
|
121
|
+
// Result recording — BenchResult/Library/run_bench live in bench_rows.h
|
|
191
122
|
|
|
192
123
|
// ----------------------------------------------------------------------------
|
|
193
124
|
// YAML output
|
|
@@ -284,7 +215,8 @@ static void bench_dom_parse(Library& lib, const std::vector<Fixture>& fixtures,
|
|
|
284
215
|
lib.add(run_bench(id, "DOM parse", fx.label.c_str(), len, iters,
|
|
285
216
|
[&]() {
|
|
286
217
|
pugi::xml_document doc;
|
|
287
|
-
doc.load_buffer(data, len
|
|
218
|
+
doc.load_buffer(data, len,
|
|
219
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
288
220
|
}));
|
|
289
221
|
}
|
|
290
222
|
#endif
|
|
@@ -390,7 +322,8 @@ static void bench_serialize(Library& lib, const Fixture& attr_heavy,
|
|
|
390
322
|
#ifdef HAVE_PUGIXML
|
|
391
323
|
else if (lib.name == "pugixml") {
|
|
392
324
|
pugi::xml_document doc;
|
|
393
|
-
doc.load_buffer(data, len
|
|
325
|
+
doc.load_buffer(data, len,
|
|
326
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
394
327
|
struct Sink : pugi::xml_writer {
|
|
395
328
|
std::string out;
|
|
396
329
|
void write(const void* d, size_t sz) override {
|
|
@@ -423,9 +356,20 @@ static void bench_serialize(Library& lib, const Fixture& attr_heavy,
|
|
|
423
356
|
|
|
424
357
|
// -- Mutation (leptris + pugixml) --
|
|
425
358
|
|
|
359
|
+
// The append-10k family compares DOM-BUILD capability. The primary row
|
|
360
|
+
// (mutation_append_10k) drives the fused single-call face — the
|
|
361
|
+
// capability-equivalent of pugixml's one root.append_child("c") per
|
|
362
|
+
// child — and lives in its own TU (bench_matrix_fused.cpp) so its
|
|
363
|
+
// codegen cannot re-roll the other rows' link-layout dice. The
|
|
364
|
+
// two-call pair stays as a second variant so both builder shapes stay
|
|
365
|
+
// visible on the scoreboard.
|
|
366
|
+
|
|
367
|
+
void bench_mutation_fused_row(Library& lib, int iters);
|
|
368
|
+
|
|
426
369
|
static void bench_mutation(Library& lib, int iters) {
|
|
427
370
|
if (lib.name == "leptris") {
|
|
428
|
-
lib
|
|
371
|
+
bench_mutation_fused_row(lib, iters);
|
|
372
|
+
lib.add(run_bench("mutation_append_10k_twocall", "mutation", "append-10k", 0, iters,
|
|
429
373
|
[&]() {
|
|
430
374
|
LeptrisStatus st = (LeptrisStatus)0;
|
|
431
375
|
LeptrisDocument d = leptris_parse_string("<r/>", 4, &st);
|
|
@@ -528,7 +472,8 @@ static void bench_xpath(Library& lib, const Fixture& catalog, int iters) {
|
|
|
528
472
|
#ifdef HAVE_PUGIXML
|
|
529
473
|
else if (lib.name == "pugixml") {
|
|
530
474
|
pugi::xml_document doc;
|
|
531
|
-
doc.load_buffer(data, len
|
|
475
|
+
doc.load_buffer(data, len,
|
|
476
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
532
477
|
lib.add(run_bench(id, "XPath", queries[q], len, iters,
|
|
533
478
|
[&]() {
|
|
534
479
|
pugi::xpath_query qy(queries[q]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// benchmarks/matrix/bench_matrix_fused.cpp — the fused append row's
|
|
2
|
+
// own translation unit.
|
|
3
|
+
//
|
|
4
|
+
// The mutation rows are tight ~120 µs loops whose measured time
|
|
5
|
+
// swings double-digit percent with the link-layout/codegen dice of
|
|
6
|
+
// the TU they compile in (a 2026-12-02 A/B: adding the fused-row
|
|
7
|
+
// lambda to bench_matrix.cpp re-rolled the OTHER rows' dice +10%
|
|
8
|
+
// while the engine objects stayed byte-identical; an inert duplicate
|
|
9
|
+
// lambda did not). Each row family therefore compiles in its own TU
|
|
10
|
+
// against the shared bench_rows.h core.
|
|
11
|
+
//
|
|
12
|
+
// The row compares DOM-build capability: pugixml's shape is ONE
|
|
13
|
+
// root.append_child("c") per child, so leptris's primary row drives
|
|
14
|
+
// the capability-equivalent fused face (leptris_element_create_child
|
|
15
|
+
// — #2255).
|
|
16
|
+
#include "bench_rows.h"
|
|
17
|
+
|
|
18
|
+
#include <leptris.h>
|
|
19
|
+
|
|
20
|
+
void bench_mutation_fused_row(Library& lib, int iters) {
|
|
21
|
+
lib.add(run_bench("mutation_append_10k", "mutation", "append-10k", 0, iters,
|
|
22
|
+
[]() {
|
|
23
|
+
LeptrisStatus st = (LeptrisStatus)0;
|
|
24
|
+
LeptrisDocument d = leptris_parse_string("<r/>", 4, &st);
|
|
25
|
+
LeptrisElement root = leptris_document_root(d);
|
|
26
|
+
for (int i = 0; i < 10000; i++) {
|
|
27
|
+
leptris_element_create_child(root, "c");
|
|
28
|
+
}
|
|
29
|
+
leptris_document_free(d);
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// benchmarks/matrix/bench_rows.h — the harness core (result record,
|
|
2
|
+
// library accumulator, timing loop) shared by the bench_matrix
|
|
3
|
+
// translation units.
|
|
4
|
+
//
|
|
5
|
+
// Extracted from bench_matrix.cpp verbatim so the fused append row
|
|
6
|
+
// (bench_matrix_fused.cpp) can live in its own TU: the mutation rows
|
|
7
|
+
// are tight ~120 µs loops whose measured time swings double-digit
|
|
8
|
+
// percent with the link-layout/codegen dice of the TU they compile
|
|
9
|
+
// in — keeping each row family in its own TU keeps a new row's
|
|
10
|
+
// codegen from re-rolling the others' dice.
|
|
11
|
+
#ifndef LEPTRIS_BENCH_MATRIX_ROWS_H
|
|
12
|
+
#define LEPTRIS_BENCH_MATRIX_ROWS_H
|
|
13
|
+
|
|
14
|
+
#include <algorithm>
|
|
15
|
+
#include <cstdio>
|
|
16
|
+
#include <cstdlib>
|
|
17
|
+
#include <cstring>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
#include "../common/bench_time.h"
|
|
22
|
+
|
|
23
|
+
struct BenchResult {
|
|
24
|
+
std::string id;
|
|
25
|
+
std::string feature;
|
|
26
|
+
std::string input;
|
|
27
|
+
size_t size_bytes;
|
|
28
|
+
int iterations;
|
|
29
|
+
double latency_us_min;
|
|
30
|
+
double latency_us_median;
|
|
31
|
+
double throughput_mbs; // 0 if not applicable
|
|
32
|
+
double cpu_user_ms;
|
|
33
|
+
double cpu_sys_ms;
|
|
34
|
+
size_t memory_peak_kb;
|
|
35
|
+
int applicable;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct Library {
|
|
39
|
+
std::string name;
|
|
40
|
+
std::string version;
|
|
41
|
+
std::vector<BenchResult> results;
|
|
42
|
+
void add(const BenchResult& r) { results.push_back(r); }
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
static inline double bench_now_us() {
|
|
46
|
+
return bench_wall_us();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static inline size_t bench_current_rss_kb() {
|
|
50
|
+
return (size_t)bench_rss_current_kb();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
template<typename F>
|
|
54
|
+
BenchResult run_bench(const char* id, const char* feature, const char* input,
|
|
55
|
+
size_t size_bytes, int iterations, F&& fn) {
|
|
56
|
+
BenchResult r = {};
|
|
57
|
+
r.id = id;
|
|
58
|
+
r.feature = feature;
|
|
59
|
+
r.input = input;
|
|
60
|
+
r.size_bytes = size_bytes;
|
|
61
|
+
r.iterations = iterations;
|
|
62
|
+
r.applicable = 1;
|
|
63
|
+
|
|
64
|
+
// Warm-up
|
|
65
|
+
fn();
|
|
66
|
+
|
|
67
|
+
std::vector<double> times;
|
|
68
|
+
times.reserve(iterations);
|
|
69
|
+
BenchCpuSplit cpu_before, cpu_after;
|
|
70
|
+
bench_cpu_split_us(&cpu_before);
|
|
71
|
+
size_t rss_before = bench_current_rss_kb();
|
|
72
|
+
|
|
73
|
+
for (int i = 0; i < iterations; i++) {
|
|
74
|
+
double t0 = bench_now_us();
|
|
75
|
+
fn();
|
|
76
|
+
times.push_back(bench_now_us() - t0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bench_cpu_split_us(&cpu_after);
|
|
80
|
+
size_t rss_after = bench_current_rss_kb();
|
|
81
|
+
|
|
82
|
+
std::sort(times.begin(), times.end());
|
|
83
|
+
r.latency_us_min = times.front();
|
|
84
|
+
r.latency_us_median = times[times.size() / 2];
|
|
85
|
+
r.cpu_user_ms = (cpu_after.user_us - cpu_before.user_us) / 1000.0;
|
|
86
|
+
r.cpu_sys_ms = (cpu_after.sys_us - cpu_before.sys_us) / 1000.0;
|
|
87
|
+
r.memory_peak_kb = rss_after > rss_before ? rss_after - rss_before : 0;
|
|
88
|
+
r.throughput_mbs = (size_bytes > 0 && r.latency_us_min > 0.001)
|
|
89
|
+
? size_bytes / r.latency_us_min / 1000.0
|
|
90
|
+
: 0.0;
|
|
91
|
+
return r;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#endif /* LEPTRIS_BENCH_MATRIX_ROWS_H */
|
|
@@ -267,7 +267,8 @@ int main(void) {
|
|
|
267
267
|
for (int i = 0; i < N_PARSE; i++) {
|
|
268
268
|
pugi::xml_document d;
|
|
269
269
|
pugi::xml_parse_result res =
|
|
270
|
-
d.load_buffer((void*)xml.data(), xml.size()
|
|
270
|
+
d.load_buffer((void*)xml.data(), xml.size(),
|
|
271
|
+
pugi::parse_default | pugi::parse_ws_pcdata);
|
|
271
272
|
if (!res) return 8;
|
|
272
273
|
for (pugi::xml_node c = d.first_child().first_child();
|
|
273
274
|
c; c = c.next_sibling()) {
|
|
@@ -110,7 +110,8 @@ int main(int argc, char** argv) {
|
|
|
110
110
|
for (int r = 0; r < 5; r++) {
|
|
111
111
|
double a = now_us();
|
|
112
112
|
xml_document xdoc;
|
|
113
|
-
xml_parse_result res = xdoc.load_buffer(doc, len
|
|
113
|
+
xml_parse_result res = xdoc.load_buffer(doc, len,
|
|
114
|
+
parse_default | parse_ws_pcdata);
|
|
114
115
|
double b = now_us();
|
|
115
116
|
if (!res) { printf("PUGIXML FAILED: %s\n", res.description()); return 1; }
|
|
116
117
|
if (b - a < pbest) pbest = b - a;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Build + run the generation_users twin (leptris vs pugixml, paired
|
|
3
|
+
# same-process) — the serialbench `generation` op on the canonical users
|
|
4
|
+
# fixture (leptris#2279). Arguments pass through to the harness
|
|
5
|
+
# (--iters N --rounds N --phases gen,parse,ser,free --check --dump).
|
|
6
|
+
#
|
|
7
|
+
# Referee parity (serialbench-c .github/workflows/benchmark.yml): the
|
|
8
|
+
# engine is a STATIC libleptris.a with LTO OFF, the harness is plain
|
|
9
|
+
# -O3 -DNDEBUG, pugixml v1.16 is compiled from source with the same
|
|
10
|
+
# flags. This script builds exactly that; an LTO library or a
|
|
11
|
+
# distribution pugixml measures a different race.
|
|
12
|
+
#
|
|
13
|
+
# Env: BUILD_DIR (default build-nolto), PUGIXML_SRC (default: a pugixml
|
|
14
|
+
# checkout's src/ — falls back to the Homebrew dylib when absent),
|
|
15
|
+
# UTF8PROC_LIB / ICONV per the library's optional features.
|
|
16
|
+
set -e
|
|
17
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
18
|
+
BUILD_DIR="${BUILD_DIR:-$ROOT/build-nolto}"
|
|
19
|
+
OUT="${OUT:-/tmp/generation_users}"
|
|
20
|
+
CFLAGS="-O3 -DNDEBUG"
|
|
21
|
+
|
|
22
|
+
cmake -S "$ROOT" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \
|
|
23
|
+
-DBUILD_TESTING=OFF -DLEPTRIS_BUILD_CLI=OFF -DLEPTRIS_ENABLE_LTO=OFF \
|
|
24
|
+
> /dev/null
|
|
25
|
+
cmake --build "$BUILD_DIR" -j4 --target leptris_static 2>&1 | grep -E "error|FAILED" || true
|
|
26
|
+
|
|
27
|
+
cc -std=c11 $CFLAGS -I"$ROOT/src/include" -I"$ROOT/benchmarks/common" \
|
|
28
|
+
-c "$ROOT/benchmarks/twins/generation_users_leptris.c" -o "$OUT.leptris.o"
|
|
29
|
+
PUGI_SRC_DIR="${PUGIXML_SRC:-$HOME/src/external/pugixml/src}"
|
|
30
|
+
PUGI_OBJ=""
|
|
31
|
+
PUGI_LIB="${PUGIXML_LIB:-/opt/homebrew/lib/libpugixml.1.16.dylib}"
|
|
32
|
+
PUGI_INC="-I/opt/homebrew/include"
|
|
33
|
+
if [ -f "$PUGI_SRC_DIR/pugixml.cpp" ]; then
|
|
34
|
+
# v1.16 from source with the harness's own flags (the referee's FetchContent build).
|
|
35
|
+
if [ ! -f "$OUT.pugixml.o" ] || [ "$PUGI_SRC_DIR/pugixml.cpp" -nt "$OUT.pugixml.o" ]; then
|
|
36
|
+
c++ -std=c++17 $CFLAGS -I"$PUGI_SRC_DIR" -c "$PUGI_SRC_DIR/pugixml.cpp" -o "$OUT.pugixml.o"
|
|
37
|
+
fi
|
|
38
|
+
PUGI_OBJ="$OUT.pugixml.o"
|
|
39
|
+
PUGI_LIB=""
|
|
40
|
+
PUGI_INC="-I$PUGI_SRC_DIR"
|
|
41
|
+
fi
|
|
42
|
+
c++ -std=c++17 $CFLAGS -I"$ROOT/src/include" -I"$ROOT/benchmarks/common" \
|
|
43
|
+
$PUGI_INC \
|
|
44
|
+
"$OUT.leptris.o" "$ROOT/benchmarks/twins/generation_users_pugixml.cpp" \
|
|
45
|
+
$PUGI_OBJ "$BUILD_DIR/src/libleptris.a" $PUGI_LIB \
|
|
46
|
+
/opt/homebrew/lib/libutf8proc.3.3.0.dylib -liconv -o "$OUT"
|
|
47
|
+
|
|
48
|
+
echo "lib: $BUILD_DIR/src/libleptris.a (LTO off) load: $(uptime | sed 's/.*load averages: //')" >&2
|
|
49
|
+
"$OUT" "$@"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* generation_users_fixture.h — the serialbench canonical `users` document,
|
|
2
|
+
* regenerated in place (the twins' shared generator).
|
|
3
|
+
*
|
|
4
|
+
* Source of truth: github.com/serialbench/fixtures `medium.xml` (sha256
|
|
5
|
+
* 008777897407f88efe651de4a310d6d0a768895dda8985ffdaa4c3e8504c979d,
|
|
6
|
+
* 306805 bytes, 13004 lines), produced once by serialbench-ruby's
|
|
7
|
+
* Serialbench::TestData#generate_medium_xml (lib/serialbench/test_data.rb):
|
|
8
|
+
* 1000 users x {name, email, created_at, profile{age, city,
|
|
9
|
+
* preferences{theme, notifications}}}, one `id` attribute per user, a
|
|
10
|
+
* pretty-printed line per element. Every serialbench harness measures this
|
|
11
|
+
* byte-identical file — the C harness reads it from disk; the twins
|
|
12
|
+
* regenerate it so the row needs no external clone. `--dump` prints the
|
|
13
|
+
* generator's bytes for a shasum check against the fixture.
|
|
14
|
+
*
|
|
15
|
+
* Shape (what the op actually pays for):
|
|
16
|
+
* elements 10001 (10 per user + <users>)
|
|
17
|
+
* attributes 1000 (id)
|
|
18
|
+
* text nodes 19002 (7000 content + 12002 inter-element whitespace)
|
|
19
|
+
* depth 4 (users > user > profile > preferences > theme)
|
|
20
|
+
* With parse_ws_pcdata on the pugixml side both lanes carry the SAME
|
|
21
|
+
* 29003-node tree — the same-tree law (leptris#1842).
|
|
22
|
+
*
|
|
23
|
+
* Output contract pinned by --check: the leptris lane's compact default
|
|
24
|
+
* (leptris_document_serialize(d, NULL)) emits the fixture minus two bytes —
|
|
25
|
+
* no newline after the declaration, none after the root (306803 bytes).
|
|
26
|
+
* pugixml's print(format_default) re-indents with tabs where it adds
|
|
27
|
+
* layout of its own and keeps the document-level newline after the
|
|
28
|
+
* declaration, so its byte count differs; what must agree is the tree
|
|
29
|
+
* (10001 elements each). */
|
|
30
|
+
#ifndef LEPTRIS_TWINS_GENERATION_USERS_FIXTURE_H
|
|
31
|
+
#define LEPTRIS_TWINS_GENERATION_USERS_FIXTURE_H
|
|
32
|
+
|
|
33
|
+
#include <stdio.h>
|
|
34
|
+
#include <string.h>
|
|
35
|
+
|
|
36
|
+
#define GU_USERS 1000
|
|
37
|
+
/* 1000 users x ~306 bytes + prolog: 306805 exactly, as the fixture. */
|
|
38
|
+
#define GU_FIXTURE_CAP (320 * 1024)
|
|
39
|
+
|
|
40
|
+
/* Phases — same semantics on both lanes. GEN is the serialbench op;
|
|
41
|
+
* the other three split it so a gap can be attributed: GEN - PARSE is
|
|
42
|
+
* the serialize share, SER measures that share directly (the document
|
|
43
|
+
* is parsed outside the timer), FREE is the document teardown. */
|
|
44
|
+
enum { GU_PHASE_GEN = 0, GU_PHASE_PARSE = 1, GU_PHASE_SER = 2,
|
|
45
|
+
GU_PHASE_FREE = 3, GU_PHASE_COUNT = 4 };
|
|
46
|
+
|
|
47
|
+
/* Port of generate_medium_xml (Ruby squiggly heredocs, verbatim layout):
|
|
48
|
+
* the first user is indented two spaces by the outer template, every
|
|
49
|
+
* later one starts at column 0; one blank line precedes </users>. */
|
|
50
|
+
static size_t gu_generate_users_xml(char* b) {
|
|
51
|
+
char* q = b;
|
|
52
|
+
char* end = b + GU_FIXTURE_CAP;
|
|
53
|
+
q += snprintf(q, (size_t)(end - q),
|
|
54
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<users>\n");
|
|
55
|
+
for (int i = 1; i <= GU_USERS; i++) {
|
|
56
|
+
q += snprintf(q, (size_t)(end - q),
|
|
57
|
+
"%s<user id=\"%d\">\n"
|
|
58
|
+
" <name>User %d</name>\n"
|
|
59
|
+
" <email>user%d@example.com</email>\n"
|
|
60
|
+
" <created_at>2023-01-%02dT10:00:00Z</created_at>\n"
|
|
61
|
+
" <profile>\n"
|
|
62
|
+
" <age>%d</age>\n"
|
|
63
|
+
" <city>City %d</city>\n"
|
|
64
|
+
" <preferences>\n"
|
|
65
|
+
" <theme>%s</theme>\n"
|
|
66
|
+
" <notifications>%s</notifications>\n"
|
|
67
|
+
" </preferences>\n"
|
|
68
|
+
" </profile>\n"
|
|
69
|
+
"</user>\n",
|
|
70
|
+
i == 1 ? " " : "", i, i, i, (i % 28) + 1, 20 + (i % 50),
|
|
71
|
+
i % 100, (i % 2 == 0) ? "dark" : "light",
|
|
72
|
+
(i % 3 == 0) ? "true" : "false");
|
|
73
|
+
}
|
|
74
|
+
q += snprintf(q, (size_t)(end - q), "\n</users>\n");
|
|
75
|
+
return (size_t)(q - b);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#endif /* LEPTRIS_TWINS_GENERATION_USERS_FIXTURE_H */
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/* generation_users_leptris.c — the leptris lane of serialbench's
|
|
2
|
+
* `generation` op on the canonical users fixture (leptris#2279), paired
|
|
3
|
+
* same-process with the pugixml lane in generation_users_pugixml.cpp
|
|
4
|
+
* (which owns main()).
|
|
5
|
+
*
|
|
6
|
+
* Op definition — serialbench-c src/bench.c, run_format(), the
|
|
7
|
+
* g_cur_op = "generation" BENCH over fixtures/medium.xml (3 warm-up +
|
|
8
|
+
* 3 timed iterations on the referee; this twin takes min-of-N over 3
|
|
9
|
+
* interleaved rounds instead — the referee's 3 iterations cannot resolve
|
|
10
|
+
* a 1.9x gap on a shared runner):
|
|
11
|
+
*
|
|
12
|
+
* LeptrisStatus st = LEPTRIS_OK;
|
|
13
|
+
* LeptrisDocument d = leptris_parse_string(data, len, &st);
|
|
14
|
+
* if (st == LEPTRIS_OK) {
|
|
15
|
+
* char *out = leptris_document_serialize(d, NULL);
|
|
16
|
+
* if (out) leptris_free_string(out);
|
|
17
|
+
* }
|
|
18
|
+
* leptris_document_free(d);
|
|
19
|
+
*
|
|
20
|
+
* leptris_document_serialize(d, NULL) is the compact default: no
|
|
21
|
+
* re-indent (indent == 0), the declaration echoed, every whitespace
|
|
22
|
+
* text node kept — the output is the input byte for byte
|
|
23
|
+
* (gu_leptris_check, --check).
|
|
24
|
+
*
|
|
25
|
+
* Referee build (serialbench-c .github/workflows/benchmark.yml): the
|
|
26
|
+
* engine is a STATIC libleptris.a built with LEPTRIS_ENABLE_LTO=OFF,
|
|
27
|
+
* linked into a plain -O3 -DNDEBUG harness. generation_users.sh builds
|
|
28
|
+
* the twin the same way — an LTO library measures a different engine
|
|
29
|
+
* than the one the scoreboard prices.
|
|
30
|
+
*
|
|
31
|
+
* Build (from the repo root; see generation_users.sh):
|
|
32
|
+
* cc -std=c11 -O3 -DNDEBUG -I src/include -c generation_users_leptris.c
|
|
33
|
+
* c++ -std=c++17 -O3 -DNDEBUG -I src/include -I benchmarks/common \
|
|
34
|
+
* gu_leptris.o generation_users_pugixml.cpp <libleptris.a> \
|
|
35
|
+
* <pugixml.o> <libutf8proc> -liconv */
|
|
36
|
+
|
|
37
|
+
#include "../common/bench_time.h"
|
|
38
|
+
#include <leptris.h>
|
|
39
|
+
#include "generation_users_fixture.h"
|
|
40
|
+
|
|
41
|
+
/* One iteration of a phase. `held` is the document parsed outside the
|
|
42
|
+
* timer for SER (NULL for the phases that parse inside). Returns the
|
|
43
|
+
* serialized length so a check can assert the op did real work. */
|
|
44
|
+
static size_t gu_leptris_once(const char* data, size_t len, int phase,
|
|
45
|
+
LeptrisDocument held) {
|
|
46
|
+
size_t out_len = 0;
|
|
47
|
+
if (phase == GU_PHASE_FREE) {
|
|
48
|
+
leptris_document_free(held);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
if (phase == GU_PHASE_SER) {
|
|
52
|
+
char* out = leptris_document_serialize(held, NULL);
|
|
53
|
+
if (out) {
|
|
54
|
+
out_len = strlen(out);
|
|
55
|
+
leptris_free_string(out);
|
|
56
|
+
}
|
|
57
|
+
return out_len;
|
|
58
|
+
}
|
|
59
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
60
|
+
LeptrisDocument d = leptris_parse_string(data, len, &st);
|
|
61
|
+
if (st == LEPTRIS_OK && phase == GU_PHASE_GEN) {
|
|
62
|
+
char* out = leptris_document_serialize(d, NULL);
|
|
63
|
+
if (out) {
|
|
64
|
+
out_len = strlen(out);
|
|
65
|
+
leptris_free_string(out);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
leptris_document_free(d);
|
|
69
|
+
return out_len;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
double gu_leptris_min(const char* data, size_t len, int phase, int iters) {
|
|
73
|
+
double best = 1e18;
|
|
74
|
+
LeptrisDocument held = NULL;
|
|
75
|
+
if (phase == GU_PHASE_SER) {
|
|
76
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
77
|
+
held = leptris_parse_string(data, len, &st);
|
|
78
|
+
if (!held) return -1.0;
|
|
79
|
+
}
|
|
80
|
+
for (int i = 0; i < iters + 1; i++) { /* iteration 0 warms */
|
|
81
|
+
LeptrisDocument d = held;
|
|
82
|
+
if (phase == GU_PHASE_FREE) {
|
|
83
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
84
|
+
d = leptris_parse_string(data, len, &st);
|
|
85
|
+
if (!d) return -1.0;
|
|
86
|
+
}
|
|
87
|
+
double t0 = bench_wall_us();
|
|
88
|
+
gu_leptris_once(data, len, phase, d);
|
|
89
|
+
double dt = bench_wall_us() - t0;
|
|
90
|
+
if (i > 0 && dt < best) best = dt;
|
|
91
|
+
}
|
|
92
|
+
return best;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* --check: one GEN iteration with the output captured. Returns 0 and
|
|
96
|
+
* copies the serialization into `out` (NUL-terminated); nonzero on any
|
|
97
|
+
* failure. The caller compares the bytes against the fixture. */
|
|
98
|
+
int gu_leptris_check(const char* data, size_t len, char* out, size_t cap,
|
|
99
|
+
size_t* out_len, long* element_count) {
|
|
100
|
+
LeptrisStatus st = LEPTRIS_OK;
|
|
101
|
+
LeptrisDocument d = leptris_parse_string(data, len, &st);
|
|
102
|
+
if (!d || st != LEPTRIS_OK) return -1;
|
|
103
|
+
*element_count = -1;
|
|
104
|
+
LeptrisXPathResult r = leptris_xpath_eval(d, NULL, "//*");
|
|
105
|
+
if (r) {
|
|
106
|
+
*element_count = (long)leptris_xpath_result_count(r);
|
|
107
|
+
leptris_xpath_result_free(r);
|
|
108
|
+
}
|
|
109
|
+
char* s = leptris_document_serialize(d, NULL);
|
|
110
|
+
int rc = 0;
|
|
111
|
+
if (!s) {
|
|
112
|
+
rc = -2;
|
|
113
|
+
} else {
|
|
114
|
+
size_t n = strlen(s);
|
|
115
|
+
*out_len = n;
|
|
116
|
+
if (n + 1 > cap) rc = -3;
|
|
117
|
+
else memcpy(out, s, n + 1);
|
|
118
|
+
leptris_free_string(s);
|
|
119
|
+
}
|
|
120
|
+
leptris_document_free(d);
|
|
121
|
+
return rc;
|
|
122
|
+
}
|