Developer-Dashboard

 view release on metacpan or  search on metacpan

doc/problem-48-performance-research.md  view on Meta::CPAN

metadata is still checked on every stable request. The focused Docker suites
pass 87 assertions, including malformed path-map recovery, file replacement,
inventory mutation, and missing-root cases.

For route-level impact, a 21-sample paired Docker run compared the production
path cache with an uncached control that discarded only the path-string map.
Each sample made 100 requests with 50 collectors; every route returned the
same 12,414-byte body. Median time changed from 72.341 ms per 100 requests to
66.347 ms (1.09x). This is a small incremental route gain, not an improvement
over v5.88 and not evidence for the full per-subroutine 50x objective.

Follow-up cache tests also cover absent and stale signatures and reject
malformed path lists. The full Docker coverage gate was rerun after these cases:
277 files and 23,938 tests passed, with statement, branch, condition, and
subroutine coverage all at 100.0% (48,462 detail rows; no stale uncoverable
annotations). This confirms coverage for the current tree; it does not change
the 1.09x route result or the still-open all-subroutine 50x objective.

After the gate, the `perldoc perlsec` frontend could not load a formatter in the
dev image, so the installed core `perlsec.pod` was read directly. The required
web security regression set passed 466 assertions across `t/08`, the static-file
suite, and `t/17`; repository scans were also run in Docker using `grep` because
the dev image does not contain `rg`.

## Saved-page profile and dashboard-root cache candidate rejected (2026-10-15)

A disposable Docker NYTProf run profiled 110 warm requests through the actual
`Web::App->handle('/app/welcome')` saved-page route with five saved nav
fragments. Each response returned 200, retained the page title and dynamic
stash marker, and measured 9,882 bytes. The profile attributed 11.068 ms over
1,540 executions (about 7.2 microseconds/execution under instrumentation) to
the `dashboards_roots` mapping statement. This identifies repeated path-list
construction, but does not imply the same wall-clock cost.

A red-first regression showed that the mapping statement ran twice for two
lookups within an explicit request scope. A request-local cache candidate made
it run once; focused Docker tests for PathRegistry, Web::App, and DancerApp
passed 813 assertions, including per-request cleanup and preservation of the
explicit bookmark-root override's directory-ensuring behavior. The paired
route benchmark then compared the candidate against the original implementation
over 21 alternating samples of 100 requests each, normalizing only the live
datetime field. Both paths returned equivalent route content; median latency
was 1.2397 ms/request uncached and 1.2368 ms/request cached (1.00x). Because
this is no meaningful end-to-end gain, the candidate and its tests were
removed. No dashboard-root cache is retained in production. The 50x target
remains open.

## Stable status validation path-join reuse (2026-10-15)

After validated response reuse, a source-bound NYTProf profile showed two
status-path joins for every discovered indicator: the directory-inventory
validation checked that each candidate file was in the persistent signature
cache, then active-collector validation rebuilt and checked the same paths.
The red-first Docker test reproduced 24 `File::Spec->catfile` calls for 12
entries. The validator now records whether each discovered name has a present
status file during its first pass and reuses that result for active jobs. It
still stats every cached candidate using the same high-resolution signature,
so external updates remain visible; it does not trade away freshness.

The focused Docker tests pass with exactly 12 joins for 12 fixture entries.
The matched 50-collector endpoint returned byte-identical 12,687-byte bodies
and measured 34.307 ms/request on v5.88 versus 0.437 ms/request on current
source (78.50x) across 31 samples. This is a route-specific measurement, not
evidence for the requirement that every subroutine improve by at least 50x.
The full Docker coverage gate passed statement, branch, condition, and
subroutine totals at 100.0% (48,438 detail rows, with no stale uncoverable
annotations). After that gate, `perldoc perlsec` rendered successfully and the
required web/security regression set passed 622 assertions across four files.

