Repository navigation
test: fix allocator-sensitive memory assertion that broke the valgrind nightly (#222) - #223
Conversation
…d nightly The secondary assertion in tests/string_to_entry_delete_range_001.phpt measured a memory_get_usage() delta around deleteRange() and required it to be > 0. Under valgrind memcheck the delta came out 0: freed zvals land on the Zend MM freelist, and memory_get_usage() does not reliably drop, while the Judy trie (and its held zvals) is invisible to it entirely. The nightly valgrind job failed its first post-#217 run on this (issue #222), even though the primary leak assertion -- __destruct fires 1000/1000 -- passed and valgrind reported 0 definite leaks. Replace the reading with Judy::memoryUsage(), the extension's own string-keyed accounting (approx_payload_bytes), which deleteRange() decrements by every confirmed removal and which is independent of the allocator: 38000 -> 0 deterministically on this test. Test identity (--TEST-- title, file name) is unchanged, so the test-floor ratchet baseline in reports/junit.xml still matches.
discipline: passedBase
|
Test Results
Benchmark Results
Run Status
Memory (Linux, PHP 8.6)Peak RSS of a child process building one structure, n = 500,000, minus an empty-process floor. Judy's memory advantage is type- and scale-dependent — see BENCHMARK.md for the curve across sizes on a dedicated host.
API Speedups (Linux, PHP 8.6)Speedup = PHP time / Judy time. Bold = Judy faster.
Core Types (Linux, PHP 8.6)Speedup = PHP time / Judy time. Bold = Judy faster.
All types detailCore Types (Linux, PHP 8.6) — AllSpeedup = PHP time / Judy time. Bold = Judy faster.
Cross-version detail (Linux)Core Types — LinuxEach cell: Judy ms (speedup vs PHP array).
API — Linux
Cross-version detail (Windows)Core Types — WindowsEach cell: Judy ms (speedup vs PHP array).
API — Windows
Windows results (PHP 8.5)Memory (Windows, PHP 8.5)Peak RSS of a child process building one structure, n = 500,000, minus an empty-process floor. Judy's memory advantage is type- and scale-dependent — see BENCHMARK.md for the curve across sizes on a dedicated host.
API Speedups (Windows, PHP 8.5)Speedup = PHP time / Judy time. Bold = Judy faster.
Core Types (Windows, PHP 8.5)Speedup = PHP time / Judy time. Bold = Judy faster.
All types detailCore Types (Windows, PHP 8.5) — AllSpeedup = PHP time / Judy time. Bold = Judy faster.
Release Comparison (2.6.0 → 2.7.1)
Summary: 0 regressions, 83 unchanged, 17 not evaluated (unstable)
17 benchmarks not evaluated (within-arm scatter exceeded the effect being claimed)
Memory ComparisonMemory: 0 regressions, 10 unchanged
Full benchmark outputLinux — PHP 8.6Windows — PHP 8.5 |
What
Fixes the failure behind issue #222: the nightly valgrind memcheck job failed its first post-#217 run on
tests/string_to_entry_delete_range_001.phpt.Root cause
The test's secondary assertion measured a
memory_get_usage()delta arounddeleteRange()and requireddelta > 0:Under valgrind memcheck the delta was 0 (
no(0)). Freed zvals land on the Zend MM freelist, somemory_get_usage()does not reliably drop; and the Judy trie plus the zvals it holds are invisible tomemory_get_usage()either way (AGENTS.md, "Debugging and profiling Judy code"). This is the same trap the repo documents — the test happened to be stable on the non-valgrind PR runs, then broke under the nightly's memcheck allocator.The primary leak assertion is what actually matters and it passed:
__destruct fired: 1000/1000(the pre-#217 bug leaked the entry struct + refcount and never ran the destructor). Valgrind itself reported 0 definite leaks.Fix
Swap the secondary measurement to
Judy::memoryUsage()— the extension's own string-keyed accounting (approx_payload_bytes), whichdeleteRange()decrements by every confirmed removal and which is independent of the allocator:38000 -> 0on this test (1000 entries)memoryUsage()overmemory_get_usage()for Judy memoryThe test identity (
--TEST--title and file name) is unchanged, so the test-floor ratchet baseline inreports/junit.xmlstill matches exactly (verified: 258/258 IDs identical, 0 dropped, 0 added).Validation
make test TESTS=tests/string_to_entry_delete_range_001.phpt)reports/junit.xmlbaselinediscipline check --base origin/main: PASS (27 gates, 0 errors, 0 warnings)