Skip to content

perf: lower async sort threshold to 1K rows, add display cache eviction#530

Merged
datlechin merged 1 commit intomainfrom
perf/async-sort-threshold-display-cache
Mar 31, 2026
Merged

perf: lower async sort threshold to 1K rows, add display cache eviction#530
datlechin merged 1 commit intomainfrom
perf/async-sort-threshold-display-cache

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • Async sort threshold lowered from 10K to 1K rows — sorting 1K-10K rows was happening synchronously in the SwiftUI view body, blocking the main thread for 50-100ms. Now dispatched to background via Task.detached, matching the existing async sort path.
  • Display cache evictionInMemoryRowProvider.displayCache was unbounded. For 10K rows x 50 columns, it could hold 500K entries (~5MB). Added eviction at 20K entries, keeping the half closest to the current access point (same strategy as DatabaseRowProvider).

Both thresholds are aligned: coordinator (MainContentCoordinator.swift:1173) and view (MainEditorContentView.swift:558).

Test plan

  • Sort a query result with 500 rows — should sort synchronously (below threshold), instant
  • Sort a query result with 2000 rows — should show brief executing state, then sorted result
  • Sort a query result with 10K+ rows — should sort async as before, no regression
  • Scroll through a large table (5K+ rows) — verify display cache eviction doesn't cause visible stutter (re-formatting is lazy)
  • Verify no memory growth when scrolling back and forth through large results

@datlechin datlechin merged commit 1496264 into main Mar 31, 2026
2 checks passed
@datlechin datlechin deleted the perf/async-sort-threshold-display-cache branch March 31, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant