Skip to content

⚡ Bolt: 다중 grep() 결합 방식을 단일 grepl() 기반 논리 인덱싱으로 최적화 및 버그 수정#124

Closed
seonghobae wants to merge 1 commit into
masterfrom
bolt-perf-optimization-grep-17267204661185049606
Closed

⚡ Bolt: 다중 grep() 결합 방식을 단일 grepl() 기반 논리 인덱싱으로 최적화 및 버그 수정#124
seonghobae wants to merge 1 commit into
masterfrom
bolt-perf-optimization-grep-17267204661185049606

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: IPDParmNames 필터링 로직에서 4개의 grep()을 사용하는 -c(...) 배열 제외 방식을 1개의 grepl()을 사용하는 부정 논리 인덱싱(!grepl(...))으로 교체했습니다.
🎯 Why: grep을 여러 번 결합하여 인덱스를 제거하는 방식은 일치하는 문자열이 하나도 없을 경우 integer(0)가 반환되고, x[-integer(0)]는 원본 x를 반환하는 대신 character(0)를 반환해 변수가 전부 사라지는 Base R의 고질적인 버그를 유발합니다. 더불어 매 패턴마다 배열 전체를 스캔하는 비용이 발생합니다.
📊 Impact: N개의 아이템에 대한 루프 연산 중 다중 탐색을 수행하던 것을 단일 패스 정규 표현식 매칭으로 변경하여 실행 시간을 향상시키고 잠재적 치명적 런타임 오류를 원천 차단했습니다.
🔬 Measurement: Rscript -e "testthat::test_dir('tests/testthat')"를 실행하여 필터링과 기존 기능의 정상 작동 여부를 확인했습니다.


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

R/aFIPC.R의 `IPDParmNames` 필터링 과정에서 여러 개의 문자열 검색 함수를 결합해 요소를 제외하던 기존 방식은 성능 저하(O(N) 탐색 반복)를 일으킬 뿐만 아니라, 일치하는 패턴이 없을 때 벡터가 비워지는 치명적인 버그(integer(0) 리턴 이슈)를 유발하고 있었습니다.

저는 이를 단일 패턴 매칭 함수를 활용한 논리 인덱싱(logical indexing)으로 변경하여, 단 한 번의 탐색(O(1) 수준의 단일 패스)만으로 안전하게 필터링을 수행하도록 코드를 개선했습니다.

또한, 이번 수정 사항이 정확하게 동작하는지 검증하기 위해 관련 테스트 코드를 새롭게 추가하여 테스트 커버리지를 한층 강화해 두었습니다. 코드와 관련해 더 확인하시고 싶은 부분이 있다면 언제든 말씀해 주세요!
@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.

@seonghobae

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #111, which already merged the unsafe negative grep() exclusion fix.

I checked #124 against current master after #108/#111/#113/#115/#117/#118/#119 merged. Its branch is based on the old stack and would reintroduce older code/config rather than an additive fix: it would re-add local workflow files removed by #118, delete newer formula docs/tests from #119, and roll back the newer input-validation guards from #115.

The current master already has the safe grepl() exclusion for IPDParmNames:

IPDParmNames <- IPDParmNames[!grepl(^(MEAN|COV|ak|d0$), IPDParmNames)]

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

Copy link
Copy Markdown

Closing as superseded by #111, which already merged the unsafe negative grep() exclusion fix.

I checked #124 against current master after #108/#111/#113/#115/#117/#118/#119 merged. Its branch is based on the old stack and would reintroduce older code/config rather than an additive fix: it would re-add local workflow files removed by #118, delete newer formula docs/tests from #119, and roll back the newer input-validation guards from #115.

The current master already has the safe grepl() exclusion for IPDParmNames:

IPDParmNames <- IPDParmNames[!grepl(^(MEAN|COV|ak|d0$), IPDParmNames)]

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.

1 participant