Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

Commit 6572a97

Browse files
piquark6046Copilot
andcommitted
docs(runner): document budgets and qualified pilot measurements
Explain automatic and explicit process-tree budgets, monitored enforcement and failure semantics. Record repeated code-lint timings, controlled concurrency, memory tradeoffs and remaining consumer validation limitations without claiming a default-branch speedup. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4661546 commit 6572a97

5 files changed

Lines changed: 243 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
### Added
66

7+
- Resource-aware lint execution with `--max-mem` in MiB, default eighty-percent
8+
observable availability, shared child admission and optional JSON profiles.
9+
- Literal argv batching and bounded asynchronous lint task supervision with
10+
explicit resource failures, cancellation cleanup and preserved engine status.
11+
712
- Explicit rule ownership and fallback reports, including native candidate
813
evidence and preserved consumer settings and file scopes.
914
- Requested-rule compatibility configurations and opt-in provider selection,

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ pnpm run check
2424

2525
`pnpm run check` is the acceptance gate. `pnpm run test` runs Vitest; `pnpm run test:coverage` also measures handwritten runtime code. Vendored implementations are checked by behavioral conformance tests and are excluded from the first-party coverage percentage.
2626

27+
The lint execution wrapper accepts `pnpm run lint -- --max-mem 8192` in MiB.
28+
Without an override it budgets eighty percent of observable available memory
29+
for the supervised command, including container constraints. See
30+
[resource-aware execution](docs/lint-execution.md) for profiling, shared child
31+
admission, platform visibility and the distinction between monitoring and a
32+
kernel-enforced memory limit.
33+
2734
## Consumer configuration
2835

2936
After installing the packages and the pinned Oxlint version with pnpm, create a complete configuration:

