SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Allocate fewer vecs in `eval_updates`

Open coolreader18 opened this issue 9 months ago • 6 comments

Description of Changes

Instead of collecting to a single vec, we collect to a linked list of vecs, which is rayon's recommended way of collecting a parallel iterator into a single data structure. This means there will be fewer allocations - for N worker threads and M query plans, it's now N vecs and N linked list nodes with standard amortizable growth, instead of M vecs that get concatenated together one at a time.

API and ABI breaking changes

Expected complexity level and risk

2 - I'm pretty confident this doesn't have a behavior change and that the changes are only optimizations, but it'd probably be worth running benchmarks to make sure

Testing

  • [ ] benchmark run

coolreader18 avatar Apr 08 '25 19:04 coolreader18

don't think this works anymore, but: benchmarks please

coolreader18 avatar Apr 08 '25 19:04 coolreader18

Criterion benchmark results

Error when comparing benchmarks: Couldn't find AWS credentials in environment, credentials file, or IAM role.

Caused by: Couldn't find AWS credentials in environment, credentials file, or IAM role.

github-actions[bot] avatar Apr 08 '25 19:04 github-actions[bot]

Callgrind benchmark in progress...

github-actions[bot] avatar Apr 08 '25 19:04 github-actions[bot]

Callgrind benchmark in progress...

github-actions[bot] avatar Apr 08 '25 19:04 github-actions[bot]

Criterion benchmark results

Error when comparing benchmarks: Couldn't find AWS credentials in environment, credentials file, or IAM role.

Caused by: Couldn't find AWS credentials in environment, credentials file, or IAM role.

github-actions[bot] avatar Apr 08 '25 20:04 github-actions[bot]

This optimization makes sense, just bear in mind that we may decide to remove parallel iteration from eval_updates entirely.

joshua-spacetime avatar Apr 11 '25 22:04 joshua-spacetime