Conversation
There was a problem hiding this comment.
Pull request overview
Adds an admin-only getMemoryStats query endpoint to the registry canister to report runtime RTS memory metrics and per-data-structure {count, bytes} estimates (via Candid serialization sizing) for storage overhead analysis.
Changes:
- Extended the public Candid interface with
StructureStats,MemoryStats, andgetMemoryStats. - Implemented
getMemoryStatsin the main canister, including RTS heap/memory metrics and per-structure aggregation. - Added internal
getMemoryStatshelpers toDownloadLog,StorageManager, andUsersto report their respective structure stats.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/declarations/main/main.did | Adds StructureStats/MemoryStats types and the getMemoryStats service method. |
| backend/main/main-canister.mo | Implements the admin-only query and aggregates stats across in-canister structures and submodules. |
| backend/main/DownloadLog.mo | Adds stats computation for download maps, snapshot buffers, and temp records. |
| backend/storage/storage-manager.mo | Adds stats computation for storage maps. |
| backend/main/Users.mo | Adds stats computation for the users map. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Change getMemoryStats from query to update to avoid hitting query instruction limits when serializing all entries via to_candid - Bump API_VERSION to 1.4 in backend and CLI (paired change) - Update cli/declarations/main/main.did.js and main.did.d.ts with StructureStats and MemoryStats types, and getMemoryStats method - Add unit tests for getMemoryStats in test/users.test.mo and test/download-log.test.mo Made-with: Cursor
Replace full-iteration to_candid calls with a systematic sample of up to 10,000 entries per data structure. The sampled byte total is extrapolated linearly (sampleBytes * total / sampled), so the result remains a useful approximation while keeping allocations bounded regardless of registry size. Made-with: Cursor
Sampling keeps to_candid calls bounded to ~10,000 per structure, so query instruction limits are no longer a concern. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eter environments)
72443ec to
c144cf3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR adds an admin-only query endpoint that reports entry counts and Candid-serialized byte counts for analyzing what data structures account for the most storage overhead in the registry canister.
getMemoryStatsis a query method gated behindUtils.isAdmin(caller). It returns:rts_heap_sizeandrts_memory_sizefrommo:prim{ count : Nat; bytes : Nat }for all data structures across the main actor,DownloadLog,StorageManager, andUsers