‎docs/lint-execution.md‎

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Resource-aware lint execution
2+
3+
The `ag-lint` executable and `@agcodeguidelines/oxlint-config/runner` subpath
4+
provide execution control without changing `createConfig()`, the configuration
5+
generator CLI, presets or rule ownership. Syntax-only execution needs neither
6+
an ESLint engine dependency nor the optional typed service.
7+
8+
## Invocation
9+
10+
```sh
11+
pnpm run lint -- --max-mem 8192
12+
pnpm run lint -- --max-mem=2048 --threads=1 --profile .cache/lint-profile.json
13+
pnpm exec ag-lint --max-mem 8192 --command node tasks/lint.mjs
14+
```
15+
16+
`--max-mem` accepts a positive integer in **MiB**. Missing, duplicate, fractional,
17+
negative, unsafe or unit-suffixed values are rejected. The wrapper consumes its
18+
own flags, including pnpm's forwarding separator; they are not sent to Oxlint,
19+
ESLint, Lerna or the compiler. A later literal `--` preserves option-looking
20+
filenames. The default backend is the installed supported Oxlint Node CLI;
21+
there is no hardcoded private Rust binary path.
22+
23+
Full root lint still uses the existing config and zero-warning contract.
24+
`lint:fix` is unchanged; parallel autofix is not introduced.
25+
26+
## Budget policy
27+
28+
At startup the wrapper computes effective observable availability from guest
29+
`MemAvailable`, meaningful platform/Node hints, and visible cgroup ancestor
30+
limits and their own current usage. It handles cgroup v1/v2 and namespace mount
31+
mapping, unlimited sentinels and soft `memory.high` pressure. Swap is not extra
32+
RAM budget. CPU admission also considers the visible quota and affinity count.
33+
34+
The automatic budget is the floor of **80% of effective available bytes**, in
35+
whole MiB. This is capacity for useful work, not a request to preallocate memory
36+
until the machine is 80% occupied. Explicit `--max-mem` replaces the automatic
37+
fraction and can be larger or smaller, but cannot exceed an observable hard
38+
ceiling. It does not reserve physical memory from other applications; current
39+
pressure can still prevent admission or terminate the run with a resource error.
40+
41+
The budget belongs to the **whole supervised command**, including its engines,
42+
workers, orchestration and caches. It is not assigned independently to each
43+
package or Node worker. Root commands create a temporary authenticated local
44+
coordinator. Participating package wrappers share reservations; nested work
45+
reuses its current package permit. Child options cannot raise the parent cap.
46+
Session sockets and permits are reclaimed at command completion/disconnection.
47+
Credentials are not included in profile JSON.
48+
49+
Thread reservations are conservative startup estimates, not per-thread hard
50+
limits. One useful small native task can run with a smaller reservation under
51+
active monitoring. A very large JS-provider profile may need more memory even
52+
with one thread; insufficient limits must fail rather than silently omit checks.
53+
54+
Visible VM RAM and container limits are honored. A guest cannot infer hidden
55+
physical-host constraints. Trusted launchers may provide
56+
`AG_LINT_HOST_LIMIT_MIB` and `AG_LINT_HOST_AVAILABLE_MIB`; without them the report
57+
states the visibility gap rather than probing outside its namespace.
58+
59+
## Enforcement and failures
60+
61+
Linux reports `monitored-process-tree`: the supervisor observes descendant RSS
62+
across Linux worker threads, restricts new work and terminates owned work on
63+
budget excess. This is **best-effort monitoring, not a portable kernel-enforced
64+
hard RSS limit**. Sampling can overshoot transiently and shared pages can be
65+
counted more than once. V8 old-space is not used as a substitute for total
66+
Node/native/process-tree memory. Existing pnpm/bootstrap memory before the
67+
supervisor starts is already reflected in available-memory observations, but is
68+
not claimed as an exact owned process-tree measurement.
69+
70+
On other platforms the report says `admission-only`; it does not pretend that
71+
parent RSS includes every child. Use an external OS/container memory scope when
72+
a strict physical bound is required. Rootless container tests use actual kernel
73+
cgroup limits in addition to the wrapper's monitored budget.
74+
75+
The wrapper preserves engine exit statuses, including lint violations (`1`).
76+
Invocation/spawn errors use `2`, resource/admission failures use `3`, and signals
77+
retain conventional statuses such as SIGINT `130`, SIGKILL `137` and SIGTERM
78+
`143`. Queued tasks have bounded idle-pressure admission waits, not an endless
79+
queue. Legitimate active work does not cause a false queue timeout. Cancellation
80+
terminates known owned process groups/descendants with escalation; Linux PID
81+
start identities protect against killing a reused PID. This is not a sandbox
82+
for adversarial programs that deliberately escape process ownership.
83+
84+
## Profiling
85+
86+
`--profile path.json` records the selected budget and sources, visibility
87+
warnings, sampled peak tree memory, engine resolution/execution timings, exit
88+
status and coordinator counts. Startup before module entry is not mislabelled
89+
as measured function time. Native child time is opaque initialization plus
90+
execution; Node CPU profiles alone cannot explain all native work.
91+
92+
The monorepo pilot separately records engine load, enumeration, effective-config
93+
calculation, grouping, fallback lint, native config I/O and spawn counts through
94+
`AG_LINT_TRACE_DIR`. Equivalent fallback overrides reuse an ESLint instance;
95+
ESLint still resolves each file's complete original config. Exact equivalent
96+
native runtime configs coalesce into argv-byte-safe batches. No arbitrary
97+
hundred-file split, dropped path, shell quoting or changed ignore policy is
98+
used to manufacture speed. Config memoization is read-only.
99+
100+
`scripts/benchmark.ts` keeps the previous manifest compatible and also accepts
101+
two or more safely named variants. `artifactsDirectory` streams complete raw
102+
stdout/stderr into artifacts instead of retaining large diagnostic buffers.
103+
Each variant may declare `resourceProfile` to attach its completed resource
104+
report to each sample. Separate tracing-on attribution runs from tracing-off
105+
timing comparisons. Full coverage, source/dependency parity and resource limits
106+
must match before claiming a speedup; a native subset is only a control.
107+
108+
## Verified limits and progress
109+
110+
Focused tests cover default80%, explicit overrides, nested cgroup headroom,
111+
soft pressure, sentinels, parser forwarding, impossible work, pressure recovery,
112+
long active tasks, cancellation, coordinator loss, child budget expansion,
113+
spawn/SIGKILL failure and cleanup of a detached child ignoring SIGTERM.
114+
Packed tarball tests exercise the public bin/subpath, TS5 declarations and
115+
pnpm symlink entry detection. No blanket lint or coverage exemptions are added.
116+
117+
Rootless Node22.12 containers with kernel limits512/1024/2048MiB complete the
118+
native fixture with automatic startup budgets around399/809/1628MiB and sampled
119+
owned peaks around55MiB. An explicit value one MiB over each hard ceiling is
120+
rejected before engine startup. These small-fixture results are not evidence
121+
that a full legacy JS-provider configuration fits512MiB or1GiB.
122+
123+
Paired single-run consumer stress attempts at1/2/4/8GiB are separate from the
124+
repeated timing study. With the result cache disabled, VPN fails explicitly
125+
at1GiB; at2GiB the current route fails and optimized completes in this sample;
126+
both complete at4/8GiB. The monorepo fails explicitly at1/2/4GiB and completes
127+
all14 chains at8GiB. Both optimized automatic80% lanes complete. These are
128+
observations, not minimum-memory guarantees: sampled RSS and current pressure
129+
vary. Cache-enabled stress attempts are not guaranteed primed after earlier
130+
failed or cache-disabled attempts. The1GiB monorepo root now rejects before
131+
starting Lerna rather than repeating a package admission timeout. Adapters
132+
report resource errors without an unhandled stack; external orchestrators such
133+
as Lerna can still aggregate a child's resource exit into their own exit1.
134+
135+
The final packed-runtime check executes the installed `ag-lint` bin with an
136+
explicit512MiB budget and verifies its JSON report on Node22.12.0,
137+
pnpm10.33.4 and TypeScript5.9.3. The shared acceptance gate passes45,513 tests;
138+
VPN full lint/type checks and1,017 tests pass (one throttle timing failure
139+
passed both isolated and full-suite retries), and all14 monorepo full lint
140+
chains pass. Browser's public5.x ruleset test profile passes lint/type checks,
141+
but retains ten CWS diff-parser test failures; it does not validate private6.x
142+
ruleset compatibility.
143+
144+
Consumer pilots and public ruleset substitutions are provisional local tests;
145+
absolute local tarball overrides are not a CI-ready distribution mechanism.
146+
Use exact approved package builds before publication/rollout. See
147+
[performance acceptance](performance.md) for the whole-command protocol and
148+
[consumer compatibility](compatibility.md) for unchanged fallback obligations.

