Skip to content

Add restate-memory crate with EstimatedMemorySize trait#4336

Merged
AhmedSoliman merged 1 commit intomainfrom
pr4336
Feb 6, 2026
Merged

Add restate-memory crate with EstimatedMemorySize trait#4336
AhmedSoliman merged 1 commit intomainfrom
pr4336

Conversation

@AhmedSoliman
Copy link
Contributor

@AhmedSoliman AhmedSoliman commented Feb 5, 2026

Introduce a new restate-memory crate containing memory management utilities.
The crate provides EstimatedMemorySize trait for types that can be significant
contributors to memory usage.

Key features:

  • EstimatedMemorySize trait with blanket impls for references (&T, &mut T)
  • Impls for common types: String, Bytes, BytesMut, [u8], str, Vec, [T]
  • Impls for smart pointers: Arc, Rc, Box, Cow
  • Impls for lock guards: MutexGuard, RwLockReadGuard, RwLockWriteGuard, Ref, RefMut
  • Impl for Option

The trait is re-exported through restate-types::memory for convenience.
Also implements EstimatedMemorySize for Record, Payloads, Store, and PolyBytes
in restate-types.


Stack created with Sapling. Best reviewed with ReviewStack.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Test Results

  7 files  +  2    7 suites  +2   2m 46s ⏱️ + 1m 44s
 47 tests + 21   47 ✅ + 21  0 💤 ±0  0 ❌ ±0 
200 runs  +156  200 ✅ +156  0 💤 ±0  0 ❌ ±0 

Results for commit 2f52afe. ± Comparison against base commit 3690b87.

This pull request removes 26 and adds 47 tests. Note that renamed tests count towards both.
dev.restate.sdktesting.tests.AwakeableIngressEndpointTest ‑ completeWithFailure(Client)
dev.restate.sdktesting.tests.AwakeableIngressEndpointTest ‑ completeWithSuccess(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$NewVersion ‑ completeAwakeable(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$NewVersion ‑ completeRetryableOperation(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$NewVersion ‑ proxyCallShouldBeDone(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$NewVersion ‑ proxyOneWayCallShouldBeDone(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$OldVersion ‑ createAwakeable(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$OldVersion ‑ startOneWayProxyCall(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$OldVersion ‑ startProxyCall(Client)
dev.restate.sdktesting.tests.BackwardCompatibilityTest$OldVersion ‑ startRetryableOperation(Client)
…
dev.restate.sdktesting.tests.CallOrdering ‑ ordering(boolean[], Client)[1]
dev.restate.sdktesting.tests.CallOrdering ‑ ordering(boolean[], Client)[2]
dev.restate.sdktesting.tests.CallOrdering ‑ ordering(boolean[], Client)[3]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromAdminAPI(BlockingOperation, Client, URI)[1]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromAdminAPI(BlockingOperation, Client, URI)[2]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromAdminAPI(BlockingOperation, Client, URI)[3]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromContext(BlockingOperation, Client)[1]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromContext(BlockingOperation, Client)[2]
dev.restate.sdktesting.tests.Cancellation ‑ cancelFromContext(BlockingOperation, Client)[3]
dev.restate.sdktesting.tests.Combinators ‑ awakeableOrTimeoutUsingAwakeableTimeoutCommand(Client)
…

♻️ This comment has been updated with latest results.

Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great building block for making our memory consumption more predictable @AhmedSoliman. LGTM. +1 for merging :-)

Introduce a new restate-memory crate containing memory management utilities.
The crate provides EstimatedMemorySize trait for types that can be significant
contributors to memory usage.

Key features:
- EstimatedMemorySize trait with blanket impls for references (&T, &mut T)
- Impls for common types: String, Bytes, BytesMut, [u8], str, Vec<T>, [T]
- Impls for smart pointers: Arc<T>, Rc<T>, Box<T>, Cow<T>
- Impls for lock guards: MutexGuard, RwLockReadGuard, RwLockWriteGuard, Ref, RefMut
- Impl for Option<T>

The trait is re-exported through restate-types::memory for convenience.
Also implements EstimatedMemorySize for Record, Payloads, Store, and PolyBytes
in restate-types.
@AhmedSoliman AhmedSoliman merged commit c0a2cc1 into main Feb 6, 2026
15 checks passed
@AhmedSoliman AhmedSoliman deleted the pr4336 branch February 6, 2026 22:14
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants