Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@
## 2026-08-09 - [대용량 로그 스캔 시 정규표현식 실행 전 O(N) 서브스트링 검증 선행]
**Learning:** `classify_testthat_failure`에서 테스트 실패 내역이 없는 2MB 로그 파일을 대상으로 정규표현식을 실행하면 약 20ms가 소요되지만, 단순 문자열 검색은 약 1ms만 소요됩니다. 문자열 존재 여부가 정규표현식 매칭의 전제 조건일 때, 콜드 패스(Cold Path)에서 순서 최적화는 매우 큰 성능 차이를 만듭니다.
**Action:** 대용량 텍스트 입력(CI 로그 등)에서 복잡한 정규표현식을 파싱하기 전에 항상 빠른 O(N) 문자열 존재 여부 확인을 먼저 수행하십시오.
## 2024-11-28 - [성능 개선] 다중 라벨 텍스트 스캔 정규표현식 최적화
**Learning:** `scripts/ci/opencode_review_normalize_output.py`의 `label_section` 함수는 다음 섹션의 시작 위치를 찾기 위해 *모든* 검증 라벨에 대해 전체 남은 텍스트를 재스캔하는 리스트 컴프리헨션을 사용하여 `O(L * N)` 복잡도를 가졌으며, 이는 패턴이 많은 대용량 텍스트 로그에서 심각한 성능 병목이었습니다.
**Action:** 다중 하위 문자열 패턴에 대한 순차적 검색을 단일 컴파일된 정규표현식(`ANY_LABEL_PATTERN = re.compile("|".join(...))`)으로 결합하고 `.search(text, start)`를 사용하여 다음 매칭 섹션 마커로 O(N) 시간 내에 이동하도록 변경했습니다.
21 changes: 12 additions & 9 deletions scripts/ci/opencode_review_normalize_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
label: re.compile(re.escape(label)) for label in APPROVAL_VERIFICATION_LABELS
}

ANY_LABEL_PATTERN = re.compile("|".join(re.escape(label) for label in APPROVAL_VERIFICATION_LABELS))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 Info: Combined-regex correctness is fragile to future label additions

Python alternation is leftmost-then-first-alternative, not longest-match. ANY_LABEL_PATTERN (opencode_review_normalize_output.py) stays correct only because no label is a prefix of another. Adding a label that shares a start position with an existing one could produce a shorter, wrong match depending on tuple order.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


SOURCE_LIKE_CHANGED_FILE_EXTENSIONS = frozenset(
{
".bash",
Expand Down Expand Up @@ -979,15 +981,16 @@ def label_starts(candidate: str) -> list[int]:
if not starts:
return ""
Comment thread
seonghobae marked this conversation as resolved.
start = starts[-1] + len(label)
next_starts = [
candidate_start
for candidate in APPROVAL_VERIFICATION_LABELS
if candidate != label
for candidate_start in label_starts(candidate)
if candidate_start >= start
]
end = min(next_starts) if next_starts else len(text)
return text[start:end]

match = ANY_LABEL_PATTERN.search(text, start)
while match:
idx = match.start()
matched_label = match.group(0)
if matched_label != label and idx in label_starts(matched_label):
return text[start:idx]
match = ANY_LABEL_PATTERN.search(text, match.end())
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

return text[start:]

@devin-ai-integration devin-ai-integration Bot Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 Info: label_section refactor is behaviorally equivalent

The rewrite preserves the original semantics. ANY_LABEL_PATTERN lists coverage: before docstring coverage:, but finditer is non-overlapping and left-anchored, so at the d of docstring coverage: it matches the whole label, not the inner coverage:; no label is a textual prefix of another, so alternation order causes no mismatch. starts[-1] picks the last target occurrence, and ascending match order makes the first later differing candidate equal to the old min(next_starts). The docstring skip at line 968 is now near-dead but harmless.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.



def coverage_section_is_valid(section: str) -> bool:
Expand Down
Loading