Skip to content

⚡ Bolt: surveyFA.R 파일의 정렬(sort) 기반 최소값 탐색 최적화#171

Open
seonghobae wants to merge 4 commits into
masterfrom
bolt/optimize-surveyfa-sort-4773234356486495246
Open

⚡ Bolt: surveyFA.R 파일의 정렬(sort) 기반 최소값 탐색 최적화#171
seonghobae wants to merge 4 commits into
masterfrom
bolt/optimize-surveyfa-sort-4773234356486495246

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: R/surveyFA.R 파일에서 sort() 함수를 이용해 가장 작은 p_value 값을 가지는 항목을 찾는 로직을 which.min()으로 변경했습니다.
🎯 Why: sort(x)[1]을 사용하면 최소값을 찾기 위해 전체 배열을 정렬해야 하므로 O(N log N)의 불필요한 오버헤드가 발생합니다. which.min(x)는 배열을 한 번만 순회하면서 최소값의 인덱스를 찾기 때문에 시간 복잡도를 O(N)으로 개선할 수 있습니다.
📊 Impact: 배열의 크기(항목의 개수)가 클수록 성능 향상이 두드러지며 불필요한 메모리 및 연산 오버헤드를 감소시킵니다.
🔬 Measurement: Rscript -e "testthat::test_dir('tests/testthat')" 명령어로 기존 테스트 세트가 모두 100% 통과하여 행동 변경이 없음을 확인했습니다.


PR created automatically by Jules for task 4773234356486495246 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 24, 2026 19:11

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

Updates surveyFA()’s candidate-selection logic to avoid a full sort when only the minimum p-value item is needed, aligning with the repo’s ongoing “Bolt” micro-optimization notes.

Changes:

  • Replaced names(sort(p_values))[1L] with names(p_values)[which.min(p_values)] for O(N) min selection in R/surveyFA.R.
  • Added a corresponding optimization note to .jules/bolt.md.

Reviewed changes

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

File Description
R/surveyFA.R Switches minimum p-value candidate selection from sort-based to which.min()-based lookup.
.jules/bolt.md Documents the optimization guidance for replacing sort-based min/max selection with which.min/which.max.

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

Comment thread .jules/bolt.md
**Action:** 조건문이나 반복문 내부에서 불필요하게 데이터프레임 부분집합 연산이 반복되지 않도록 외부에서 한 번만 `linkedFormData <- newformXDataK[colnames(newFormModel@Data$data)]`로 캐싱(caching)한 뒤, `ncol(linkedFormData)`와 `data = linkedFormData` 형태로 재사용하여 메모리 복사와 O(N) 오버헤드를 방지해야 합니다.
## 2025-02-13 - R 언어에서 정렬 기반 최소/최대값 탐색(sort) 최적화
**Learning:** R에서 최솟값 또는 최댓값을 찾기 위해 `sort(x)[1]`이나 `names(sort(x))[1]`을 사용하면 전체 배열을 정렬해야 하므로 O(N log N)의 오버헤드가 발생합니다.
**Action:** `sort()` 대신 `which.min(x)` 또는 `which.max(x)`를 사용하여 O(N) 선형 시간 복잡도로 성능을 최적화해야 합니다. (예: `names(sort(x))[1]` 대신 `names(which.min(x))`)
…h.min, O(N))으로 최적화

- Fix `R CMD check` NOTE about hidden `.semgrepignore` file by adding it to `.Rbuildignore`
Copilot AI review requested due to automatic review settings July 24, 2026 19:22

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

…h.min, O(N))으로 최적화

- Fix `R CMD check` NOTE about hidden `.semgrepignore` file by adding it to `.Rbuildignore`
…h.min, O(N))으로 최적화

- Fix `R CMD check` WARNING about hidden `.Rcheck` directory by adding it to `.Rbuildignore`
- Fix `R CMD check` NOTE about hidden `.semgrepignore` file by adding it to `.Rbuildignore`
Copilot AI review requested due to automatic review settings July 24, 2026 19:54

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

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

Comments suppressed due to low confidence (1)

.jules/bolt.md:21

  • The example names(which.min(x)) is incorrect: which.min(x) returns an integer index without names, so names(which.min(x)) yields NULL. To get the name of the minimum element, index the names of x using the result of which.min(x).
## 2025-02-13 - R 언어에서 정렬 기반 최소/최대값 탐색(sort) 최적화
**Learning:** R에서 최솟값 또는 최댓값을 찾기 위해 `sort(x)[1]`이나 `names(sort(x))[1]`을 사용하면 전체 배열을 정렬해야 하므로 O(N log N)의 오버헤드가 발생합니다.
**Action:** `sort()` 대신 `which.min(x)` 또는 `which.max(x)`를 사용하여 O(N) 선형 시간 복잡도로 성능을 최적화해야 합니다. (예: `names(sort(x))[1]` 대신 `names(which.min(x))`)

Comment thread .Rbuildignore
Comment on lines +25 to +27
^\.semgrepignore$
^\.\.Rcheck$
^\.\.Rcheck/.*
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