clockworklabs / clockworklabs/SpacetimeDB

Proposal for C# SDK performance

Open
#1,934 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

The BSATN codegen for c# often generates pattern like new(new()) to emulate rust's variant types, and wraps certain value types into reference classes, such as Timestamp and EnergyQuota.

Similarly, many allocations for encoding and decoding of messages can be made once and reused, or at least pooled to avoid allocations.

A great deal of GC overhead and pressure can be removed by refactoring codegen to emit high-performance C#.

One benefit of this is to gain support for Burst compilation and ECS in Unity, as they do not allow reference types to be used at all.

Proposal should also look at the way updates are processed by SDK clients and look at a way to send the matching memory layouts directly from rust. Right now an intermediate client-side processing pass using a temporary hashmap is required to combine matching inserts/deletes into updates.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the C# BSATN code generator and the SDK client update-processing path. Measure allocations from generated value wrappers, encoding and decoding, and temporary update processing; done requires a defined high-performance design that supports Burst/ECS constraints and reduces the described allocation and intermediate-processing overhead.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, rust, unity
Domain
backend-api-design, game-dev, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.