Skip to content

Write the host-speed and fit-memory ledgers at rebalance and fit end, not every generation - #70

Merged
eliotmcintire merged 1 commit into
developmentfrom
hostspeed-merge-rarely
Nov 7, 2026
Merged

eliotmcintire merged 1 commit into
developmentfrom
hostspeed-merge-rarely

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

Fits were stalling every generation while the master re-saved two large shared files that record how fast each host is, with all workers idle. They now save them every 100 generations and when the fit ends.

Affects: Fit speed only: about 2.9 s saved per generation with today's ledger (8 s at a full 30-day window); results and cached generations are unchanged.

Technical details

Defect: R/DEoptim.R:420-422 called .recordHostSpeed() and .recordFitMemory() after every generation, and each went through .replaceRecords() (R/hostSpeed.R:20-27), which reads and rewrites the whole hostSpeed.rds (8.3 MB, 367k rows) and fitMemory.rds under the lock. On a copy of the live ledger this cost 2.90 s per generation before, and 0.02 s after (plus one 2.8 s flush per 100 generations, 0.049 s per generation on average).

Fix: DEoptimIterative() passes a pending environment; .replaceRecords() keeps the rows there, and the new .flushRecords() writes them in one locked read-modify-write per file, before each rebalance (which reads them) and in on.exit(). File names, columns and record semantics are unchanged, so older clusters versions keep sharing the files. A fit that is killed loses its records since the last flush (at most 100 generations).

Tests (tests/testthat/test-hostSpeed.R): a flushed buffer gives the same ledgers as per-record writes, and an 8-generation fit with rebalance every 3 writes each ledger at most ceiling(8/3)+1 times (8 on base) with data visible at each rebalance; the second fails on base. Full suite: 1368 pass, 0 fail on the branch; 1361 pass, 0 fail on base. R CMD check --no-manual (scratch library, DT absent so _R_CHECK_FORCE_SUGGESTS_=false): 0 errors, 0 warnings, 3 existing notes.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

…very generation

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Nov 7, 2026
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.30%. Comparing base (fa81d7e) to head (d4f8386).

Additional details and impacted files
@@               Coverage Diff               @@
##           development      #70      +/-   ##
===============================================
+ Coverage        77.16%   77.30%   +0.14%     
===============================================
  Files               24       24              
  Lines             2238     2252      +14     
===============================================
+ Hits              1727     1741      +14     
  Misses             511      511              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eliotmcintire
eliotmcintire merged commit 7bf89b9 into development Nov 7, 2026
14 checks passed
@eliotmcintire
eliotmcintire deleted the hostspeed-merge-rarely branch November 7, 2026 22:11
eliotmcintire added a commit that referenced this pull request Nov 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant