-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Bolt: [성능 개선] 파일 시스템 순회 속도 향상 #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2024-06-06 - [Performance Optimization] Filesystem Traversal | ||
| **Learning:** In local-first CLI applications that extensively traverse the filesystem (like vspec), using `fs.readdirSync` with `fs.statSync` for each file causes a significant performance bottleneck due to excessive I/O operations. | ||
| **Action:** Always use `fs.readdirSync(..., { withFileTypes: true })` instead. It directly returns `fs.Dirent` objects containing type information, saving an I/O system call per file and dramatically speeding up directory traversals. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,10 +27,9 @@ export function projectKey(start = process.cwd()): string | null { | |
| export function walkFiles(root: string, predicate: (path: string) => boolean): string[] { | ||
| if (!existsSync(root)) return []; | ||
| const files: string[] = []; | ||
| for (const entry of readdirSync(root)) { | ||
| const path = join(root, entry); | ||
| const stat = statSync(path); | ||
| if (stat.isDirectory()) files.push(...walkFiles(path, predicate)); | ||
| for (const entry of readdirSync(root, { withFileTypes: true })) { | ||
| const path = join(root, entry.name); | ||
| if (entry.isDirectory()) files.push(...walkFiles(path, predicate)); | ||
| else if (predicate(path)) files.push(path); | ||
|
Comment on lines
+30
to
33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# 검증 목적:
# 1) walkFiles 관련 테스트에 symlink 디렉터리 케이스가 있는지 확인
# 2) 이전 구현과 현재 구현의 디렉터리 판별 차이를 코드 레벨로 확인
set -euo pipefail
echo "== walkFiles 호출/테스트 맥락 검색 =="
rg -n -C3 '\bwalkFiles\s*\(' --type=ts
echo
echo "== symlink 관련 테스트/정책 흔적 검색 =="
rg -n -C3 'symlink|symbolic|isSymbolicLink|ln -s' --type=ts --type=md
echo
echo "== 직전 커밋의 walkFiles 구현 확인 =="
git show HEAD~1:src/files.ts | sed -n '1,140p'Repository: Seongho-Bae/vooster-v2-mvp Length of output: 6109
🤖 Prompt for AI Agents |
||
| } | ||
| return files.sort(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문서 날짜를 실제 변경 시점으로 맞춰 주세요.
Line 1의
2024-06-06은 현재 PR 시점(2026-06-06)과 불일치합니다. 히스토리 추적 혼선을 막기 위해 날짜를 실제 작성일로 정정하는 게 좋습니다.🤖 Prompt for AI Agents