Skip to content

Regenerate TICON datums on every core - #245

Merged
clarkbw merged 2 commits into
mainfrom
ticon/parallel-import
Oct 7, 2026
Merged

clarkbw merged 2 commits into
mainfrom
ticon/parallel-import

Conversation

@clarkbw

@clarkbw clarkbw commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

npm run import -w sources/ticon now runs one process per core, each taking every nth station. A forced datum regeneration spends seconds of CPU per station synthesizing the 19-year epoch, and all 4,838 stations ran in a single process. SHARDS sets the count, and SHARDS=1 runs one process. GESLA is downloaded before the processes start so they don't race to extract it.

A forced regeneration of the 304 meds stations (FORCE_DATUMS=meds) on this 20-core Mac:

Time
One process, engine beta.2 (what main installs) 877 s
Per-core processes, beta.2 130 s
Per-core processes, engine with openwatersio/slackwater#373 33 s

The per-core run's station files are byte-identical to the single-process run, both for the forced meds regeneration and for a run that reuses cached datums. Each station depends only on its own data. Round-robin assignment leaves some processes finishing early, since GESLA file sizes vary tenfold, but at 33 s that isn't worth a work queue.

Regenerating on main also rewrites the name or region of 569 stations, with or without this change. That is #244.

🤖 Generated with Claude Code

A forced datum regeneration spends about a second of CPU per station synthesizing the 19-year epoch, and the import ran all 4,838 stations in one process. `./import` now runs one shard per core (SHARDS overrides the count), each taking every nth station, and fetches GESLA before the shards start so they don't race to extract it. Each station depends only on its own data, so the output is identical to a single-process run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@slackwater/database@245

commit: 0393cb9

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Resolve the GESLA preparation race and validate that the shard count is a positive integer.

2 open findings
What changed in this PR

Parallelizes TICON imports across configurable shards and prefetches GESLA data.

Changes:

  • Adds round-robin shard selection via SHARDS/SHARD.
  • Launches parallel importer processes.
  • Documents shard configuration and GESLA prefetching.
File Summary
sources/​ticon/​README.md Documents parallel import behavior and shard configuration.
sources/​ticon/​import.ts Filters stations by shard; cached fallback paths can race during GESLA preparation.
sources/​ticon/​import Launches shard workers; needs safe GESLA preparation and validation for non-positive shard counts.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sources/ticon/import
Comment thread sources/ticon/import
A cache-reuse import skips the up-front GESLA fetch, but a station with no cached datums or harmonics still calls `ensureGeslaData`, and every shard could then download and extract into the same paths at once. `unzip` also fills GESLA_DIR in place, so a shard could read it half-extracted. The download and the extract now go to per-process paths and are renamed into place.

`./import` also rejects a SHARDS that is not a positive integer instead of importing nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clarkbw
clarkbw merged commit 452fcb8 into main Oct 7, 2026
5 checks passed
@clarkbw
clarkbw deleted the ticon/parallel-import branch October 7, 2026 15:56
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.

2 participants