Security applicability review: V1, V7, V12, and V13 were relevant. The change
retains the existing filesystem roots and high-resolution signatures, closes a
directory handle on a read error, and reports close failures; the response is
reused only after freshness validation. No route, auth/session, input,
cryptographic, network, command-execution, or configuration behavior changed,
so V2-V6, V8-V11, and V14 were not newly applicable. The all-subroutine Problem
48 objective, packaging, image, and delivery gates remain open.

## Indicator ordering experiment (2026-10-14)

An isolated Docker sort benchmark compared the existing comparator, which
repeated method dispatch and hash lookups on every comparison, with a
decorate-sort-undecorate implementation. Coverage-driven direct tests were
added for each priority, collector-order, and name-fallback condition. In 30
alternating pairs on identical 5,000-record inputs, the final sort measured
16.240 ms for the legacy comparator and 10.763 ms for decorated sorting (1.51x)
with exact order parity. The optimized path applies at 32 or more records;
smaller lists retain the shared comparator.
Coverage reruns showed Perl's sort comparison schedule did not reliably
exercise every short-circuit pair. The tuple comparison is now a small private
function with direct deterministic tests for priority, two-collector ordering,
equal-order names, and mixed/unmanaged name fallbacks.

The complete two-layer listing benchmark, which also includes filesystem
discovery and file reads, measured 1.04x at 50 records, 1.14x at 1,000, and
1.06x at 5,000, with exact canonical JSON parity. The isolated sort gain does
not translate into a comparable end-to-end gain. Problem 48's all-subroutine
50x target remains open.

The final clean Docker coverage gate for this sort iteration passed 272 test
files / 23,628 tests, with 100.0% statement, branch, condition, and subroutine
coverage across `lib/` (47,832 detail rows and no stale uncoverable
annotations). Post-gate perlsec, the required 459-assertion web-security test
set, and changed-file syntax/POD checks passed. This verification does not
change the performance conclusion above.

## Required target

The objective is to accelerate every dashboard subroutine using MCE,
FFI::Platypus, Inline::C, XS, SPVM, Memoize, Perl's built-in `class` / `method`
and `field` syntax, and method/subroutine signatures, with a minimum 50x speedup
against Developer Dashboard 5.88. This investigation retains that full target;
it distinguishes measured results from unproven claims. Behavior, security,
output, authentication, and process-order contracts must remain unchanged.

## What the technologies do

`MCE` runs independent work in worker processes or threads; it cannot make an
arbitrary sequential subroutine parallel. `FFI::Platypus` binds typed native
functions and must handle ABI, integer widths, buffers, library lookup, and
platform availability explicitly.

doc/problem-48-performance-research.md  view on Meta::CPAN

87.3/79.3/75.5/91.8% for `PathRegistry.pm`, and 96.4/91.6/93.1/96.8% for
`Web/App.pm`. These are focused-run measurements, not whole-library coverage;
the canonical full-coverage gate must be rerun in a clean Docker Git/network
environment before claiming the gate passes.

### Saved-page profile reinspection (2026-10-15)

The retained NYTProf line reports were re-read after the worker-cache changes.
Across the 110-request profile, `PathIdentity::_path_identity` was entered 1,030
times and accounted for 7.634 ms instrumented line time; indicator ordering
accounted for 3.762 ms across 110 calls, and legacy CODE-section ordering for
4.457 ms across 550 comparator calls. These profiler totals are useful for
ranking repeated work, not uninstrumented latency estimates. Path identity
already has request-local exact-spelling reuse, and the earlier FFI realpath
experiment produced only parity at the complete path-alias API level. The
remaining candidate gains are therefore small against the measured 0.497 ms
route median and do not justify weakening filesystem freshness or portability.
No additional production optimization was selected from this trace. The next
optimization must be driven by an isolated representative route profile and
paired wall-clock benchmark; the full 50x objective remains open.

### Cross-request Template service reuse rejected (2026-10-15)

A Docker experiment tested reusing one Template Toolkit service while forcing
`STAT_TTL => -1`, then rewriting an included template and restoring its exact
mtime before the next process call. The reused service returned the old
content (`first`); a newly constructed service returned the edited content
(`second`). Thus even aggressive provider stat refresh does not preserve the
existing immediate-freshness contract for same-mtime edits. No production
change was made; any future service-reuse candidate must explicitly refresh
the provider cache without weakening this behavior and show a paired latency
gain first.

