Skip to content

Commit 87a73a6

Browse files
Update USAGE.md with new memory stats APIs
1 parent 6c2f895 commit 87a73a6

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

USAGE.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ let (value, is_new) = sl.get_or_insert(b"key", b"default");
272272
| `is_empty` | `fn is_empty(&self) -> bool` | Returns true if no live entries |
273273
| `is_sealed` | `fn is_sealed(&self) -> bool` | Returns true if sealed |
274274
| `memory_usage` | `fn memory_usage(&self) -> usize` | Total arena bytes allocated |
275+
| `memory_reserved` | `fn memory_reserved(&self) -> usize` | Total arena bytes reserved |
276+
| `memory_utilization` | `fn memory_utilization(&self) -> f64` | Utilization (0.0 to 1.0) |
277+
| `memory_idle` | `fn memory_idle(&self) -> usize` | Reserved but unused bytes |
278+
279+
```rust
280+
let sl = ConcurrentSkipList::new();
281+
sl.insert(b"key", b"value");
282+
283+
println!("allocated: {} bytes", sl.memory_usage());
284+
println!("reserved: {} bytes", sl.memory_reserved());
285+
println!("utilization: {:.1}%", sl.memory_utilization() * 100.0);
286+
println!("idle: {} bytes", sl.memory_idle());
287+
```
275288

276289
#### Lifecycle
277290

@@ -296,7 +309,10 @@ A sealed (read-only) memtable created by `seal()`. Used for flushing to SSTable.
296309
| `cursor_at` | `fn cursor_at(&self, target: &[u8]) -> Option<Cursor<'_>>` | Cursor at target |
297310
| `len` | `fn len(&self) -> usize` | Live entry count |
298311
| `is_empty` | `fn is_empty(&self) -> bool` | Returns true if empty |
299-
| `memory_usage` | `fn memory_usage(&self) -> usize` | Arena bytes |
312+
| `memory_usage` | `fn memory_usage(&self) -> usize` | Arena bytes allocated |
313+
| `memory_reserved` | `fn memory_reserved(&self) -> usize` | Arena bytes reserved |
314+
| `memory_utilization` | `fn memory_utilization(&self) -> f64` | Utilization (0.0 to 1.0) |
315+
| `memory_idle` | `fn memory_idle(&self) -> usize` | Reserved but unused |
300316
| `get` | `fn get(&self, key: &[u8]) -> Option<(&[u8], bool)>` | Point lookup |
301317
| `get_live` | `fn get_live(&self, key: &[u8]) -> Option<&[u8]>` | Point lookup (live only) |
302318

0 commit comments

Comments
 (0)