docs: memoryUsage() documentation and memory patterns benchmark#47
docs: memoryUsage() documentation and memory patterns benchmark#47
Conversation
Add a new section to BENCHMARK.md documenting Judy::memoryUsage() behavior per type (which types return int vs NULL, why, and how it works internally). Include guidance on when Judy saves memory vs when PHP arrays win, with concrete examples for sparse keys, dense counters, and bitset tracking. Add examples/judy-bench-memory-patterns.php benchmark script comparing Judy vs PHP arrays for memory footprint at 1K-1M elements (INT_TO_INT, BITSET), insertion throughput, and sparse key scenarios.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the understanding of Judy array memory management by providing detailed documentation for the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Test Results
Benchmark Summary (Judy vs PHP Array)Ratio = Judy / Array. Bold = Judy wins (≤0.95x). Plain = Array is faster/smaller. Time (Write / Read) — Linux
Memory — Linux
Time (Write / Read) — Windows
Memory — Windows
Raw benchmark dataWrite Time — Linux
Read Time — Linux
Memory — Linux
Write Time — Windows
Read Time — Windows
Memory — Windows
Batch & Set Operations BenchmarksBenchmarks for Batch Operations — PHP 8.5 (Linux)Set Operations — PHP 8.5 (Linux) |
There was a problem hiding this comment.
Code Review
This pull request adds valuable documentation for Judy::memoryUsage() and a new benchmark script to compare memory usage patterns between Judy and PHP arrays. The documentation is clear and the benchmark script is well-structured. I have two suggestions for improvement: one to clarify a point in the documentation and another to refactor some duplicated code in the new benchmark script for better maintainability.
…put code - Reword "allocates a full hash table" to avoid mischaracterizing PHP array behavior for sparse keys - Extract run_throughput_bench() helper to eliminate duplicated INT_TO_INT / BITSET / STRING_TO_INT printing blocks - Update file header comment to reflect that STRING types are only in throughput section, not memory footprint
Summary
Judy::memoryUsage()" section toBENCHMARK.md— documents return values per type (int for BITSET/INT_TO_INT/INT_TO_MIXED, NULL for STRING types), explains the internal O(1) mechanism (JPM TotalMemWords counter), and provides guidance on when Judy saves memory vs when PHP arrays winexamples/judy-bench-memory-patterns.php— benchmark script comparing Judy vs PHP arrays at 1K–1M elements for INT_TO_INT, BITSET, and STRING_TO_INT insertion throughput, with sparse key memory comparisonmemory_get_usage())Phase 2 of the plan from #43.
Test plan
php examples/judy-bench-memory-patterns.phppecl package package.xmlproduces valid .tgz