Skip to content

⚡ Bolt: 성능 최적화 - HexFormat을 사용한 헥스 문자열 변환 속도 개선#67

Closed
seonghobae wants to merge 1 commit into
mainfrom
bolt/hexformat-optimization-10999098816462460112
Closed

⚡ Bolt: 성능 최적화 - HexFormat을 사용한 헥스 문자열 변환 속도 개선#67
seonghobae wants to merge 1 commit into
mainfrom
bolt/hexformat-optimization-10999098816462460112

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What:
DefaultDocumentConversionService 내부 contentHash 메서드에서 사용되는 String.format 루프 기반 헥스 문자열 변환 로직을 Java 17부터 도입된 java.util.HexFormat을 사용하여 최적화했습니다.

🎯 Why:
String.format("%02x", b)을 바이트 배열 크기만큼 반복 호출하는 방식은 각 반복마다 새로운 Object[] 배열과 중간 문자열 객체를 생성하여 불필요한 메모리 할당(Garbage)을 발생시키고 성능을 저하시킵니다. 특히 파일 해시와 같이 빈번하게 호출되거나 큰 데이터를 다루는 경우 병목이 될 수 있습니다.

📊 Impact:

  • 객체 생성 감소: HexFormat.of().formatHex()를 사용하여 중간 객체 생성 없이 바이트 배열 전체를 효율적으로 변환합니다.
  • CPU 사용량 감소: 문자열 포맷팅 파싱 오버헤드를 제거합니다.
  • 가독성 향상: 장황한 반복문 코드가 간결한 한 줄로 변경되었습니다.

🔬 Measurement:

  • 로컬에서 프로파일링/벤치마크 결과 HexFormatString.format 루프 방식보다 훨씬 빠르고 메모리 할당이 적음을 확인했습니다.
  • mvn test 통과 확인 완료.
  • 해시 결과값이 기존과 100% 동일함을 확인했습니다.

PR created automatically by Jules for task 10999098816462460112 started by @seonghobae

@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 1, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes SHA-256 content hashing in DefaultDocumentConversionService by replacing a per-byte String.format loop with Java’s built-in HexFormat, reducing intermediate allocations and formatter overhead during hex encoding.

Changes:

  • Replaced String.format("%02x", b) loop with java.util.HexFormat.of().formatHex(raw) for hashing output generation.
  • Added a .jules/bolt.md note capturing the optimization rationale for future reference.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/com/clearfolio/viewer/service/DefaultDocumentConversionService.java Switches digest-to-hex conversion to HexFormat for better performance and less allocation.
.jules/bolt.md Documents the learning/action item behind the hex conversion optimization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .jules/bolt.md
@@ -0,0 +1,3 @@
## 2026-07-01 - Byte Array to Hex String Conversion Optimization
**Learning:** In Java 21, using `String.format("%02x", b)` inside a loop to convert a byte array to a hex string causes unnecessary allocations and is significantly slower than native alternatives.
**Action:** Use `java.util.HexFormat.of().formatHex(bytes)` for faster and allocation-free conversions from byte arrays to hex strings in this codebase.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

OpenCode reviewed the current-head evidence but found unresolved reviewer or review-agent threads before approval.

Findings

1. HIGH .github/workflows/opencode-review.yml:1 - Unresolved reviewer thread blocks automated approval

  • Problem: OpenCode reached an APPROVE control result, but the approval step found unresolved, non-outdated human or review-agent thread evidence on the current pull request.
  • Root cause: Reviewer and review-agent feedback can arrive after bounded model evidence is prepared, so the approval step must re-query GitHub immediately before publishing an approval.
  • Fix: Address or resolve the listed reviewer thread(s), then re-run OpenCode on the current head.
  • Regression test: Keep the approval gate querying reviewThreads(first: 100) after model output and before create_pull_review APPROVE, including bot review agents other than OpenCode itself.

Review thread evidence

Latest unresolved reviewer thread evidence

.jules/bolt.md line 3

  • Latest reviewer comment: @copilot-pull-request-reviewer at 2026-07-01T20:55:46Z

  • Comment URL: #67 (comment)

  • Comment excerpt: 'formatHex(...)' still allocates the resulting hex 'String' (and 'HexFormat.of()' may allocate), so calling this “allocation-free” is inaccurate. Consider wording this as “lower-allocation / fewer intermediate allocations” to avoid misleading future guidance.

  • Result: REQUEST_CHANGES

  • Reason: unresolved reviewer or review-agent thread(s) were present before approval.

  • Head SHA: 27a34bc9593c68e7bcdb61ac76f2aeb6b74490d6

  • Workflow run: 28547083561

  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (2 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (2 files)"]
  R1 --> V1["required checks"]
Loading

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

OpenCode Review Overview

  • Head SHA: 27a34bc9593c68e7bcdb61ac76f2aeb6b74490d6
  • Workflow run: 28547083561
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode reviewed the current-head evidence but found unresolved reviewer or review-agent threads before approval.

Findings

1. HIGH .github/workflows/opencode-review.yml:1 - Unresolved reviewer thread blocks automated approval

  • Problem: OpenCode reached an APPROVE control result, but the approval step found unresolved, non-outdated human or review-agent thread evidence on the current pull request.
  • Root cause: Reviewer and review-agent feedback can arrive after bounded model evidence is prepared, so the approval step must re-query GitHub immediately before publishing an approval.
  • Fix: Address or resolve the listed reviewer thread(s), then re-run OpenCode on the current head.
  • Regression test: Keep the approval gate querying reviewThreads(first: 100) after model output and before create_pull_review APPROVE, including bot review agents other than OpenCode itself.

Review thread evidence

Latest unresolved reviewer thread evidence

.jules/bolt.md line 3

  • Latest reviewer comment: @copilot-pull-request-reviewer at 2026-07-01T20:55:46Z

  • Comment URL: ⚡ Bolt: 성능 최적화 - HexFormat을 사용한 헥스 문자열 변환 속도 개선 #67 (comment)

  • Comment excerpt: 'formatHex(...)' still allocates the resulting hex 'String' (and 'HexFormat.of()' may allocate), so calling this “allocation-free” is inaccurate. Consider wording this as “lower-allocation / fewer intermediate allocations” to avoid misleading future guidance.

  • Result: REQUEST_CHANGES

  • Reason: unresolved reviewer or review-agent thread(s) were present before approval.

  • Head SHA: 27a34bc9593c68e7bcdb61ac76f2aeb6b74490d6

  • Workflow run: 28547083561

  • Workflow attempt: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (2 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (2 files)"]
  R1 --> V1["required checks"]
Loading

@seonghobae

Copy link
Copy Markdown
Collaborator Author

중복 정리: 이 PR은 'HexFormat hex 변환 최적화' 클러스터의 중복입니다. 정본으로 #80 (APPROVED + CI green + MERGEABLE)을 유지합니다. 동일 파일을 수정해 동시 병합이 불가능하므로 정리합니다. 고유하게 필요한 변경이 있으면 #80에 반영하거나 재오픈하세요.

@seonghobae seonghobae closed this Jul 7, 2026
@google-labs-jules

Copy link
Copy Markdown

중복 정리: 이 PR은 'HexFormat hex 변환 최적화' 클러스터의 중복입니다. 정본으로 #80 (APPROVED + CI green + MERGEABLE)을 유지합니다. 동일 파일을 수정해 동시 병합이 불가능하므로 정리합니다. 고유하게 필요한 변경이 있으면 #80에 반영하거나 재오픈하세요.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

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.

2 participants