Files
orca/src/main/ipc/markdown-documents.ts
T
Neil be4cea1584 perf(wsl): search Windows-drive projects with host ripgrep (#27690)
* perf(wsl): run ripgrep on the Windows host for drive-path projects

A project stored on a Windows drive (C:\...) with the WSL runtime selected
ran quick open, file-path search, content search and Markdown listing
through wsl.exe and the Linux rg reading /mnt/c over drvfs. rg only reads
files, so it has no git index whose stat cache two writers could thrash;
the host binary reads NTFS directly.

Measured on a 21.6k-file clone on C: (Windows 11, Ubuntu-24.04):
  content search  WSL rg 3.5 s  -> host rg.exe 0.19 s
  file listing    WSL rg 0.14 s + ~65 ms wsl.exe spawn -> host 0.03 s

Git routing is intentionally unchanged: alternating Windows git and WSL git
on the same index forced a full ~250 s rehash on the next WSL git status.

WSL UNC roots and non-drive roots keep their existing routing.

* fix(search): keep host rg results whole when files only WSL can open exist

Windows rg cannot open a 'nul' file, Win32-trimmed names, or WSL-created
symlinks; treat those per-file errors as skipped rather than failing or
truncating the search, and keep symlink-following scans in WSL.
2026-10-11 19:35:46 -07:00

30 lines
1.1 KiB
TypeScript

import { spawnBundledRipgrep } from '../ripgrep/bundled-ripgrep-spawn'
import { stopBundledRipgrep } from '../ripgrep/bundled-ripgrep-stop'
import { resolveBundledRipgrepWslRouting } from '../ripgrep/bundled-ripgrep-wsl-routing'
import {
collectMarkdownDocuments,
MARKDOWN_DOCUMENT_LISTING_ARGS
} from '../../shared/node-markdown-document-listing'
import type { MarkdownDocument } from '../../shared/filesystem-entry-types'
export * from '../../shared/markdown-document-paths'
export async function listMarkdownDocuments(
rootPath: string,
options: { wslDistro?: string; signal?: AbortSignal } = {}
): Promise<MarkdownDocument[]> {
options.signal?.throwIfAborted()
const { wslDistro, wslDistroForOutput: distro } = resolveBundledRipgrepWslRouting(
rootPath,
options.wslDistro
)
const child = spawnBundledRipgrep(MARKDOWN_DOCUMENT_LISTING_ARGS, {
cwd: rootPath,
wslDistro,
wslDistroForOutput: distro,
stdio: ['ignore', 'pipe', 'pipe']
})
return collectMarkdownDocuments(child, rootPath, Boolean(distro), options.signal, {
stopProcess: () => stopBundledRipgrep(child, Boolean(distro))
})
}