Skip to content

fix(gset): stop globaltest hanging on strong contrasts - #565

Merged
phisanti merged 1 commit into
fantafrom
fix/globaltest-crash
Nov 27, 2026
Merged

phisanti merged 1 commit into
fantafrom
fix/globaltest-crash

Conversation

@phisanti

Copy link
Copy Markdown
Contributor

Problem

A lipidomics upload (317 samples, 78 contrasts, camera + globaltest) ran past its 3600 s compute timeout. The job never left fitting contrasts using globaltest....

.gt.getP falls back to the generalised F (.gt.genF → .gt.getC) when Imhof is too coarse, roughly p < 1e-8. In .gt.getC the series terms can underflow to exactly 0. rest then sticks at about 1.6e-13 from rounding, rest/mx stays just above eps = 1e-10, and no term is ever negative, so the repeat never exits. globaltest:::.getC upstream has the same loop.

Fix

  • .gt.getC stops after 50 consecutive exactly-zero terms. A single zero is not enough: two-eigenvalue spectra produce legitimate early zeros.
  • The series vectors are preallocated, and the loop calls mean.default, so it no longer copies them on every term. Results are the same bits.

Evidence

  • Real upload data, 95 lipid sets built from feature names: before the fix, contrast 1 had not finished after 300 s. After the fix, all 78 contrasts finish in 91 s, with 25 sets that would previously have hung.
  • 150 random eigenvalue spectra give bit-identical p-values with and without the fix.
  • New regression test with a hanging spectrum from simulated data (tests/testthat/fixtures/gt-underflow-lams.rds), run under a 120 s time limit.

The test suite was not run on the CI machine, which is currently off. test-gset-globaltest.R passes locally via load_all. The parity test against globaltest::gt was skipped because globaltest is not installed here.

When Imhof is too coarse (p below ~1e-8), globaltest falls back to the
generalised F. Its series terms can underflow to exactly 0, leaving the
remainder stuck just above the tolerance, so the loop never ends. A
lipidomics upload with 317 samples hung on its first contrast until the
compute timeout killed it. Upstream globaltest has the same loop.

The series now stops after 50 consecutive zero terms. P-values are
unchanged wherever the old code finished, and the loop no longer copies
its vectors on every term.
@phisanti
phisanti merged commit 2415f6c into fanta Nov 27, 2026
1 check failed
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93d58692-7f0f-486c-9df5-073be46be57e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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