Skip to content

Conversation

@jussisaurio
Copy link
Collaborator

@jussisaurio jussisaurio commented Dec 24, 2025

Beef

  1. Use bump arena for in-memory records
  • Allows contiguous allocation and bulk deallocate
  • Allows sorting pointers instead of sorting large SortableImmutableRecord structs which pay a large memmove penalty
  1. Use boxed records for on-disk chunk heap
  • Avoids the same memmove problem

Testing

ran RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --package turso_core sorter --target aarch64-apple-darwin

Results

Locally I got -20% on this clickbench query: SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;.

Unfortunately the clickbench CI benchmark is noisy, but It looks like queries with sorting that used to take the longest now take less time. Very scientific.

@jussisaurio jussisaurio changed the title perf/sorter: sort pointers instead of records perf/sorter: sort pointers instead of records, use arena allocation Dec 24, 2025
@jussisaurio jussisaurio force-pushed the optimize-sorter-perf branch 3 times, most recently from 881bd9b to eff510e Compare December 24, 2025 20:24
@jussisaurio jussisaurio marked this pull request as ready for review December 24, 2025 20:26
1. Use bump arena for in-memory records
- Allows contiguous allocation and bulk deallocate
- Allows sorting pointers instead of sorting large SortableImmutableRecord structs which pay a large memmove penalty
2. Use boxed records for on-disk chunk heap: avoids the same memmove problem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants