Skip to content

feat(neotree): virtualize unbounded file trees - #289

Merged
fcoury-oai merged 2 commits into
mainfrom
fcoury/neotree-unbounded-virtualization
Aug 21, 2026
Merged

fcoury-oai merged 2 commits into
mainfrom
fcoury/neotree-unbounded-virtualization

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Neo-tree silently loses files in large directories: the host stops enumerating after 160 filesystem entries, and the Husk presentation layer separately stops after 200 visible rows. Entries are discarded before sorting, so valid files can disappear entirely and existing timings understate the real cost of browsing a complete directory.

What changed

  • Add scripts/neotree_bench.py, a real-editor PTY benchmark that creates fixture directories, verifies the alphabetically final file is reachable, and measures opening latency, navigation latency, resident memory, and idle CPU.
  • Remove both directory and tree-row limits, sort every discovered entry, and move filesystem enumeration onto Tokio's blocking pool.
  • Introduce src/plugin/tree.rs, a compact virtual tree model that shares Husk directory-entry arrays and materializes icons, paths, Git decorations, branch guides, and theme styles only for visible or selected rows.
  • Preserve existing small-tree behavior, keyboard and mouse navigation, active-file reveal, selection, clipboard markers, and Git status rendering.
  • Replace full nonrecursive watcher snapshots with compact directory/ignore-file metadata fingerprints; build a fresh listing only when that fingerprint changes.
  • Document the benchmark methodology and matched baseline/results in docs/performance-neotree-unbounded-2026-08-21.md.

Performance

Three-sample medians from optimized builds:

Files Baseline complete Updated complete Opening, baseline → updated Updated navigation p95
128 Yes Yes 59.47 → 21.55 ms 0.555 ms
512 No Yes 36.59 → 23.94 ms 0.566 ms
2,048 No Yes 35.55 → 24.32 ms 0.662 ms
8,192 No Yes 37.30 → 47.17 ms 0.566 ms

Baseline numbers above 128 files cover only the first 160 entries, not the complete directory. A separate 32,768-file stress run reached the final file in 119.88 ms with 0.694 ms p95 navigation.

How to Test

  1. Build the optimized editor:

    cargo build --locked --release --bin red
  2. Run the complete-directory benchmark:

    python3 -B scripts/neotree_bench.py \
      --sizes 128 512 2048 8192 \
      --samples 3 \
      --navigation-presses 50 \
      --require-complete

    Expect every size to report complete: true, no truncation marker, and the final alphabetically sorted file to remain reachable.

  3. Exercise the active-file reveal regression case:

    python3 -B scripts/neotree_bench.py \
      --sizes 8192 \
      --samples 1 \
      --active-target \
      --require-complete

    Expect Neo-tree to reveal the already-open final file and keep that entry reachable in the large directory.

  4. Run the focused directory, virtual-panel, Husk-core, and benchmark tests:

    cargo test --locked directory_listing_returns_every_entry_in_large_directories
    cargo test --locked virtual_tree_rows_remain_selectable_and_render_only_the_viewport
    cargo run --locked --release -p husk-cli -- test --locked plugins/neotree_core
    python3 -B -m unittest discover -s tests -p 'test_neotree_bench.py'

Validated locally with 2,958 passing Rust tests, six Neo-tree Husk tests, 19 Python tests, the bundled-plugin startup self-check, and all-target/all-feature Clippy with warnings denied.

@fcoury-oai
fcoury-oai merged commit dbced21 into main Aug 21, 2026
12 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/neotree-unbounded-virtualization branch August 21, 2026 18:15
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