leptris 1.9.461.0 → 1.9.462.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/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/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +17 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/benchmarks/README.adoc +26 -0
- data/vendor-src/libleptris/benchmarks/README.md +23 -0
- data/vendor-src/libleptris/benchmarks/baseline.json +5 -1
- data/vendor-src/libleptris/benchmarks/matrix/bench_matrix.cpp +11 -1
- data/vendor-src/libleptris/scripts/ab_compare.py +120 -0
- data/vendor-src/libleptris/scripts/perf_gate.py +21 -3
- data/vendor-src/libleptris/src/include/leptris.h +2 -2
- data/vendor-src/libleptris/src/leptris/common/port.h +32 -0
- data/vendor-src/libleptris/src/leptris/core.c +2 -2
- data/vendor-src/libleptris/src/leptris/flat/direct_parse.c +3 -3
- data/vendor-src/libleptris/src/leptris/memory/pool.c +2 -2
- data/vendor-src/libleptris/test/CMakeLists.txt +3 -0
- data/vendor-src/libleptris/test/memory/test_layout_pin.cpp +42 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea390397f7ed16576ae043de733fc7fd74923c59ceaf55007fdb77aef7ec727c
|
|
4
|
+
data.tar.gz: 3b6dbdf43caa8ddd35ed48a75f8d1b72ecf64fcc81eda7b3008a3a101ec7eb7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d407550dd0a75cd05fa7be4d89285c13c1469aa83376bb30692faef6cec1ada4b3e82b0ab448c3cc2bf9a5146c2a7b09574d3e797ddd2795fb23238e5b020ac3
|
|
7
|
+
data.tar.gz: da178bb2ccc9c3116e623b9c2e3c93a33227d03ef87edbd8a4df94c60580f67a9386d7ccd24aaf2221813490324245ca372c30546f4585441876ea1d3fdde857
|
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.462"
|
|
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/vendor-src/README.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.9.462] - 2026-12-05
|
|
4
|
+
|
|
5
|
+
The code-placement release: the parse hot path's function starts are pinned, the Performance Gate compares again, every engine pull request carries a same-runner A/B against main, and the PGO attach job runs on a release train.
|
|
6
|
+
|
|
7
|
+
### Performance
|
|
8
|
+
|
|
9
|
+
- **The parse hot path no longer rides the link layout** (#2306). The functions on the parse hot path — the direct parse loop, the attribute scan, the interleaved lane and the two pool entry points — start on a 64-byte boundary in every build. Before, an attr-heavy parse's number was decided partly by where the link happened to place them: two builds with instruction-identical parse code measured 417 µs and 377 µs on `dom_parse_attr-heavy-5k`, because an edit in any unrelated translation unit moved every function's start address. With the pin, two trees that differ by every other edit measure the same. No instruction changes; a spec fails if a pinned entry point is off its boundary. The comparison rules that follow are in `benchmarks/README.{md,adoc}` as the Layout Law.
|
|
10
|
+
|
|
11
|
+
### CI
|
|
12
|
+
|
|
13
|
+
- **The Performance Gate compares again** (#2307). `benchmarks/baseline.json` had been empty since 2026-10-21, so every run recorded into a throwaway checkout and exited green. The baseline is seeded, an empty baseline is a failure, and an update persists as an artifact to commit through a PR.
|
|
14
|
+
- **Every engine pull request carries a same-runner A/B against main** (#2313): the base branch's engine and the PR's engine built in one job with identical flags, `bench_matrix` run interleaved, a per-row table in the job summary. Report-only — its own null run measured the noise floor of three rounds on a shared runner at about 5%.
|
|
15
|
+
- **The PGO attach job runs on a release train** (#2310). Its condition compared `github.event_name` with `workflow_call`, which a called workflow never carries, so the job had skipped on every train and the tarballs were attached by hand.
|
|
16
|
+
|
|
17
|
+
Nothing else changed: XSD 1.1 = 2211/2211, XSD 1.0 = 1046/1056, XPath 438/438, libxslt 205/205.
|
|
18
|
+
|
|
19
|
+
|
|
3
20
|
## [1.9.461] - 2026-12-05
|
|
4
21
|
|
|
5
22
|
The QName release: one split rule for every name on both parse lanes, every parse failure named and positioned, a per-evaluation XPath leak closed — and the users row takes another step toward pugixml.
|
|
@@ -27,6 +27,32 @@ scoreboard claim). The same principle applies to any competitor
|
|
|
27
27
|
option that changes the DOM content: configure the competitor to
|
|
28
28
|
build the SAME tree, then compare speed.
|
|
29
29
|
|
|
30
|
+
== The Layout Law (code placement)
|
|
31
|
+
|
|
32
|
+
A parse row also measures WHERE the code lands. Two binaries built
|
|
33
|
+
from the same loops with whole-program LTO differed by ~10% on
|
|
34
|
+
`dom_parse_attr-heavy-5k` (417 µs vs 377 µs, paired and interleaved)
|
|
35
|
+
while every parse function was instruction-identical: the toolchains
|
|
36
|
+
align a function to 4 bytes by default, so an edit anywhere re-rolls
|
|
37
|
+
every function's start address (leptris#2306). The engine pins its
|
|
38
|
+
parse hot path to a 64-byte boundary (`LEPTRIS_HOT`, in
|
|
39
|
+
`src/leptris/common/port.h`) and this directory pins the harness loop
|
|
40
|
+
that drives it (`BENCH_HOT`, in `matrix/bench_matrix.cpp`).
|
|
41
|
+
|
|
42
|
+
* A difference under ~2% between two binaries that are not both pinned
|
|
43
|
+
is not evidence of anything about the source.
|
|
44
|
+
* A claim that a parity row is "unchanged" or "improved" needs a
|
|
45
|
+
paired, interleaved, same-machine run of both binaries built with
|
|
46
|
+
identical flags — never two separate runs, never a CI median against
|
|
47
|
+
a baseline from another runner class.
|
|
48
|
+
* When a row moves more than ~3% and no loop of its own changed, build
|
|
49
|
+
a layout-control binary — the same tree with only the hot file
|
|
50
|
+
reverted — and run the pair interleaved. If the control is as fast
|
|
51
|
+
as the candidate, the source is innocent and the placement moved.
|
|
52
|
+
* Do not pin to a page (4096) or larger: the run-time slide randomizes
|
|
53
|
+
address bits from 14 up, so page-level pins move the row from run to
|
|
54
|
+
run (measured: 370 µs in some rounds, ~390 µs in others).
|
|
55
|
+
|
|
30
56
|
== Building Benchmarks
|
|
31
57
|
|
|
32
58
|
[source,bash]
|
|
@@ -82,6 +82,29 @@ cd build/benchmarks
|
|
|
82
82
|
4. **Statistical Rigor**: Multiple runs, calculate mean/stddev/min/max
|
|
83
83
|
5. **Apples-to-Apples**: Measure equivalent operations only
|
|
84
84
|
6. **MECE Structure**: Each benchmark has single, clear purpose
|
|
85
|
+
7. **Code Placement Is Part of the Measurement (THE LAYOUT LAW)**: a
|
|
86
|
+
parse row also measures WHERE the code lands. Two binaries built
|
|
87
|
+
from the same loops with whole-program LTO differed by ~10% on
|
|
88
|
+
`dom_parse_attr-heavy-5k` (417 µs vs 377 µs, paired and interleaved)
|
|
89
|
+
while every parse function was instruction-identical — the toolchains
|
|
90
|
+
align a function to 4 bytes by default, so an edit anywhere re-rolls
|
|
91
|
+
every function's start address (#2306). The engine pins its parse
|
|
92
|
+
hot path to a 64-byte boundary (`LEPTRIS_HOT`, in
|
|
93
|
+
`src/leptris/common/port.h`) and this directory pins the harness loop
|
|
94
|
+
that drives it (`BENCH_HOT`, in `matrix/bench_matrix.cpp`). Rules:
|
|
95
|
+
* A difference under ~2% between two binaries that are not both
|
|
96
|
+
pinned is not evidence of anything about the source.
|
|
97
|
+
* A claim that a parity row is "unchanged" or "improved" needs a
|
|
98
|
+
paired, interleaved, same-machine run of both binaries built with
|
|
99
|
+
identical flags — never two separate runs, never a CI median against
|
|
100
|
+
a baseline from another runner class.
|
|
101
|
+
* When a row moves more than ~3% and no loop of its own changed, build
|
|
102
|
+
a layout-control binary — the same tree with only the hot file
|
|
103
|
+
reverted — and run the pair interleaved. If the control is as fast
|
|
104
|
+
as the candidate, the source is innocent and the placement moved.
|
|
105
|
+
* Do not pin to a page (4096) or larger: the run-time slide randomizes
|
|
106
|
+
address bits from 14 up, so page-level pins move the row from run to
|
|
107
|
+
run (measured: 370 µs in some rounds, ~390 µs in others).
|
|
85
108
|
|
|
86
109
|
## DOM Benchmarks
|
|
87
110
|
|
|
@@ -194,7 +194,17 @@ static void write_yaml(const Library& lib, const char* out_dir) {
|
|
|
194
194
|
|
|
195
195
|
// -- DOM Parse --
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
// The engine pins its parse hot path to the same boundary (LEPTRIS_HOT,
|
|
198
|
+
// src/leptris/common/port.h). The harness loop that drives it is pinned
|
|
199
|
+
// here so a measurement does not inherit this file's layout either:
|
|
200
|
+
// an unpinned harness moves with every unrelated edit in this file too.
|
|
201
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
202
|
+
#define BENCH_HOT __attribute__((aligned(64)))
|
|
203
|
+
#else
|
|
204
|
+
#define BENCH_HOT
|
|
205
|
+
#endif
|
|
206
|
+
|
|
207
|
+
BENCH_HOT static void bench_dom_parse(Library& lib, const std::vector<Fixture>& fixtures,
|
|
198
208
|
int iters) {
|
|
199
209
|
for (const auto& fx : fixtures) {
|
|
200
210
|
char id[128];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Same-runner A/B of bench_matrix rows: a candidate engine against the base
|
|
3
|
+
it was built beside, in one job, with identical flags.
|
|
4
|
+
|
|
5
|
+
ab_compare.py --base run1.txt run2.txt ... --cand run1.txt run2.txt ...
|
|
6
|
+
[--threshold PCT] [--min-us US] [--gate] [--json OUT]
|
|
7
|
+
|
|
8
|
+
Each file is one captured `bench_matrix` stdout (its "=== Summary" table).
|
|
9
|
+
The row's leptris latency is the first column; the median over the files of
|
|
10
|
+
a side is that side's number. delta = (cand - base) / base: positive means
|
|
11
|
+
the candidate is SLOWER.
|
|
12
|
+
|
|
13
|
+
A row whose base median is below --min-us is reported as too small to
|
|
14
|
+
compare (the table truncates to whole microseconds, so a sub-microsecond
|
|
15
|
+
row reads 0 and a percentage is meaningless).
|
|
16
|
+
|
|
17
|
+
Without --gate the script only reports (exit 0). With --gate it exits 1
|
|
18
|
+
when any comparable row is slower than --threshold.
|
|
19
|
+
"""
|
|
20
|
+
import argparse
|
|
21
|
+
import json
|
|
22
|
+
import re
|
|
23
|
+
import statistics
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
ROW = re.compile(r"^\s*(\S+)\s+(\d+(?:\.\d+)?)\s*/")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def parse(path):
|
|
30
|
+
rows = {}
|
|
31
|
+
in_table = False
|
|
32
|
+
with open(path, encoding="utf-8", errors="replace") as f:
|
|
33
|
+
for line in f:
|
|
34
|
+
if "=== Summary" in line:
|
|
35
|
+
in_table = True
|
|
36
|
+
continue
|
|
37
|
+
if not in_table:
|
|
38
|
+
continue
|
|
39
|
+
if not line.strip():
|
|
40
|
+
break
|
|
41
|
+
m = ROW.match(line)
|
|
42
|
+
if m:
|
|
43
|
+
rows[m.group(1)] = float(m.group(2))
|
|
44
|
+
return rows
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def medians(paths, label):
|
|
48
|
+
per_row = {}
|
|
49
|
+
for p in paths:
|
|
50
|
+
rows = parse(p)
|
|
51
|
+
if not rows:
|
|
52
|
+
sys.exit(f"ab-compare: no bench_matrix rows found in {label} file {p}")
|
|
53
|
+
for name, value in rows.items():
|
|
54
|
+
per_row.setdefault(name, []).append(value)
|
|
55
|
+
return {name: statistics.median(values) for name, values in per_row.items()}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main():
|
|
59
|
+
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
60
|
+
ap.add_argument("--base", nargs="+", required=True, metavar="FILE")
|
|
61
|
+
ap.add_argument("--cand", nargs="+", required=True, metavar="FILE")
|
|
62
|
+
ap.add_argument("--threshold", type=float, default=10.0,
|
|
63
|
+
help="slowdown %% that counts as a regression (default 10)")
|
|
64
|
+
ap.add_argument("--min-us", type=float, default=5.0,
|
|
65
|
+
help="rows with a smaller base median are not compared (default 5)")
|
|
66
|
+
ap.add_argument("--gate", action="store_true",
|
|
67
|
+
help="exit 1 when a row regresses beyond --threshold")
|
|
68
|
+
ap.add_argument("--json", metavar="OUT", help="also write the rows as JSON")
|
|
69
|
+
args = ap.parse_args()
|
|
70
|
+
|
|
71
|
+
base = medians(args.base, "base")
|
|
72
|
+
cand = medians(args.cand, "cand")
|
|
73
|
+
|
|
74
|
+
result = []
|
|
75
|
+
for name in sorted(set(base) | set(cand)):
|
|
76
|
+
b = base.get(name)
|
|
77
|
+
c = cand.get(name)
|
|
78
|
+
if b is None or c is None:
|
|
79
|
+
result.append({"row": name, "base": b, "cand": c, "delta_pct": None,
|
|
80
|
+
"verdict": "missing on the %s side" % ("base" if b is None else "candidate")})
|
|
81
|
+
continue
|
|
82
|
+
if b < args.min_us:
|
|
83
|
+
result.append({"row": name, "base": b, "cand": c, "delta_pct": None,
|
|
84
|
+
"verdict": "too small to compare"})
|
|
85
|
+
continue
|
|
86
|
+
delta = (c - b) / b * 100.0
|
|
87
|
+
verdict = "REGRESSION" if delta > args.threshold else "ok"
|
|
88
|
+
result.append({"row": name, "base": b, "cand": c, "delta_pct": round(delta, 1),
|
|
89
|
+
"verdict": verdict})
|
|
90
|
+
|
|
91
|
+
result.sort(key=lambda r: -(abs(r["delta_pct"]) if r["delta_pct"] is not None else -1))
|
|
92
|
+
|
|
93
|
+
def us(value):
|
|
94
|
+
return "-" if value is None else "%g" % value
|
|
95
|
+
|
|
96
|
+
print("| row | base µs | candidate µs | delta | verdict |")
|
|
97
|
+
print("|---|---:|---:|---:|---|")
|
|
98
|
+
for r in result:
|
|
99
|
+
d = "-" if r["delta_pct"] is None else "%+.1f%%" % r["delta_pct"]
|
|
100
|
+
print("| `%s` | %s | %s | %s | %s |" % (r["row"], us(r["base"]), us(r["cand"]), d, r["verdict"]))
|
|
101
|
+
|
|
102
|
+
comparable = [r for r in result if r["delta_pct"] is not None]
|
|
103
|
+
regressed = [r for r in comparable if r["verdict"] == "REGRESSION"]
|
|
104
|
+
print()
|
|
105
|
+
print("ab-compare: %d rows compared, %d regressed beyond %.1f%% (%d too small or missing)"
|
|
106
|
+
% (len(comparable), len(regressed), args.threshold, len(result) - len(comparable)))
|
|
107
|
+
|
|
108
|
+
if args.json:
|
|
109
|
+
with open(args.json, "w", encoding="utf-8") as f:
|
|
110
|
+
json.dump({"threshold_pct": args.threshold, "rows": result}, f, indent=2)
|
|
111
|
+
if args.gate and regressed:
|
|
112
|
+
for r in regressed:
|
|
113
|
+
print("ab-compare: REGRESSION %s: %.1f -> %.1f µs (%+.1f%%)"
|
|
114
|
+
% (r["row"], r["base"], r["cand"], r["delta_pct"]), file=sys.stderr)
|
|
115
|
+
return 1
|
|
116
|
+
return 0
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
sys.exit(main())
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
the committed baseline. Fails when any tracked metric regresses by
|
|
4
4
|
more than the recorded tolerance. Runner noise on shared CI is
|
|
5
5
|
significant; medians of 5 runs plus a generous default tolerance keep
|
|
6
|
-
this a regression tripwire, not a stopwatch.
|
|
6
|
+
this a regression tripwire, not a stopwatch.
|
|
7
|
+
|
|
8
|
+
An EMPTY or missing baseline exits non-zero (leptris#2307): before,
|
|
9
|
+
it fell into the record branch on every run and the gate was green
|
|
10
|
+
while comparing nothing. Seed it with a `workflow_dispatch` that sets
|
|
11
|
+
update_baseline=true and commit the uploaded artifact."""
|
|
7
12
|
import json, os, re, statistics, sys
|
|
8
13
|
|
|
9
14
|
runs_path, baseline_path = sys.argv[1], sys.argv[2]
|
|
@@ -31,16 +36,29 @@ base = {}
|
|
|
31
36
|
if os.path.exists(baseline_path):
|
|
32
37
|
base = json.load(open(baseline_path))
|
|
33
38
|
|
|
34
|
-
if update
|
|
39
|
+
if update:
|
|
35
40
|
json.dump(medians, open(baseline_path, "w"), indent=2, sort_keys=True)
|
|
36
41
|
print("perf-gate: baseline recorded:", medians)
|
|
37
42
|
sys.exit(0)
|
|
38
43
|
|
|
44
|
+
if not any(not str(k).startswith("__") for k in base):
|
|
45
|
+
# An EMPTY baseline used to fall into the record branch above on
|
|
46
|
+
# every run, writing into the runner's throwaway checkout and
|
|
47
|
+
# exiting green — the tripwire never compared anything for six
|
|
48
|
+
# weeks (leptris#2307). Fail loudly instead: an unseeded baseline
|
|
49
|
+
# is a broken gate, not a green one.
|
|
50
|
+
sys.exit(
|
|
51
|
+
"perf-gate: baseline is empty — seed benchmarks/baseline.json first "
|
|
52
|
+
"(dispatch this workflow with update_baseline=true, then commit the "
|
|
53
|
+
"uploaded perf-gate-baseline artifact through a PR)"
|
|
54
|
+
)
|
|
55
|
+
|
|
39
56
|
fail = False
|
|
40
57
|
for k, m in sorted(medians.items()):
|
|
41
58
|
b = base.get(k)
|
|
42
59
|
if b is None:
|
|
43
|
-
print(f"perf-gate: {k}: new metric, median {m:.1f} ns/node
|
|
60
|
+
print(f"perf-gate: {k}: new metric, median {m:.1f} ns/node "
|
|
61
|
+
f"(not in the baseline; record it with an update)")
|
|
44
62
|
continue
|
|
45
63
|
regress = (m - b) / b * 100.0
|
|
46
64
|
tol = base.get("__tolerance_pct__", 15.0)
|
|
@@ -4331,8 +4331,8 @@ LEPTRIS_API const char* leptris_xinclude_get_encoding(LeptrisElement include_ele
|
|
|
4331
4331
|
* CI's export-surface gate diffs the header against the binary. */
|
|
4332
4332
|
#define LIBLEPTRIS_VERSION_MAJOR 1
|
|
4333
4333
|
#define LIBLEPTRIS_VERSION_MINOR 9
|
|
4334
|
-
#define LIBLEPTRIS_VERSION_PATCH
|
|
4335
|
-
#define LIBLEPTRIS_VERSION_STRING "1.9.
|
|
4334
|
+
#define LIBLEPTRIS_VERSION_PATCH 462
|
|
4335
|
+
#define LIBLEPTRIS_VERSION_STRING "1.9.462"
|
|
4336
4336
|
|
|
4337
4337
|
/**
|
|
4338
4338
|
* Get libleptris version string
|
|
@@ -150,6 +150,38 @@ static __inline uint32_t leptris_port_bswap32(uint32_t w) {
|
|
|
150
150
|
# define LEPTRIS_ALWAYS_INLINE inline
|
|
151
151
|
#endif
|
|
152
152
|
|
|
153
|
+
/* ---- Code placement ------------------------------------------------------ */
|
|
154
|
+
/* LEPTRIS_CODE_ALIGNED(N) pins a function's start address onto an N-byte
|
|
155
|
+
* boundary of the final image. These toolchains give a function 4 bytes
|
|
156
|
+
* of alignment by default, so its address — and the address of every loop
|
|
157
|
+
* in it — is decided by how much code the link happened to place in front
|
|
158
|
+
* of it: an edit in an unrelated translation unit re-rolls it. On an
|
|
159
|
+
* attr-heavy parse that lottery was worth ~10% (#2306: two binaries with
|
|
160
|
+
* instruction-identical parse loops, 417 µs vs 377 µs). MSVC aligns
|
|
161
|
+
* functions itself and ignores the attribute. */
|
|
162
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
163
|
+
# define LEPTRIS_CODE_ALIGNED(N) __attribute__((aligned(N)))
|
|
164
|
+
#else
|
|
165
|
+
# define LEPTRIS_CODE_ALIGNED(N)
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
/* LEPTRIS_HOT marks a function on the parse hot path and pins its start
|
|
169
|
+
* to LEPTRIS_HOT_ALIGN bytes (a build may override the value; 0 = off).
|
|
170
|
+
* LEPTRIS_HOT_PINNED is 1 when the attribute is effective, so a spec can
|
|
171
|
+
* assert the pin where it exists and skip where the toolchain cannot
|
|
172
|
+
* place functions. 4096 is NOT a safe value: the run-time slide randomizes
|
|
173
|
+
* address bits from 14 up, and page-level pins measured erratic (#2306). */
|
|
174
|
+
#ifndef LEPTRIS_HOT_ALIGN
|
|
175
|
+
# define LEPTRIS_HOT_ALIGN 64
|
|
176
|
+
#endif
|
|
177
|
+
#if LEPTRIS_HOT_ALIGN > 0 && (defined(__GNUC__) || defined(__clang__))
|
|
178
|
+
# define LEPTRIS_HOT LEPTRIS_CODE_ALIGNED(LEPTRIS_HOT_ALIGN)
|
|
179
|
+
# define LEPTRIS_HOT_PINNED 1
|
|
180
|
+
#else
|
|
181
|
+
# define LEPTRIS_HOT
|
|
182
|
+
# define LEPTRIS_HOT_PINNED 0
|
|
183
|
+
#endif
|
|
184
|
+
|
|
153
185
|
/* ---- restrict-qualified pointer locals --------------------------------- */
|
|
154
186
|
/* LEPTRIS_RESTRICT qualifies a POINTER DECLARATION (`T* LEPTRIS_RESTRICT
|
|
155
187
|
* p`): every access to the object it designates in its scope goes
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* reaches here via target_compile_definitions in src/CMakeLists.txt.
|
|
22
22
|
* Fallback keeps hand-built compilers honest. */
|
|
23
23
|
#ifndef LEPTRIS_VERSION
|
|
24
|
-
#define LEPTRIS_VERSION "1.9.
|
|
24
|
+
#define LEPTRIS_VERSION "1.9.462"
|
|
25
25
|
#endif
|
|
26
26
|
#ifndef LEPTRIS_VERSION_MAJOR
|
|
27
27
|
#define LEPTRIS_VERSION_MAJOR 1
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
#define LEPTRIS_VERSION_MINOR 9
|
|
31
31
|
#endif
|
|
32
32
|
#ifndef LEPTRIS_VERSION_PATCH
|
|
33
|
-
#define LEPTRIS_VERSION_PATCH
|
|
33
|
+
#define LEPTRIS_VERSION_PATCH 462
|
|
34
34
|
#endif
|
|
35
35
|
|
|
36
36
|
/* Thread-local allocator hooks (TODO 27/74).
|
|
@@ -1411,7 +1411,7 @@ static struct leptris_ns_cache* dp_ensure_cache(DParser* p,
|
|
|
1411
1411
|
* samples in prologue spill traffic). Own frame = own allocation —
|
|
1412
1412
|
* the hot fields stay in registers; the call cost is one frame per
|
|
1413
1413
|
* TAG, not per attribute. */
|
|
1414
|
-
static LEPTRIS_NOINLINE int dp_parse_attrs(DParser* p,
|
|
1414
|
+
static LEPTRIS_NOINLINE LEPTRIS_HOT int dp_parse_attrs(DParser* p,
|
|
1415
1415
|
LeptrisElement elem) {
|
|
1416
1416
|
/* Reset the per-element caches so dp_add_attr_inline and the
|
|
1417
1417
|
* xmlns wiring below can both run in O(1) per attr. */
|
|
@@ -2258,7 +2258,7 @@ static int dp_utf8_valid(const char* s, size_t len);
|
|
|
2258
2258
|
static struct leptris_document* dp_fail_invalid_utf8(const char* s,
|
|
2259
2259
|
size_t len);
|
|
2260
2260
|
|
|
2261
|
-
static struct leptris_document* direct_parse_internal(char* buf, size_t len,
|
|
2261
|
+
static LEPTRIS_HOT struct leptris_document* direct_parse_internal(char* buf, size_t len,
|
|
2262
2262
|
unsigned skip_flags,
|
|
2263
2263
|
int owns_buffer,
|
|
2264
2264
|
int drop_ws_text,
|
|
@@ -4634,7 +4634,7 @@ static int dp_il_eligible(size_t len) {
|
|
|
4634
4634
|
return len >= dp_env_memo.min_len;
|
|
4635
4635
|
}
|
|
4636
4636
|
|
|
4637
|
-
static struct leptris_document* dp_il_try(const char* xml, size_t len,
|
|
4637
|
+
static LEPTRIS_HOT struct leptris_document* dp_il_try(const char* xml, size_t len,
|
|
4638
4638
|
int drop_ws, int keep_ent,
|
|
4639
4639
|
int dtd_attrs) {
|
|
4640
4640
|
/* Empty string counts as unset: MSVC's _putenv_s(k, "") (the
|
|
@@ -585,7 +585,7 @@ static void* pool_alloc_arena_extension(LeptrisMemoryPool* pool, size_t size) {
|
|
|
585
585
|
return ptr;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
void* leptris_pool_alloc(LeptrisMemoryPool* pool, size_t size) {
|
|
588
|
+
LEPTRIS_HOT void* leptris_pool_alloc(LeptrisMemoryPool* pool, size_t size) {
|
|
589
589
|
if (!pool || size == 0) return NULL;
|
|
590
590
|
|
|
591
591
|
/* Arena mode: parse-time allocations live in the one contiguous
|
|
@@ -696,7 +696,7 @@ void* leptris_pool_alloc_batch(LeptrisMemoryPool* pool, size_t item_size, size_t
|
|
|
696
696
|
/* Allocate a node struct + content buffer with the split-on-oversize
|
|
697
697
|
* behavior documented in the header (TODO 90 Phase 2b silent-drop
|
|
698
698
|
* bug fix). */
|
|
699
|
-
void* leptris_pool_alloc_node_with_content(LeptrisMemoryPool* pool,
|
|
699
|
+
LEPTRIS_HOT void* leptris_pool_alloc_node_with_content(LeptrisMemoryPool* pool,
|
|
700
700
|
size_t struct_size,
|
|
701
701
|
size_t content_size,
|
|
702
702
|
char** content_out) {
|
|
@@ -360,6 +360,9 @@ leptris_add_test(test_arena memory/test_arena.cpp)
|
|
|
360
360
|
leptris_add_test(test_doc_block memory/test_doc_block.cpp)
|
|
361
361
|
leptris_add_test(test_plan_leak memory/test_plan_leak.cpp)
|
|
362
362
|
leptris_add_test(test_synth_graveyard memory/test_synth_graveyard.cpp)
|
|
363
|
+
# #2306: the parse hot path's function starts are pinned (LEPTRIS_HOT);
|
|
364
|
+
# the attr-heavy parse row moved ~10% on code placement alone.
|
|
365
|
+
leptris_add_test(test_layout_pin memory/test_layout_pin.cpp)
|
|
363
366
|
leptris_add_test(test_interleaved parser/test_interleaved.cpp)
|
|
364
367
|
leptris_add_test(test_pool_arena memory/test_pool_arena.cpp)
|
|
365
368
|
leptris_add_test(test_mut_recycle memory/test_mut_recycle.cpp)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// test/memory/test_layout_pin.cpp — the #2306 code-placement gate.
|
|
2
|
+
//
|
|
3
|
+
// An attr-heavy parse's number is decided by the ADDRESSES of the code
|
|
4
|
+
// that runs, not only by its instructions: two binaries with
|
|
5
|
+
// instruction-identical parse loops differed by ~10% (417 µs vs 377 µs,
|
|
6
|
+
// paired interleaved) purely because whole-program LTO had placed the
|
|
7
|
+
// loops at different offsets. The default function alignment on these
|
|
8
|
+
// toolchains is 4 bytes, so every unrelated edit re-rolls every start
|
|
9
|
+
// address. LEPTRIS_HOT (src/leptris/common/port.h) pins the parse hot
|
|
10
|
+
// path to LEPTRIS_HOT_ALIGN bytes; this spec fails if the pin is lost.
|
|
11
|
+
//
|
|
12
|
+
// Only the exported half of the hot set is addressable from a spec --
|
|
13
|
+
// the parse loops and the attribute scan are static. They ride the same
|
|
14
|
+
// macro; this gate covers the two pool entry points that every parsed
|
|
15
|
+
// node allocates through.
|
|
16
|
+
|
|
17
|
+
#include <gtest/gtest.h>
|
|
18
|
+
|
|
19
|
+
#include <cstdint>
|
|
20
|
+
|
|
21
|
+
#include "leptris.h"
|
|
22
|
+
#include "pool.h"
|
|
23
|
+
#include "port.h"
|
|
24
|
+
|
|
25
|
+
namespace {
|
|
26
|
+
|
|
27
|
+
template <typename Fn>
|
|
28
|
+
uintptr_t addr_of(Fn fn) {
|
|
29
|
+
return reinterpret_cast<uintptr_t>(fn);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // namespace
|
|
33
|
+
|
|
34
|
+
TEST(LayoutPin, HotEntryPointsStartOnTheirBoundary) {
|
|
35
|
+
#if LEPTRIS_HOT_PINNED
|
|
36
|
+
EXPECT_EQ(0u, addr_of(&leptris_pool_alloc) % LEPTRIS_HOT_ALIGN);
|
|
37
|
+
EXPECT_EQ(0u,
|
|
38
|
+
addr_of(&leptris_pool_alloc_node_with_content) % LEPTRIS_HOT_ALIGN);
|
|
39
|
+
#else
|
|
40
|
+
GTEST_SKIP() << "this toolchain cannot place functions; the pin is a no-op";
|
|
41
|
+
#endif
|
|
42
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
|
|
3
3
|
"name": "leptris",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.462",
|
|
5
5
|
"description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
|
|
6
6
|
"homepage": "https://github.com/leptris/leptris",
|
|
7
7
|
"license": "MIT",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: leptris
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.462.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -607,6 +607,7 @@ files:
|
|
|
607
607
|
- vendor-src/libleptris/packaging/homebrew/leptris.rb
|
|
608
608
|
- vendor-src/libleptris/ports/leptris/portfile.cmake
|
|
609
609
|
- vendor-src/libleptris/ports/leptris/usage
|
|
610
|
+
- vendor-src/libleptris/scripts/ab_compare.py
|
|
610
611
|
- vendor-src/libleptris/scripts/check_dll_exports.py
|
|
611
612
|
- vendor-src/libleptris/scripts/check_export_surface.py
|
|
612
613
|
- vendor-src/libleptris/scripts/check_ffi_mirrors.py
|
|
@@ -1038,6 +1039,7 @@ files:
|
|
|
1038
1039
|
- vendor-src/libleptris/test/html/test_html_parse_errors.cpp
|
|
1039
1040
|
- vendor-src/libleptris/test/memory/test_arena.cpp
|
|
1040
1041
|
- vendor-src/libleptris/test/memory/test_doc_block.cpp
|
|
1042
|
+
- vendor-src/libleptris/test/memory/test_layout_pin.cpp
|
|
1041
1043
|
- vendor-src/libleptris/test/memory/test_mut_recycle.cpp
|
|
1042
1044
|
- vendor-src/libleptris/test/memory/test_oom_injection.cpp
|
|
1043
1045
|
- vendor-src/libleptris/test/memory/test_plan_leak.cpp
|