Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -16,3 +16,6 @@
## 2025-02-12 - R 언어에서 반복적인 mirt 모델 생성 시 불필요한 데이터프레임 부분집합 추출 최적화
**Learning:** R에서 데이터프레임의 특정 열을 추출하는 작업(`df[cols]`)은 O(N)의 메모리 복사를 수반합니다. `autoFIPC`에서 `mirt` 모델의 파라미터를 설정하거나 호출하는 과정 중에 `newformXDataK[colnames(newFormModel@Data$data)]` 코드가 반복해서 사용되었고, 심지어 `ncol()`을 위해 단순히 개수를 구할 때도 사용되어 불필요한 메모리 할당과 오버헤드를 초래했습니다.
**Action:** 조건문이나 반복문 내부에서 불필요하게 데이터프레임 부분집합 연산이 반복되지 않도록 외부에서 한 번만 `linkedFormData <- newformXDataK[colnames(newFormModel@Data$data)]`로 캐싱(caching)한 뒤, `ncol(linkedFormData)`와 `data = linkedFormData` 형태로 재사용하여 메모리 복사와 O(N) 오버헤드를 방지해야 합니다.
## 2026-09-02 - R 언어에서 특정 컬럼 이름을 가져올 때 불필요한 데이터 프레임 서브셋 추출 최적화
**Learning:** R에서 데이터 프레임의 부분집합을 만들 때(`df[cols]`), 단순히 해당 열의 이름을 얻기 위해서 `colnames(df[cols])`를 호출하는 것은 불필요하게 내부 데이터를 전부 복사하는 O(N)의 오버헤드를 발생시킵니다.
**Action:** 이미 모델 등에 열 이름 배열이 명시적으로 존재한다면, 데이터 프레임을 다시 서브셋팅하는 대신 해당 배열(`colnames(model@Data$data)`)을 직접 참조하여 O(1)의 성능으로 열 이름을 확보해야 합니다.
8 changes: 4 additions & 4 deletions R/aFIPC.R

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Verification result is undocumented

The contribution rules require a command and result summary. The PR lists a test command but records no outcome.

Devin Review

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

Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ autoFIPC <-
IPDItemCount <- 0

# IPD target item checking
newFormColNames <- colnames(newformXDataK[colnames(newFormModel@Data$data)])
oldFormColNames <- colnames(oldformYDataK[colnames(oldFormModel@Data$data)])
newFormColNames <- colnames(newFormModel@Data$data)
oldFormColNames <- colnames(oldFormModel@Data$data)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Column names remain aligned

Model inputs rebuild backing data from @Data$data; raw inputs fit against unchanged columns. Every surveyFA fallback disables item removal.

Devin Review

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


# ⚡ Bolt: Vectorized match() to avoid dynamic array growth overhead inside a for loop
idxNew <- match(newformCommonItemNames, newFormColNames)
Expand Down Expand Up @@ -749,8 +749,8 @@ autoFIPC <-
}
}

newFormColNames <- colnames(newformXDataK[colnames(newFormModel@Data$data)])
oldFormColNames <- colnames(oldformYDataK[colnames(oldFormModel@Data$data)])
newFormColNames <- colnames(newFormModel@Data$data)
oldFormColNames <- colnames(oldFormModel@Data$data)

# ⚡ Bolt: Cache parameter indices to avoid O(N) linear search inside loop
newScaleParmsItemIdxCache <- split(seq_len(nrow(NewScaleParms)), NewScaleParms$item)
Expand Down
Loading