### Numeric CODE-section sorting candidate rejected (2026-10-15)

The retained route profile showed numeric CODE-section sorting as repeated
work, so an isolated Docker comparison measured the existing regex comparator
against extracting each numeric suffix once before sorting. Both produced
identical order for 5 and 1,001 sections across 31 alternating samples. The
decorated version was 1.31x at 5 entries but 0.95x at 1,001; the common-case
absolute saving was about one microsecond per sort, while large documents
regressed. No production change was made because the result does not justify a
special-case branch for negligible route benefit.

### FFI path identity on the saved-page route rejected (2026-10-15)

The earlier 1.59x isolated FFI `realpath` result was rechecked through the
actual saved-page handler, with the existing request-local exact-path cache
left enabled. In 21 alternating Docker pairs, baseline median latency was
1.657 ms and the FFI variant was 2.072 ms (0.80x baseline/candidate, or about
25% slower). Both returned 9,573-byte bodies; their SHA-256 matched after
normalizing the live datetime field. FFI call and allocation overhead erased
the isolated helper gain on this request, so no production change was made.

### Collector-backed status route profile (2026-10-15)

Expected outcome: repeated `/system/status` requests with unchanged collector
configuration should compare each persisted indicator once per synchronization,
return byte-identical response data, and observe disk changes on the next
request. Reproduction: in an isolated HOME, seed 50 collector indicators, warm
the endpoint once, then profile 100 `Web::App->handle('/system/status')`
requests with NYTProf enabled only around the request loop. The Docker profile
returned HTTP 200 and a 12,687-byte body on every request. Before the fix it
recorded 5,000 calls to `_collector_sync_plan`, 15,000 calls to
`_read_indicator_file`, and 15,100 calls to `PathRegistry::indicators_roots`;
`sync_collectors` had 2.40 seconds inclusive profile time over the 100 calls.
The root cause was that each collector sync separately resolved the same roots
for effective state, local state, and final inventory, then decoded each file
again at each lookup.

The first Docker regression run was red: a 12-indicator steady-state sync
resolved roots 37 times instead of once. The implementation now gives one
`sync_collectors` call a roots snapshot and decoded-file cache; the final
inventory reuses both. Writes and deletions invalidate their entries, and the
cache ends at sync return. Tests verify one root resolution and one physical
read per file, next-sync visibility of changed state, and correct listing after
collector retirement. The focused Docker suites passed 229 assertions.

On the same 50-collector `/system/status` workload, 15 alternating unprofiled
Docker pairs measured 9.203 ms/request before and 2.689 ms/request after
(3.42x), with exact response-byte parity. Both variants returned HTTP 200 and
12,687 bytes. In the request-scoped NYTProf recheck, physical status-file reads
fell from 15,000 to 5,000, indicator-root resolutions from 15,100 to 100, and
`sync_collectors` inclusive time from 2.40 s to 513 ms across 100 calls. These
figures establish a collector-heavy route gain, not a 50x improvement for all
subroutines; Problem 48 remains open.

### Single-root collector lookup follow-up (2026-10-15)

The initial follow-up profile was first read from the installed `/root/perl5`
copy rather than this checkout, so it was not valid evidence for the source
changes. The profile was rerun in Docker with `/work/lib` explicitly first in
`@INC`; it confirmed the checked-out implementation performs 101 root
snapshots across 100 requests, not 15,100. Its repeated local-state and
inherited-state reads were therefore not the remaining source bottleneck.

In the collector plan, the effective indicator lookup already reads the only
possible root when the snapshot has one entry. The local lookup then repeated
that work, and a placeholder-missing record caused an inherited lookup even
though there was no inherited root. A red-first test counted both calls across
12 indicators and failed before the change (12 local plus 12 inherited calls).
The planner now reuses the existing record for the single-root case and skips
the impossible fallback. Multi-root behavior remains unchanged. The focused
Docker regression passes all 10 assertions and still verifies fresh disk state
on the next sync and correct collector retirement.

