Skip to content

perf: speed up first directory listing with prefetch and shared reads - #20

Merged
LukeGus merged 3 commits into
Termix-SSH:dev-1.1.2from
deanxbox:perf/file-manager-directory-load-speed
Oct 29, 2026
Merged

LukeGus merged 3 commits into
Termix-SSH:dev-1.1.2from
deanxbox:perf/file-manager-directory-load-speed

Conversation

@deanxbox

Copy link
Copy Markdown

Overview

Speeds up the first open of a directory in the file manager, using bounded prefetching and shared in-flight reads. It also shows a loading state instead of a transient "No files found." The branch also carries earlier layout, listing and sudo-read fixes.

  • Added: Hover/predictive directory prefetching, and controlled loading and rendering benchmarks (scripts and docs).
  • Updated: Directory reads, request sharing, mutation refresh and cache invalidation.
  • Removed: ...
  • Fixed: Transient "No files found.", stale listings after navigation, and duplicate concurrent requests returning 409 instead of both succeeding.

Changes Made

  • Added a hover/predictive prefetch scheduler and an epoch-aware shared request cache.
  • Directory entries are read concurrently (2 READDIRs) with deduplication. A 30-second listing watchdog returns 504 and releases activeOperations exactly once.
  • Duplicate concurrent requests now both return 200, and the dead 409 branch is removed.
  • Mutations always invalidate the cache and trigger a forced refresh. The delayed refresh is skipped if you navigate or change session first.
  • A late listing after authentication or connect can no longer move the pane.
  • A skipped-sudo prefetch is retried once as a forced read.
  • Earlier commits on this branch:
    • fix the grid layout after tab switches and directory changes
    • give list rows a fixed height
    • extract filtering and sorting into a shared Intl.Collator helper
    • pass sudo passwords over stdin
  • Streaming listings and a backend snapshot cache are deferred.

Related Issues

  • None

Screenshots / Demos

Controlled fixtures only, not live Termix or real SSH hosts. Reproduce with scripts/benchmark-file-loading.mjs and scripts/benchmark-file-rendering.cjs.

Rendering (real Chromium, production bundles, 15 samples):

Entries Initial render and directory update
10,000 (list and grid) about 87% faster
500 unchanged
0 (empty list, initial render) 19.9 → 28.3 ms median (+8.4 ms); p95 about 33 ms for both

Loading and rendering were measured separately and should not be added together.

Checklist

  • Code follows the project style
  • Works on mobile and desktop (if it has UI)
  • Tests pass and new code has tests
  • Added the change to CHANGELOG.md (if the repo has one)
  • I have read the repo's CONTRIBUTING.md

- Re-measure the grid after a tab becomes visible and keep list rows at a fixed height

- Memoize selected and dragged paths, and pass sudo passwords over stdin

- Extract file filtering and sorting with a shared collator and add tests
- Prefetch likely directories and share epoch-aware listing requests.
- Read directory entries concurrently with deduplication and a 30s watchdog.
- Show loading state, retry sudo reads after skipped prefetch, and guard against stale listings.
- Fix mutation refresh and cache invalidation; add controlled-fixture benchmarks and docs (not live-host measurements).
@termix-triage-bot

Copy link
Copy Markdown

AI review | Looks safe to merge

Implements bounded directory prefetching, request coalescing, and pipelined SFTP reads to reduce listing latency. Race conditions, cache invalidation, and sudo credential handling are carefully managed with comprehensive tests and isolated benchmarks.

Reviewed b244973. AI can be wrong, a maintainer still decides. Comment /termix review to run it again.

@LukeGus
LukeGus changed the base branch from main to dev-1.1.2 October 29, 2026 18:02
@LukeGus
LukeGus merged commit aea495f into Termix-SSH:dev-1.1.2 Oct 29, 2026
2 checks passed
@LukeGus LukeGus mentioned this pull request Oct 29, 2026
3 of 6 tasks
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.

2 participants