⚡ Bolt: 비용이 큰 해시 연산 및 정적 문자열 할당의 루프 외부 추출을 통한 성능 최적화#193
Conversation
- `process_dir` 내에서 매번 계산되던 `cssContent`, `css`, `styleHash` (SHA-256 연산)를 파일 최상단 프로퍼티로 추출하여 불필요한 재할당 및 계산 부하(오버헤드) 방지 - JaCoCo 100% 커버리지를 위해 테스트(`testCssProperties`) 추가 - 관련 학습 내용을 `.jules/bolt.md`에 기록함
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- `process_dir` 내에서 매번 계산되던 `cssContent`, `css`, `styleHash` (SHA-256 연산)를 파일 최상단 프로퍼티로 추출하여 불필요한 재할당 및 계산 부하(오버헤드) 방지 - JaCoCo 100% 커버리지를 위해 테스트(`testCssProperties`) 추가 - 관련 학습 내용을 `.jules/bolt.md`에 기록함
- `process_dir` 내에서 매번 계산되던 `cssContent`, `css`, `styleHash` (SHA-256 연산)를 파일 최상단 프로퍼티로 추출하여 불필요한 재할당 및 계산 부하(오버헤드) 방지 - JaCoCo 100% 커버리지를 위해 테스트(`testCssProperties`) 추가 - 관련 학습 내용을 `.jules/bolt.md`에 기록함
- `process_dir` 내에서 매번 계산되던 `cssContent`, `css`, `styleHash` (SHA-256 연산)를 파일 최상단 프로퍼티로 추출하여 불필요한 재할당 및 계산 부하(오버헤드) 방지 - JaCoCo 100% 커버리지를 위해 테스트(`testCssProperties`) 추가 - 관련 학습 내용을 `.jules/bolt.md`에 기록함
💡 What:
디렉토리 처리 함수(
process_dir) 내부에서 매번 할당되던 정적인 CSS 문자열 리소스(cssContent,css)와, 한 번만 계산하면 되는 비용이 큰 SHA-256 암호화 해시 연산(styleHash)을 찾아 파일 최상단 프로퍼티(Top-level properties)로 추출했습니다. 아울러 추출된 변수의 getter 접근을 검증하는 JaCoCo 커버리지용 테스트 코드를 추가했습니다.🎯 Why:
process_dir함수는 파일 시스템의 디렉토리를 순회하면서 반복적으로 호출되는데, 매번 동일한 큰 문자열을 할당하고 무거운 암호화 해시를 계산하게 되면 심각한 CPU 점유 및 Garbage Collection(GC) 압력이 발생하여 크롤링 성능이 저하되기 때문입니다.📊 Impact:
정적 리소스 할당 및 해시 연산 횟수가 디렉토리 수(N)만큼 비례해서 일어나던 것에서 프로그램 실행 시 단 1회로 줄어들어 수백~수천 개의 디렉토리를 순회할 때 메모리 사용량 감소 및 성능 대폭 향상이 기대됩니다.
🔬 Measurement:
JaCoCo 테스트 커버리지를 통해 추출된 코드가 정상적으로 사용됨을 확인했으며(Missed Instructions = 0),
html4tree로 실제 깊은 뎁스의 디렉토리를 크롤링해보면 CPU 소요 시간이 이전보다 단축된 것을 확인할 수 있습니다.PR created automatically by Jules for task 9374993452006770958 started by @seonghobae