The matched 50-collector Docker status workload retained exact 12,687-byte
responses and measured 7.708 ms/request for the legacy strategy versus 2.195
ms/request for current source (3.51x). The correctly source-bound NYTProf
profile showed `_local_indicator` and `_nearest_inherited_indicator` were not
called in the one-root workload. `_collector_sync_plan` remains a leading
inclusive cost, and one physical read per persisted indicator is retained to
preserve cross-process freshness. This is a narrow incremental gain; the
all-subroutine 50x goal remains open.

### Direct v5.88 status-route comparison (2026-10-15)

To verify progress against the named baseline rather than only against a
current-source compatibility strategy, the same `/system/status` workload was
run against the preserved v5.88 tree and the checkout in the same Docker image.
Each run used an isolated HOME, 50 configured collectors, the same request

doc/problem-48-performance-research.md  view on Meta::CPAN

delete, and move events); queue overflow remains delivered independently of the
mask. The paired Docker benchmark in
`script/problem48-indicator-watch-benchmark` then ran 21 alternating samples,
100 calls per sample, and exact inventory comparisons. The stable helper
measured 0.001600 ms per call with inotify versus 0.256500 ms with the portable
validator (160.33x). The same run verified an external status write invalidated
the watcher and appeared in the next full sync. The latest native-enabled
focused tests pass 116 assertions across the adapter and store integration,
including real Linux inotify writes and visible fallback warnings. All five
focused Problem 48 files pass 210 tests. This helper-level result is not a
direct v5.88 or whole-dashboard comparison.

This clears 50x for the stable `_collector_sync_files_unchanged` workload
versus its pre-watch portable validator at 50 indicators on the tested Linux
Docker runtime. It is not a direct v5.88 component comparison and does not
establish 50x for other routines, platforms without inotify, changed-state
reconciliations, or the whole dashboard. The Problem 48 all-subroutine target
remains open.

### Inotify FFI feasibility probe and profiler workload rejection (2026-10-15)

A fresh isolated Docker `dev` run installed and tested FFI::Platypus 2.12, then
bound libc `inotify_init1` and `inotify_add_watch`. With one directory watch,
10,000 nonblocking `IO::Select->can_read(0)` polls averaged 0.000941 ms each;
creating a file in the watched directory produced a readable 128-byte event
record. This confirmed that an optional Linux event source was technically
available, but that first probe did not test queue overflow, watcher
replacement, concurrent status-file writes, watch-limit exhaustion, or
end-to-end dashboard latency. Those gaps were addressed by the later integrated
adapter, event-invalidation tests, and paired stable-sync benchmark above.

A separate attempt to use NYTProf around all of `t/03-web-app.t` was rejected
as route evidence. That test includes subprocess setup, helper-account PBKDF2,
and many unrelated routes; the instrumented run exited with six assertion
failures while the ordinary Docker run passed all 355 assertions. The profile
was dominated by test setup and password hashing, and report generation on the
host emitted source-path warnings because the profile came from the container.
Those measurements are not used to select or claim an optimization. A next
profile must isolate one stable request path, validate its response parity,
and avoid timing-sensitive assertions under instrumentation. Problem 48's
50x-per-subroutine target remains open.

### Full Docker coverage rerun after config-merge closure (2026-10-15)

`d2 docker compose exec dev perl script/coverage-gate` completed successfully:
281 test files and 24,151 tests passed; statement, branch, condition, and
subroutine totals were all 100.0% (48,963 detail rows, no stale uncoverable
annotations). The malformed-ZIP tests emitted their expected parser diagnostics
while passing. The container's `perldoc perlsec` command exited 13 because no
POD text formatter is installed; the full core `perlsec.pod` source was read
directly in three consecutive ranges. This closes the current coverage gate,
not the all-subroutine 50x performance objective or remaining delivery gates.

### Matched status-route rerun and current NYTProf call tree (2026-10-15)

