clockworklabs / clockworklabs/SpacetimeDB

PERFORMANCE FIX: TableCacheImpl TODO: this just scans the whole table; we should build proper index structures

Open
#5,317 3 comments 0 reactions 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

It shows up in all my performance profiling as an issue. Specifically, the todo comment you guys have in there. Please prioritise, it is showing up in all my performance profiles.

crates/bindings-typescript/src/sdk/table_cache.ts

Class: TableCacheImpl
Method: #makeReadonlyIndex (private), around line 105
TODO: // TODO: this just scans the whole table; we should build proper index structures
Hot path: find() on unique indexes loops self.iter() and calls deepEqual(getKey(row), expected) per row (lines ~198–204)
filter() on ranged indexes does the same scan + deepEqual in matchRange
crates/bindings-typescript/src/lib/util.ts

Function: deepEqual (lines ~9–37)
Uses Object.keys() twice + recursive comparison

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 reading crates/bindings-typescript/src/sdk/table_cache.ts, especially TableCacheImpl, #makeReadonlyIndex, find(), and filter(), then inspect deepEqual in crates/bindings-typescript/src/lib/util.ts. Trace how unique and ranged indexes currently scan rows and compare keys. Done means find() and filter() use proper index structures instead of scanning the whole table, with profiling confirming the hot-path improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.