Skip to content

perf(ipd): evaluate explicit factor levels with equivalence coverage - #323

Draft
seonghobae wants to merge 2 commits into
masterfrom
bolt-factor-optimization-5100846848171526656
Draft

perf(ipd): evaluate explicit factor levels with equivalence coverage#323
seonghobae wants to merge 2 commits into
masterfrom
bolt-factor-optimization-5100846848171526656

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Current exact authority

  • protected base: master@f87c2324f1686135e57d8730c1b0b9420874f300
  • exact head: 249217b00d92802ab4bccaafcb02e00fe093cb84
  • lifecycle: Draft / ordinary two-form equivalence characterized / performance claim unproven
  • effective files: R/aFIPC.R, tests/testthat/test-ipdgroup-factor-equivalence.R

Review and repair

The production delta replaces as.factor(c(rep("oldForm", ...), rep("newForm", ...))) with factor(..., levels = c("newForm", "oldForm")) in the IPD grouping path.

The generated PR originally claimed roughly 30–50% factor-construction improvement without a reproducible representative benchmark or profile. Unit success cannot establish that number or a buyer-visible autoFIPC() speedup, so it is not merge authority for this lane.

A normal descendant restores .jules/bolt.md byte-for-byte to protected authority (7d3c603f9991196ce123271a6c1e129156f24fd8). This local expression experiment is not repository-wide performance doctrine. No force push or destructive rebase was used.

The new deterministic characterization checks the exact protected factor object against the explicit-level candidate for several non-empty old/new form cardinalities, including factor levels and internal encoding through expect_identical(). Synthetic cardinalities here are unit-test fixtures only; they are not psychometric or performance acceptance data.

Remaining RED / GREEN acceptance

The characterization currently covers the product path where both forms contribute observations. Before claiming behavior equivalence for the whole public input domain, either prove the maintained autoFIPC() path rejects/never reaches IPD with an empty form before this expression, or characterize and preserve the protected one-sided/empty-factor semantics explicitly. Do not silently redefine that edge case to make the optimization pass.

Performance promotion additionally requires a protected-vs-candidate benchmark on the actual IPD path using representative/right-cleared form data under the same R/mirt/runtime state, with respondent/item cardinalities, warm-up policy, repeated wall-time distribution (at least median and p95), allocation/GC evidence, and profile evidence showing this constructor is material. Do not extrapolate a micro-expression timing to calibration latency.

Keep Draft until one unchanged exact head has terminal R CMD/test, applicable security/SAST/CodeQL, current review findings resolved, and qualifying independent review. No self-approval, source-neutral retrigger, gate weakening, generated Bolt doctrine, force push, or destructive rebase.

Replaced `as.factor()` with `factor(..., levels=c('newForm', 'oldForm'))` to avoid O(N) overhead associated with level inference and string sorting during the factor creation.
@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.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 2 potential issues.

Devin Review

Comment thread .jules/bolt.md Outdated
Comment on lines +19 to +21
## 2026-09-02 - R 언어에서 factor 생성 시 명시적 수준 지정으로 O(N) 오버헤드 최적화
**Learning:** R에서 `as.factor()`를 사용해 요인을 생성하면 데이터를 스캔하고 정렬하여 레벨을 추론하는 오버헤드가 발생합니다.
**Action:** 레벨이 이미 알려진 경우 `factor(..., levels = c(...))` 형식으로 레벨을 명시적으로 제공하여 추론 과정을 우회하고 성능을 최적화할 수 있습니다.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Optimization remains linear

Explicit levels skip discovery and sorting, but factor() still encodes every observation. The O(N) elimination claim overstates the optimization.

Devin Review

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

Comment thread R/aFIPC.R
Comment on lines +616 to +619
factor(c(
rep('oldForm', nrow(oldformYDataK)),
rep('newForm', nrow(newformXDataK))
))
), levels = c('newForm', 'oldForm'))

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: Group reference semantics stay stable

as.factor() ordered these labels as newForm, then oldForm. The explicit order preserves encoding and reference-group selection across every estimation branch.

Devin Review

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

@seonghobae
seonghobae marked this pull request as draft September 6, 2026 04:03
@seonghobae seonghobae changed the title ⚡ Bolt: 최적화: factor 레벨 명시 지정으로 as.factor() O(N) 오버헤드 제거 perf(ipd): evaluate explicit factor levels with equivalence coverage Sep 6, 2026
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