‎docs/performance.md‎

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,66 @@
11
# Lint performance acceptance
22

3-
## Current evidence
3+
## Resource-aware pilot measurements
4+
5+
An isolated Linux guest comparison on 2026-10-15 used Node22.12.0,
6+
pnpm10.33.4, Oxlint1.82.0 and the same exact
7+
`0.1.0-review.20261015.5` SDK tarballs in paired disposable installations.
8+
Every variant ran under the same8192MiB monitored process-tree envelope.
9+
Ten cold and ten warm samples per variant were interleaved, with three warmups
10+
and separate result caches. Cold disables ESLint's result cache; host page cache
11+
is uncontrolled. Builds and tests did not run concurrently with measurement.
12+
13+
Times below are whole **code-lint** commands, including orchestration, discovery
14+
and engine startup, not native-only subsets. Type checking and Markdown owners
15+
passed separate full-lint gates, but are not included in these timings.
16+
The monorepo includes all14 original code chains (12 targets and two API
17+
examples), without adding builder lint. Its ESLint/current baselines explicitly
18+
use four-way concurrency; the optimized route selects seven at this budget.
19+
Four is a controlled comparison setting, **not Lerna's installed default**.
20+
These numbers do not establish a repeated-sample gain over default concurrency.
21+
22+
| Consumer / Cache | Full ESLint Median | Current Hybrid Median | Optimized Median | Optimized P25-P75 | Change vs Current |
23+
| --- | ---: | ---: | ---: | ---: | ---: |
24+
| VPN cold | 12,803ms | 13,036ms | 12,785ms | 12,717-12,886ms | -1.9% |
25+
| VPN warm | 1,135ms | 1,344ms | 1,075ms | 1,072-1,083ms | -20.0% |
26+
| Monorepo cold | 17,883ms | 18,473ms | 14,728ms | 14,491-14,926ms | -20.3% |
27+
| Monorepo warm | 5,354ms | 5,796ms | 4,814ms | 4,755-4,878ms | -16.9% |
28+
29+
VPN cold is essentially equal to full ESLint, with overlapping distributions;
30+
it is not a substantial cold-start improvement. VPN warm improves5.2% over
31+
full ESLint in this run. Monorepo improvements over its four-way full ESLint
32+
baseline are17.6% cold and10.1% warm. The added resource controls and complete
33+
fallback work remain in the timed command.
34+
35+
The monorepo trades memory for throughput. Maximum sampled tree RSS across
36+
the ten cold samples rises from5362MiB (current) to7161MiB (optimized);
37+
warm peaks rise from2817MiB to4043MiB. VPN cold peaks are2226/2168MiB and
38+
warm peaks469/415MiB, respectively. RSS summation can double-count shared
39+
pages and sampling can miss transients; these are not kernel memory peaks.
40+
41+
Separate tracing runs cover1083 files across the same14 packages in both
42+
monorepo lanes. Effective groups remain16; native child launches fall from19
43+
to13. Summed discovery time is approximately7.0s/7.1s and fallback time40.4s
44+
in each lane: discovery was not eliminated. These overlapping package times
45+
must not be summed as exclusive wall time. Native initialization plus execution
46+
totals857ms/628ms; it is not an isolated measurement of rule cost.
47+
48+
Startup controls on one valid fixture measured approximately9.8ms for Node,
49+
136.6ms for pnpm-exec plus Node,26.1ms for native Oxlint and127.8ms with the
50+
JS compatibility provider (cold medians). These are separate initialization
51+
controls, not full-coverage speedups inferred by subtracting medians.
52+
An additional actual-default monorepo cold smoke completed in45.4s (ESLint)
53+
and46.8s (current hybrid) under8192MiB. These are single supervised-task times,
54+
not a substitute for the repeated four-way comparison above.
55+
56+
Raw manifests, all samples, min/max and P25/P75, full stdout/stderr and per-sample
57+
resource profiles are retained locally under
58+
`.cache/invocation-study/final/`. The earlier VPN run with shared caches was
59+
discarded from acceptance, not combined with these samples. Original consumer
60+
checkouts were not changed. Absolute local tarball overrides remain test-only
61+
and must not be committed or used as a release mechanism.
62+
63+
## Historical evidence
464