The production-boundary benchmark was rerun with 50 synthetic collectors,
100 requests per sample, and 21 samples against both the v5.88 tree and the
current source. Both returned HTTP 200 and byte-identical 12,864-byte bodies
(SHA-256 `da887f795a1b16c65b1c3b8d54a7e390425b1dd0b19731cac0b437dd95d9ac68`).
Median latency was 72.415810 ms/request on v5.88 and 0.249081 ms/request on the
current source (290.73x for this endpoint and fixture only). Run-to-run variance
means this is a refreshed measurement, not an incremental gain attributed to
the config-merge follow-up.

A current-source NYTProf run profiled only the warmed 500-request loop and kept
the same body hash. The instrumented request median was 1.313282 ms; it is not
a wall-clock performance figure. The largest application source-line totals in
the generated CSV were JSON decode (22.703 ms / 500 calls), JSON encode
(15.320 ms / 1,000 calls), indicator projection (10.122 ms / 25,000 entries),
and `dispatch_request` (9.960 ms / 500 calls). Path discovery and secure
runtime metadata checks also recur on the request path. These results identify
different costs rather than a single universal accelerator; no code change is
justified by the trace alone, and the all-subroutine 50x target remains open.

The same NYTProf invocation was run for 100 warmed requests against v5.88 and
current source. Both profiles returned the same body hash. Under instrumentation,
v5.88 measured 169.546802 ms/request and current source 1.108379 ms/request
(152.97x); this is profiler-bound evidence, not a production latency ratio. The
line reports show the principal call-count change: `abs_path` was called
808,400 times in v5.88 versus 400 times currently (2,021x fewer), and the old
trace made 100,800 `getpwuid` calls while the current trace had no such call.
On the same 100-request workload, JSON decode fell from 20,000 calls to 100,
and JSON encode from 25,300 calls to 200. This traces the route-level gain to
eliminated repeated discovery/serialization work, but it still says nothing
about uncalled routines or every routine's independent speedup.

### Parsed-config clone cache candidate rejected (2026-10-15)

The current profile shows one JSON decode per request for the merged global
config. To test whether a metadata-validated parsed-tree cache could avoid that
work without sharing mutable config objects, an isolated Docker probe compared
`JSON::XS` decode with cloning a cached decoded tree using core `Storable::dclone`.
The 8,504-byte, 50-collector fixture preserved canonical JSON exactly. Across
21 alternating rounds of 5,000 operations, median decode time was 240.356 ms
and median clone time was 348.680 ms; cloning was only 0.69x as fast. This
candidate is rejected: it would add cache invalidation and ownership complexity
while making config reconstruction slower. The current request-fresh config
read remains unchanged.

### Bounded state-metadata JSON scalar reuse (2026-10-15)

NYTProf showed one state-metadata JSON encode on each identical status request.
A red-first Docker regression in `t/97-pathregistry-coverage.t` failed because
two identical metadata calls invoked `json_encode` twice, and also required a
changed runtime root or application name to regenerate the correct payload.
`PathRegistry` now keeps one encoded scalar for the latest exact pair. It does
not cache parsed data or filesystem trust: every call still creates/hardens the
directory as needed, performs `lstat`, rejects symlinks/non-files/foreign owners,
requires mode 0600 for reuse, opens and reads the existing bytes, and rewrites
stale state visibly. The test passes all 318 assertions, including key changes,
exact JSON contents, and a defined-name request rejecting an undefined-name
cache entry. Malformed cache entries lacking required encoded fields are
treated as misses rather than producing an uninitialized-value warning.

The warmed 50-collector status route preserved the exact 12,864-byte response
hash. Its current median was 0.247939 ms/request versus 0.249081 ms in the
preceding run; this difference is within noise and no route gain is claimed.
The optimization removes one encode operation when the same state identity is
revisited, but does not establish the all-subroutine 50x objective.

The clean Docker coverage gate was rerun after this change. All 281 test files



( run in 1.072 second using v1.01-cache-2.11-cpan-eb134014566 )