⚡ Bolt: [성능 개선] 정적 CSS 및 해시 계산 캐싱 (디렉토리 반복문 최적화)#196
Conversation
- `html4tree/main.kt`의 `process_dir` 함수가 재귀적으로 호출될 때마다 크기가 큰 CSS 문자열(`cssContent`)을 할당하고, 매번 SHA-256 해시(`styleHash`) 연산을 수행하던 병목을 제거했습니다. - 불변인 CSS 내용과 해시 값을 `private object StaticHtmlResources`로 추출하여, JVM 애플리케이션 시작 시 한 번만 계산되도록 최적화했습니다. - 이를 통해 각 디렉토리를 처리할 때마다 발생하던 불필요한 메모리 할당(GC 압력)과 CPU 연산 오버헤드를 크게 줄였습니다.
|
👋 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. |
- `html4tree/main.kt`의 `process_dir` 함수가 재귀적으로 호출될 때마다 크기가 큰 CSS 문자열(`cssContent`)을 할당하고, 매번 SHA-256 해시(`styleHash`) 연산을 수행하던 병목을 제거했습니다. - 불변인 CSS 내용과 해시 값을 `private object StaticHtmlResources`로 추출하여, JVM 애플리케이션 시작 시 한 번만 계산되도록 최적화했습니다. - 이를 통해 각 디렉토리를 처리할 때마다 발생하던 불필요한 메모리 할당(GC 압력)과 CPU 연산 오버헤드를 크게 줄였습니다.
💡 What:
html4tree/main.kt의 디렉토리 처리 루프(process_dir함수) 내부에 있던 정적 CSS 문자열(cssContent)과 그에 대한 SHA-256 해시(styleHash) 연산, 그리고 인라인<style>태그 생성 로직(css)을 추출했습니다.private object StaticHtmlResources내부의 프로퍼티로 선언하여, 클래스 로딩 시 단 한 번만 평가되도록 구조를 개선했습니다.🎯 Why:
process_dir가 호출될 때마다, 수십 줄의 CSS 문자열을 새로 생성하고 비용이 높은MessageDigest.getInstance("SHA-256")알고리즘을 반복적으로 호출하고 있었습니다.📊 Impact:
🔬 Measurement:
./gradlew test jacocoTestReport jacocoTestCoverageVerification를 실행하여 모든 기존 단위 테스트가 정상 통과하며 정적 값이 올바르게 삽입됨을 확인했습니다 (100% 테스트 커버리지 유지).PR created automatically by Jules for task 2028903043979642179 started by @seonghobae