[PR #4635] [MERGED] Skip idle NoodleR reserve scans and back off disabled Noodle refresh polls #6450

Closed
opened 2026-10-23 04:10:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4635
Author: @Gunterlie
Created: 8/5/2026
Status: ✅ Merged
Merged: 8/5/2026
Merged by: @Gunterlie

Base: staging ← Head: noodler-for-the-cpu-poor


📝 Commits (3)

  • 943b27e Skip idle NoodleR reserve scans and back off disabled refresh polls (#4630)
  • b480e7b Merge branch 'staging' into noodler-for-the-cpu-poor
  • ab17dff Use an existence check for the idle reserve poll and cover the remaining idle-state combination

📊 Changes

5 files changed (+33 additions, -2 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/services/noodle/noodle-autopost-scheduler.service.ts (+14 -0)
📝 packages/server/src/services/noodle/noodle-refresh-scheduler.service.ts (+4 -1)
📝 packages/server/src/services/storage/noodle.storage.ts (+6 -0)
📝 scripts/regressions/noodle-scheduler.regression.ts (+8 -1)

📄 Description

Why

Two Noodle background schedulers wake every 60 seconds forever, even with the features disabled and nothing to do. On a phone/Termux install that is a permanent idle drain for no user-visible benefit (#4630, found during a mobile-battery investigation).

  • The NoodleR reserve poll called reconcileNoodlerReserve before any settings check. That path full-scans noodlerPreparedPosts and noodlePosts and JSON.parses every post's metadata — O(all posts) per minute on the file-native store, with automatic posting off and zero prepared rows.
  • The timeline-refresh poll re-armed at the 60 s cap when refreshesPerDay === 0, so a disabled schedule still woke 1440 times a day to learn nothing changed.

What changed

  • noodle-autopost-scheduler.service.ts: the periodic poll() now reads settings first and returns early when automatic posting is disabled and there are no prepared reserve rows to tidy. The one cheap read it does (listNoodlerPreparedPosts) replaces both full table materializations. The startup reconcile stays unconditional, per the scheduler's own comment about upgrades beginning their hold while posting is disabled.
  • noodle-refresh-scheduler.service.ts: a disabled schedule (refreshesPerDay === 0) now backs the poll off to 15 minutes instead of 60 seconds. Enabling the feature is noticed within one backoff window; nothing else changes about the retry/failure delays.
  • Extracted noodlerReservePollIsIdle so the skip condition is directly assertable, and covered both behaviors in noodle-scheduler.regression.ts.

Behavior when the features are enabled, or when prepared rows exist while disabled, is unchanged — reconciliation still runs so stale rows are still discarded.

Validation

  • pnpm check
  • pnpm regression:noodle

Run locally: server lint (tsc) passes; noodle-scheduler, noodle-autopost, and noodle-refresh-transaction regressions pass. Client eslint needs NODE_OPTIONS=--max-old-space-size=8192 in this sandbox (pre-existing OOM, unrelated to this change).

Test plan

  • Start the server with Noodler/automatic posting disabled and no prepared posts; confirm no prepared/post table scans fire on the 60 s poll (log or breakpoint in reconcileNoodlerPreparedPosts), and that the startup reconcile still runs once.
  • With automatic posting disabled but prepared reserve rows present, confirm the poll still reconciles and discards them.
  • Enable automatic posting and verify preparation and publishing behave as before.
  • Set Noodle automatic timeline refresh to 0/day and confirm the scheduler re-arms at 15 min; re-enable it and confirm the next refresh runs on schedule.

Closes #4630.

Summary by CodeRabbit

  • Performance

    • Reduced background polling for inactive NoodleR reserve scans.
    • Disabled automatic posting schedules now pause reserve processing when no prepared posts are available.
    • Disabled automatic refresh schedules now check for updates every 15 minutes instead of every minute.
  • Bug Fixes

    • Improved scheduler behavior when automatic posting or refresh features are disabled.
    • Ensured timelines refresh appropriately after posting or refresh actions are disabled.
    • Added regression coverage for active and idle scheduling states.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4635 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/5/2026 **Status:** ✅ Merged **Merged:** 8/5/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `noodler-for-the-cpu-poor` --- ### 📝 Commits (3) - [`943b27e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/943b27e7ef388d2af8442d765c0726146f906750) Skip idle NoodleR reserve scans and back off disabled refresh polls (#4630) - [`b480e7b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b480e7b95864f2438c82388461101ec1a140c38e) Merge branch 'staging' into noodler-for-the-cpu-poor - [`ab17dff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ab17dff1353e1d1e80bc4600b5dc47635a3ac098) Use an existence check for the idle reserve poll and cover the remaining idle-state combination ### 📊 Changes **5 files changed** (+33 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/services/noodle/noodle-autopost-scheduler.service.ts` (+14 -0) 📝 `packages/server/src/services/noodle/noodle-refresh-scheduler.service.ts` (+4 -1) 📝 `packages/server/src/services/storage/noodle.storage.ts` (+6 -0) 📝 `scripts/regressions/noodle-scheduler.regression.ts` (+8 -1) </details> ### 📄 Description ## Why Two Noodle background schedulers wake every 60 seconds forever, even with the features disabled and nothing to do. On a phone/Termux install that is a permanent idle drain for no user-visible benefit (#4630, found during a mobile-battery investigation). - The NoodleR reserve poll called `reconcileNoodlerReserve` before any settings check. That path full-scans `noodlerPreparedPosts` **and** `noodlePosts` and `JSON.parse`s every post's metadata — O(all posts) per minute on the file-native store, with automatic posting off and zero prepared rows. - The timeline-refresh poll re-armed at the 60 s cap when `refreshesPerDay === 0`, so a disabled schedule still woke 1440 times a day to learn nothing changed. ## What changed - `noodle-autopost-scheduler.service.ts`: the periodic `poll()` now reads settings first and returns early when automatic posting is disabled **and** there are no prepared reserve rows to tidy. The one cheap read it does (`listNoodlerPreparedPosts`) replaces both full table materializations. The **startup** reconcile stays unconditional, per the scheduler's own comment about upgrades beginning their hold while posting is disabled. - `noodle-refresh-scheduler.service.ts`: a disabled schedule (`refreshesPerDay === 0`) now backs the poll off to 15 minutes instead of 60 seconds. Enabling the feature is noticed within one backoff window; nothing else changes about the retry/failure delays. - Extracted `noodlerReservePollIsIdle` so the skip condition is directly assertable, and covered both behaviors in `noodle-scheduler.regression.ts`. Behavior when the features are *enabled*, or when prepared rows exist while disabled, is unchanged — reconciliation still runs so stale rows are still discarded. ## Validation - [ ] `pnpm check` - [ ] `pnpm regression:noodle` Run locally: server `lint` (tsc) passes; `noodle-scheduler`, `noodle-autopost`, and `noodle-refresh-transaction` regressions pass. Client `eslint` needs `NODE_OPTIONS=--max-old-space-size=8192` in this sandbox (pre-existing OOM, unrelated to this change). ## Test plan - [ ] Start the server with Noodler/automatic posting disabled and no prepared posts; confirm no prepared/post table scans fire on the 60 s poll (log or breakpoint in `reconcileNoodlerPreparedPosts`), and that the startup reconcile still runs once. - [ ] With automatic posting disabled but prepared reserve rows present, confirm the poll still reconciles and discards them. - [ ] Enable automatic posting and verify preparation and publishing behave as before. - [ ] Set Noodle automatic timeline refresh to 0/day and confirm the scheduler re-arms at 15 min; re-enable it and confirm the next refresh runs on schedule. Closes #4630. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Performance** * Reduced background polling for inactive NoodleR reserve scans. * Disabled automatic posting schedules now pause reserve processing when no prepared posts are available. * Disabled automatic refresh schedules now check for updates every 15 minutes instead of every minute. * **Bug Fixes** * Improved scheduler behavior when automatic posting or refresh features are disabled. * Ensured timelines refresh appropriately after posting or refresh actions are disabled. * Added regression coverage for active and idle scheduling states. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:10:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6450
No description provided.