Repository navigation
Stop holding every analysed app in memory between cache rebuilds - #36
Merged
Merged
Conversation
getAllApps selected apps.* and the result was memoised for the life of the process, so every app's full analysis (raw trackerscan output, Info.plists, per-match class lists) and both App Store records stayed resident. The site builders only read success and trackers, so project those in SQL, keep only the fields the builders use, and drop the rows once the views are built. Concurrent rebuilds for one signature still share a single load. Claude-Session: https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1
The analyser asked for work every 30 seconds even when there was none, so the website never went quiet long enough for Railway to sleep it. Double the wait between empty polls from IDLE_SLEEP_MIN (60s) up to IDLE_SLEEP_MAX (1800s), resetting as soon as an app is assigned, and retry transient curl failures for up to a minute so requests survive the server waking up. The analyser's last check-in was only held in memory, so a woken process reported it offline until the next ping. Store it in an analyser_heartbeat row and read it back once per process. Claude-Session: https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1
Member
Author
|
CI is red at the The failure is not from this PR: it doesn't touch
I couldn't find an existing fix to port, and I haven't regenerated the lockfile here. A re-run would fail the same way, so I haven't triggered one. Proposed fix, as a separate PR:
Generated by Claude Code |
This reverts commit 9e96967, which now lives on claude/analyser-idle-backoff so the memory change can be reviewed and merged on its own. Claude-Session: https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1
kasnder
marked this pull request as ready for review
October 20, 2026 07:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getAllAppsselectedapps.*, andgetAllAppsForSignaturekept the result inallAppsMemofor as long as the process ran. That kept two things in memory for every analysed app:buildSiteDataandbuildReverseIndexonly readanalysis.successandanalysis.trackers.models/Apps.js: select onlyappid,analysed,details, the storefront details and{success, trackers}. The projection happens in SQL, so the rest of each analysis never reaches Node. Analyses that are not JSON objects (SQLNULL, JSONnull, arrays) pass through unchanged, so the builders treat them exactly as before.routes/index.js: keep only the fields the builders read, and drop the rows once the cached views are built. Concurrent rebuilds for the same signature still share one load, through an in-flight promise.The cached output is unchanged, so
SCHEMA_VERSIONdoes not need a bump.The polling back-off that briefly sat on this branch was moved to its own PR, #38. The revert commit here leaves the branch identical to the memory change alone.
Testing
Synthetic benchmark with about 2,820 apps, roughly the production count. The App Store records are real iTunes lookups, and the analyses are shaped like
trackerscan_to_analysis.jsoutput. Each variant ran in a separate process:The reverse index and aggregate statistics were identical between the two versions in each run.
Ran the new query against a local Postgres 16 with an ordinary row and with SQL
NULL, JSONnull,{"success":false}and array analyses. Each returned what the old code expected.npm test: 164/164 pass.CI will fail at the
npm auditstep until #37 merges; the advisories are unrelated to this change.https://claude.ai/code/session_01Fi3H98SycMK13rrr8ySSU1