565
The initial consumer PR integrations transferred only `no-debugger`,
666
`no-duplicate-case` and `no-sparse-arrays` through `ag-compat`. Their recorded
@@ -13,18 +73,17 @@ single warm samples were slower, not statistically reliable speed measurements:
1373
| tsurlfilter logger only | 937 ms | 1,832 ms |
1474

1575
These are task-brief results for build `0.1.0-build.11600659`, not reruns of the
16-
new code. No complete representative-consumer performance result is claimed.
17-
The local reference checkouts have neither installed dependencies nor the PR
18-
hybrid integration. The benchmark harness unit test measures synthetic child
19-
processes only and is not adoption evidence.
76+
new code. The resource-aware measurements above are a separate experiment,
77+
not a reinterpretation of these samples. The benchmark harness unit test
78+
measures synthetic child processes only and is not adoption evidence.
2079

2180
Native-only requested configurations now omit JavaScript providers; existing
2281
mutable presets intentionally keep their old registration behavior. This
2382
removes one possible cost, not the second ESLint parse or config discovery.
2483
The three native candidates also have recorded diagnostic differences. Benefits
2584
are explicit ownership and bounded startup work; costs include migration,
2685
diagnostic differences and a remaining complete fallback pass. No speedup or
27-
production rollout is accepted on these changes alone.
86+
production rollout is accepted on these historical changes alone.
2887

2988
## Reproducible protocol
3089

‎packages/oxlint-config/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
## Incremental Compatibility
44

5+
### Resource-aware execution
6+
7+
The separate `ag-lint` executable accepts `--max-mem <MiB>` or
8+
`--max-mem=<MiB>`, plus optional `--profile report.json`. The default budget is
9+
eighty percent of observable available memory; explicit values replace that
10+
policy but cannot exceed a visible system/container hard limit. Use
11+
`pnpm run lint -- --max-mem 8192` when a project routes its lint script through
12+
this CLI. Wrapper arguments never reach the selected engine.
13+
14+
The `./runner` subpath exports budget probing, argument parsing, literal argv
15+
batching, async task supervision and command-local shared admission. Nested
16+
packages share one root budget rather than independently claiming eighty
17+
percent. The default engine is the installed Oxlint; `--command executable`
18+
supervises an existing lint orchestration command without replacing its checks.
19+
Linux RSS control is monitored/best-effort, and other platforms explicitly
20+
report admission-only behavior. Neither V8 heap size nor this wrapper is a
21+
portable kernel hard cap; use an OS/container scope for strict enforcement.
22+
523
`createCompatibilityConfig({ rules, language, context, ignorePatterns })`
624
translates one already resolved effective source configuration group. It returns
725
`config`, `ownership` and `fallback`; it never activates the shared preset.

0 commit comments

Comments
 (0)