Skip to content

fix(scheduling): follow-up to #771 — accurate runBlocking reasons and two cancel-safety fixes - #774

Draft
tstapler wants to merge 16 commits into
mainfrom
backlog/stelekit-scheduling-hygiene
Draft

tstapler wants to merge 16 commits into
mainfrom
backlog/stelekit-scheduling-hygiene

Conversation

@tstapler

@tstapler tstapler commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #771, which merged before its review finished. That review failed one criterion: many runBlocking justification comments were false. This fixes that and what a later verify pass found.

  • Tests that don't need real time now use runTest; the rest have an accurate reason.
  • Storage move: a cancel during release no longer leaves the graph marked "move in progress" until restart.
  • Scheduler: resume is non-cancellable in the adapter itself, not only in the legacy shim.
  • New audit test rejects runBlocking in production scheduling code.

Fixes #657

Review note

Commit 32d6cfadf (merge of main) silently reverted the conversions in eight test files; 08bcaf060 restores them. Tests passed both ways, so check the diff, not only CI.

Test plan

  • b4199200e: filtered jvmTest (storage-move coordinator, both audits; 52 tests) and detekt
  • 08bcaf060: bazel test //kmp:detekt //kmp:business_tests, filtered jvmTest on the converted classes
  • 32d6cfadf: testDebugUnitTest
  • Full jvmTest on the final head (CI)
  • GitSyncServiceRateLimitRetryTest skips locally (needs network)
  • Not run: any device or emulator test.

