From 6d3864302091479f7e17f1ec7b20dd413edeaa60 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Tue, 14 Jul 2026 07:13:12 -0600 Subject: [PATCH 1/4] Require barry >= 0.2.2 and make long computations interruptible barry 0.2.2 (USCbiostats/barry#24) fixes a catastrophic hash-collision bug that made init_defm() appear to hang for models with many outcome columns: all support statistics landed in a single unordered_map bucket, degrading support enumeration to O(4^ncol). A 16-outcome, order-1 model that previously never finished initializing now takes seconds. The LinkingTo requirement ensures defm is compiled against fixed headers. This also defines BARRY_USER_INTERRUPT as Rcpp::checkUserInterrupt() in every translation unit that includes barry, enabling barry's built-in interrupt checkpoint (every 1000 support iterations). Long-running calls such as init_defm() can now be stopped with Ctrl-C from an interactive session instead of requiring a force-kill. Verified via setTimeLimit(), which uses the same R_CheckUserInterrupt checkpoint: a ~20s init aborts at the 3s limit with a clean R error and no crash. A model interrupted mid-initialization should be rebuilt before further use (same caveat as any error thrown during init). All 25 tinytest results pass against barry 0.2.2. Co-Authored-By: Claude Fable 5 --- DESCRIPTION | 4 ++-- NEWS.md | 13 +++++++++++++ src/counters.cpp | 5 +++++ src/defm-object.cpp | 5 +++++ src/terms.cpp | 5 +++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f2016f6..0e7afd8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: defm Type: Package Title: Estimation and Simulation of Multi-Binary Response Models -Version: 0.2.1.0 +Version: 0.2.2.0 Authors@R: c( person("George", "Vega Yon", role=c("aut", "cre"), email="g.vegayon@gmail.com", comment = c(ORCID = "0000-0002-3171-0844")), @@ -23,7 +23,7 @@ Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.3 -LinkingTo: Rcpp, barry +LinkingTo: Rcpp, barry (>= 0.2.2) Imports: Rcpp, stats diff --git a/NEWS.md b/NEWS.md index 910594c..a5f11d7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# defm 0.2.2.0 + +* Requires `barry` (>= 0.2.2), which fixes a hash-collision bug that made + `init_defm()` appear to hang for models with many outcome columns + (USCbiostats/barry#24). A 16-outcome model that previously never finished + initializing now takes seconds. + +* Long-running computations (e.g., the support enumeration in `init_defm()`) + can now be interrupted from R with Ctrl-C. Note that a model interrupted + mid-initialization is left partially initialized and should be rebuilt + with `new_defm()` before further use. + + # defm 0.2.1.0 * Returning to CRAN. diff --git a/src/counters.cpp b/src/counters.cpp index 194d796..92779d3 100644 --- a/src/counters.cpp +++ b/src/counters.cpp @@ -1,4 +1,9 @@ #include + +// Lets barry check for user interrupts (Ctrl-C) during long-running +// computations such as the support enumeration in init_defm(). +#define BARRY_USER_INTERRUPT Rcpp::checkUserInterrupt(); + #include #include diff --git a/src/defm-object.cpp b/src/defm-object.cpp index f1075ad..4a35956 100644 --- a/src/defm-object.cpp +++ b/src/defm-object.cpp @@ -1,4 +1,9 @@ #include + +// Lets barry check for user interrupts (Ctrl-C) during long-running +// computations such as the support enumeration in init_defm(). +#define BARRY_USER_INTERRUPT Rcpp::checkUserInterrupt(); + #include #include diff --git a/src/terms.cpp b/src/terms.cpp index 73b8452..4d5aa22 100644 --- a/src/terms.cpp +++ b/src/terms.cpp @@ -1,4 +1,9 @@ #include + +// Lets barry check for user interrupts (Ctrl-C) during long-running +// computations such as the support enumeration in init_defm(). +#define BARRY_USER_INTERRUPT Rcpp::checkUserInterrupt(); + #include "barry/barry.hpp" #include "barry/models/defm.hpp" #include "defm-common.h" From d5088ca562bb49f239ab74dd945da5662f2fa44b Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Wed, 15 Jul 2026 12:41:58 -0600 Subject: [PATCH 2/4] Adding the remotes field in the description (will remove once the package lands on CRAN) --- DESCRIPTION | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 0e7afd8..05a730c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,3 +32,5 @@ Depends: stats4 Suggests: texreg, tinytest, barry +Remotes: + USCbiostats/barryr From d0b8d78dabaf3ed14e7dc7e61467c3a28e8c3c23 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Wed, 15 Jul 2026 13:00:30 -0600 Subject: [PATCH 3/4] ci: install barry 0.2.2 from barryr PR branch until it reaches CRAN CI could not resolve `barry (>= 0.2.2)`: CRAN only has 0.2.1, and pak's `deps::.` (used by setup-r-dependencies) does not consume the DESCRIPTION `Remotes:` field when a satisfying-named package exists on CRAN, so the GitHub source for the newer barry was never considered. Add the barryr PR branch as an explicit `extra-packages` entry in every workflow that installs dependencies. The action passes extra-packages straight to `pak::lockfile_create()`, which does honor an explicit remote spec; verified locally with pak 0.10.0 in a clean library that the graph now solves with barry -> 0.2.2 from the branch. All three entries are temporary and must be removed once barry 0.2.2 is on CRAN (tracked via USCbiostats/barryr#8); each is commented as such. Co-Authored-By: Claude Fable 5 --- .github/workflows/copilot-setup-steps.yml | 4 ++++ .github/workflows/coverage.yaml | 4 ++++ .github/workflows/pkgdown.yaml | 4 ++++ .github/workflows/r.yml | 11 +++++++++++ 4 files changed, 23 insertions(+) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 27eaa75..30c14ef 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -36,7 +36,11 @@ jobs: - name: Install dependencies uses: r-lib/actions/setup-r-dependencies@v2 with: + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the + # barryr PR branch. Remove once barryr 0.2.2 is released + # (USCbiostats/barryr#8). extra-packages: | any::rcmdcheck any::tinytest + USCbiostats/barryr@fix/freqtable-hash-collisions needs: check diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 8807b99..6caaab9 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -20,8 +20,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the + # barryr PR branch. Remove once barryr 0.2.2 is released + # (USCbiostats/barryr#8). extra-packages: | any::covr + USCbiostats/barryr@fix/freqtable-hash-collisions needs: check - name: Running coverage diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 68c1a7b..8d71e11 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -41,9 +41,13 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the + # barryr PR branch. Remove once barryr 0.2.2 is released + # (USCbiostats/barryr#8). extra-packages: | any::pkgdown local::. + USCbiostats/barryr@fix/freqtable-hash-collisions needs: website - name: Build site diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 1412d0d..4a6db17 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -25,6 +25,13 @@ jobs: use-public-rspm: true - uses: r-lib/actions/setup-r-dependencies@v2 + with: + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the + # barryr PR branch. Remove once barryr 0.2.2 is released + # (USCbiostats/barryr#8). The DESCRIPTION Remotes field is not + # honored by pak's `deps::.`, so the source must be listed here. + extra-packages: | + USCbiostats/barryr@fix/freqtable-hash-collisions - name: Build package run: R CMD build . @@ -73,8 +80,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the + # barryr PR branch. Remove once barryr 0.2.2 is released + # (USCbiostats/barryr#8). extra-packages: | any::rcmdcheck + USCbiostats/barryr@fix/freqtable-hash-collisions needs: check - uses: r-lib/actions/check-r-package@v2 From e424fe4554fdce24ae238c81f1ac6fef5a692444 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Wed, 15 Jul 2026 13:10:41 -0600 Subject: [PATCH 4/4] ci: point barry remote at barryr main now that #8 is merged USCbiostats/barryr#8 is merged, so barryr's main branch is barry 0.2.2. Drop the PR-branch ref from the extra-packages remotes; plain USCbiostats/barryr now resolves to 0.2.2 and won't break when the branch is deleted. Verified with pak 0.10.0 in a clean library: the graph solves with barry -> 0.2.2 from barryr main (commit fdd41d5). Still temporary: remove these extra-packages entries entirely once barry 0.2.2 reaches CRAN. Co-Authored-By: Claude Fable 5 --- .github/workflows/copilot-setup-steps.yml | 7 +++---- .github/workflows/coverage.yaml | 7 +++---- .github/workflows/pkgdown.yaml | 7 +++---- .github/workflows/r.yml | 17 ++++++++--------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 30c14ef..012f9f0 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -36,11 +36,10 @@ jobs: - name: Install dependencies uses: r-lib/actions/setup-r-dependencies@v2 with: - # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the - # barryr PR branch. Remove once barryr 0.2.2 is released - # (USCbiostats/barryr#8). + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from + # barryr's main branch. Remove once barry 0.2.2 is on CRAN. extra-packages: | any::rcmdcheck any::tinytest - USCbiostats/barryr@fix/freqtable-hash-collisions + USCbiostats/barryr needs: check diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 6caaab9..b993515 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -20,12 +20,11 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the - # barryr PR branch. Remove once barryr 0.2.2 is released - # (USCbiostats/barryr#8). + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from + # barryr's main branch. Remove once barry 0.2.2 is on CRAN. extra-packages: | any::covr - USCbiostats/barryr@fix/freqtable-hash-collisions + USCbiostats/barryr needs: check - name: Running coverage diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 8d71e11..50a5d65 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -41,13 +41,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the - # barryr PR branch. Remove once barryr 0.2.2 is released - # (USCbiostats/barryr#8). + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from + # barryr's main branch. Remove once barry 0.2.2 is on CRAN. extra-packages: | any::pkgdown local::. - USCbiostats/barryr@fix/freqtable-hash-collisions + USCbiostats/barryr needs: website - name: Build site diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 4a6db17..d6af285 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -26,12 +26,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the - # barryr PR branch. Remove once barryr 0.2.2 is released - # (USCbiostats/barryr#8). The DESCRIPTION Remotes field is not - # honored by pak's `deps::.`, so the source must be listed here. + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from + # barryr's main branch. Remove once barry 0.2.2 is on CRAN. + # (The DESCRIPTION Remotes field is not honored by pak's + # `deps::.`, so the source must be listed here.) extra-packages: | - USCbiostats/barryr@fix/freqtable-hash-collisions + USCbiostats/barryr - name: Build package run: R CMD build . @@ -80,12 +80,11 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from the - # barryr PR branch. Remove once barryr 0.2.2 is released - # (USCbiostats/barryr#8). + # TEMPORARY: barry (>= 0.2.2) is not on CRAN yet; pull it from + # barryr's main branch. Remove once barry 0.2.2 is on CRAN. extra-packages: | any::rcmdcheck - USCbiostats/barryr@fix/freqtable-hash-collisions + USCbiostats/barryr needs: check - uses: r-lib/actions/check-r-package@v2