-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat(cli): analyze --all to re-index all registered repos (#253) #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
511f984
feat(cli): analyze --all to re-index all registered repos (#253)
azizur100389 1fb6bc3
fix(cli): resource-aware throttle for analyze --all (#1010 review)
azizur100389 6892c0d
fix(cli): remove --no-throttle bypass; warn on risky env-tuned thresh…
azizur100389 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be careful with this! Imagine having 100s of cloned repositories and somebody runs GitNexus with
--alloption and there's a possibility it may crash the computer because of CPU exhaustion. I'd implement a queue and depending on resource availability i'd start processing them. Also don't forget the pipeline itself also spawns subproceses. Maybe it would be faster to not to call the whole gitnexus but to call the ingestion pipeline with the necessary arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review — good catch, and I want to make sure I implement the right queue shape rather than guess and iterate.
Current state (for calibration)
The current implementation is strictly sequential —
spawnSyncblocks the for-loop until each child exits (analyze.ts:190–198), so only ONE analyze runs at any moment. Pipeline-internal parse workers are already CPU-bounded inside each child. That said, your concern about sustained load over 100s of repos is still valid — even sequential, that's hours of 100% CPU with no graceful pause.Which queue shape do you have in mind?
A few options with tradeoffs; happy to implement whichever you prefer:
(a) Throttled sequential with resource check. Stay 1-at-a-time, but check
os.loadavg()between children and pause if load > threshold. Downside:os.loadavg()returns[0, 0, 0]on Windows, so the gate is Unix-only unless we proxy through something else.(b)
--concurrency <n>with default 1. Opt-in parallelism for users who know their machine can handle it. Default 1 = current sequential behaviour. Downside: contradicts the CPU-exhaustion framing — parallel makes CPU pressure worse, not better — so I don't think this is what you meant, flagging for disambiguation.(c) Confirmation gate + estimated duration. Print
"About to re-index N repos sequentially. Estimated time: ~{N × avg}s. Pass --yes to confirm."and require-y, --yesfor non-interactive runs. Same pattern asclean --all --force. Makes the resource cost visible before the user commits to it.(d) Something else — happy to build it if you have a specific shape in mind.
The pipeline-direct suggestion
On
"call the ingestion pipeline with the necessary arguments"— I deliberately went child-process-per-repo to keep LadybugDB handles, progress bar, SIGINT, and the monkey-patched console cleanly isolated per repo. CallingrunFullAnalysisin-process would save ~1–2s process-startup per repo but means (i) a crash in one repo aborts the batch, (ii) state-reset hazards between iterations we'd need to prove idempotent. Happy to revisit if the queue design ends up needing in-process for some other reason — but I'd rather not bundle it in unless there's a concrete motivation.Will hold on code changes until you point at the shape you want. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very primitive but could be a good starting point
More information about the npm package: https://www.npmjs.com/package/systeminformation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the concrete pointer — implemented in `1fb6bc36` using `systeminformation` exactly as you sketched.
What shipped
Defaults match your sketch 1:1: 80% CPU / 85% memory thresholds, 1-second poll interval, simple `cpu > CPU_THRESHOLD || memUsed > MEM_THRESHOLD` predicate.
Shape: between each `--all` child spawn, the batch polls CPU + memory. If either metric is above threshold, it prints `⏸ Throttling — CPU X.X% / mem Y.Y% (thresholds 80% / 85%) — waiting before [i/N]...` and re-polls every second. When both drop below threshold, it prints `▶ Resuming — CPU X.X% / mem Y.Y%` and spawns the next child.
No max-wait timeout by design. A host pinned above threshold is exactly the case you asked us to protect, so bailing after some arbitrary deadline would silently defeat the safety. Ctrl-C is the user's graceful exit.
Escape hatches:
On broken metrics provider (e.g. `systeminformation` platform issue): the batch falls through WITHOUT throttling rather than hanging indefinitely. Unit-tested.
Pipeline-direct suggestion
Kept child-process-per-repo. The isolation story (each repo gets fresh LadybugDB handles, progress bar, monkey-patched console, SIGINT handler) is what lets one repo crash without corrupting the batch. Happy to revisit if you want to swap in-process for a specific reason later — but since your main concern (resource pressure) is now addressed at the orchestration layer, I'd rather not bundle that bigger change in here.
Tests
Local verification on the final commit:
CI running.