Known gaps, not fixed here

  • If quiesceStrategy.release throws (not a cancel), the "move in progress" flag still stays set.
  • WorkManagerTaskScheduler.resume loses the job if the enqueue fails after the snapshot is cleared.
  • The runBlocking guard does not cover jvmMain or a few scheduling-adjacent files (for example TickRunRecorder, SyncNotifier, jobs/WorkManager*).
  • The backlog reviewer has not reviewed this PR (its item closed when fix(scheduling): remove runBlocking from sync scheduler and make scheduling tests deterministic #771 merged).

…duling tests deterministic

WorkManagerSyncScheduler's schedule/cancel/pauseFor/resumeFor are now suspend.
Scheduling tests move to runTest where nothing needs real time; the rest say why.
… cannot drop periodic sync

Also corrects runBlocking justification comments found in review.
… and long waits

Sweeps every scheduling/worker test by content rather than by file name, and
records the test scope in the requirements.
Converts AndroidGitLegacyConfigSourceTest to runTest and annotates LfsTransferPolicyTest;
drops the test-scope note from the requirements.
…t, and fix SharePreviewPane race

The share preview test waited on a flag set before the compute finished, so
Copy could still be disabled when asserted (failed the Android job on #771).
Also covers a cancelled caller of the quiesce release.
…duling-hygiene

# Conflicts:
#	kmp/src/androidMain/kotlin/dev/stapler/stelekit/git/WorkManagerSyncScheduler.kt
#	kmp/src/androidUnitTest/kotlin/dev/stapler/stelekit/db/AndroidGraphMoveQuiesceStrategyTest.kt
#	kmp/src/androidUnitTest/kotlin/dev/stapler/stelekit/db/QuiesceRealFlushTest.kt
#	kmp/src/androidUnitTest/kotlin/dev/stapler/stelekit/platform/ml/DepthModelDownloaderTest.kt
#	kmp/src/androidUnitTest/kotlin/dev/stapler/stelekit/wiring/RepoGateSharedEntryPointTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncCancelBoundaryTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncServiceAutoCommitTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncServicePublishFailureTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncServiceRateLimitRetryTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncServiceScheduledSyncTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/GitSyncServiceSingleFlightTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/PausedRetryNowAndDurabilityTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/ResolveGateKeyFailureTest.kt
#	kmp/src/businessTest/kotlin/dev/stapler/stelekit/git/SyncSingleFlightRegressionTest.kt
… convert 7 more

The merge of main silently took the squash-merged #771 text in eight test files.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

JVM Load Benchmark (Desktop)

0 regressed · 3 improved · 2 unchanged · 0 new · 0 removed

jvm/GraphLoad

Benchmark Base Head Change
phase2Ms 1 ms 0 ms 🟢 -100.0% ▰▰▰▰▰
totalMs 2 ms 1 ms 🟢 -50.0% ▰▰▰▰▰

jvm/WriteLatency

Benchmark Base Head Change
jankBaselineP95Ms 44 ms 26 ms 🟢 -40.9% ▰▰▰▰▰
2 unchanged

jvm/GraphLoad

Benchmark Base Head Change
phase1TtiMs 0 ms 0 ms ⚪ n/a (base is 0)
phase3Ms 1 ms 1 ms ⚪ 0.0% ▱▱▱▱▱
Environment
Base Head
branch main HEAD
gitSha 5e67595d9 b3683ad3b
graphConfig xlarge xlarge
pageCount 230 230

A change counts when it is ≥ 5% and, where the data allows, statistically significant. Judged: 5 by threshold only (point estimates).

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

JVM Load Benchmark: profiling details

Flamegraphs (this PR) **Allocation** — object allocation pressure (JDBC/SQLite churn)

Alloc flamegraph not available

CPU — method-level hotspots by on-CPU time

CPU flamegraph not available

Top allocation hotspots (this PR) `34%` byte[]_[k] `6.8%` java.lang.String_[k] `6.7%` int[]_[k] `5.4%` java.lang.Object[]_[k] `5.3%` java.util.LinkedHashMap$Entry_[k]
Top CPU hotspots (this PR) `98.5%` /usr/lib/x86_64-linux-gnu/libc.so.6 `0.5%` /tmp/sqlite-3.51.3.0-ebe9ac6f-0c33-4819-8b00-a15a3ce532fd-libsqlitejdbc.so `0.2%` pthread_cond_signal `0.1%` SR_handler `0%` syscall

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Android Load Benchmark (API 30 x86_64 emulator)

2 regressed · 6 improved · 1 unchanged · 0 new · 0 removed

android/WriteLatency

Benchmark Base Head Change
writes 22 writes 17 writes 🔴 -22.7% ▰▰▰▱▱
jankFactor 1.67 x 2 x 🔴 +19.8% ▰▰▱▱▱
baselineP95Ms 9 ms 7 ms 🟢 -22.2% ▰▰▰▱▱
phase3P95Ms 15 ms 14 ms 🟢 -6.7% ▰▱▱▱▱

android/GraphLoad

Benchmark Base Head Change
phase1Ms 50 ms 27 ms 🟢 -46.0% ▰▰▰▰▰
phase3Ms 4762 ms 3463 ms 🟢 -27.3% ▰▰▰▱▱

android/SafIo

Benchmark Base Head Change
safPerFileMs 0.23 ms 0.13 ms 🟢 -43.5% ▰▰▰▰▰
safOverhead 7 x 4 x 🟢 -42.9% ▰▰▰▰▰
1 unchanged

android/SafIo

Benchmark Base Head Change
safDirectPerFileMs 0 ms 0 ms ⚪ n/a (base is 0)
Environment
Base Head
branch main HEAD
gitSha 5e67595d9 b3683ad3b
pageCount 530 530

A change counts when it is ≥ 5% and, where the data allows, statistically significant. Judged: 9 by threshold only (point estimates).

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

CI memory (Gradle diff-coverage job, 16 GB runner)

2 benchmarks (no base to compare with)

ci-memory/diff-coverage

Benchmark Value Range
peak_used [max] 8961 MB —
min_available [min] 6739 MB —
Environment
Head
sha b3683ad3b22297e68043ce295295b1f30badecbd

Head-only report: add a base to see changes.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

CI memory (Bazel Android build, 16 GB runner)

2 regressed · 0 improved · 0 unchanged · 0 new · 0 removed

ci-memory/android-build

Benchmark Base Head Change
peak_used [max] 2064 MB 11989 MB 🔴 +480.9% ▰▰▰▰▰
min_available [min] 13636 MB 3711 MB 🔴 -72.8% ▰▰▰▰▰
Environment
Base Head
sha 5e67595d93450309f95abd43cbd36687e101a94e b3683ad3b22297e68043ce295295b1f30badecbd

A change counts when it is ≥ 10% and ≥ 500 absolute and, where the data allows, statistically significant. Judged: 2 by threshold only (point estimates).

This branch has not been deployed

No deployments
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.

Scheduling hygiene: runBlocking audit and real-clock test polling

1 participant