clockworklabs / clockworklabs/SpacetimeDB
Implement Pooling of MemoryStream in DecompressDecodeMessage and DecompressDecodeQueryUpdate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
Originally included as a TODO comment in https://github.com/clockworklabs/SpacetimeDB/commit/5ad9baa3049ff575e87668c61f65c139352930d7, when either DecompressDecodeMessage or DecompressDecodeQueryUpdate are called in the C# SDK, the following is ran:
// DO NOT TRY TO TAKE THIS OUT. The BrotliStream ReadByte() implementation allocates an array
// PER BYTE READ. You have to do it all at once to avoid that problem.
MemoryStream memoryStream = new MemoryStream();
decompressedStream.CopyTo(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
return new ServerMessage.BSATN().Read(new BinaryReader(memoryStream));
This MemoryStream may be eligible for pooling, in order to avoid a new allocation every time this runs.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the C# SDK implementations of DecompressDecodeMessage and DecompressDecodeQueryUpdate and read how each creates and consumes the MemoryStream. Check the surrounding decompression and decoding code first, then identify the SDK's existing pooling facilities. Done means both paths avoid a fresh MemoryStream allocation while preserving the current decoding behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100