-
Notifications
You must be signed in to change notification settings - Fork 50
refactor(analyzer): split second_pass into resolve + write phases (#687) #688
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
Open
DvirDukhan
wants to merge
1
commit into
staging
Choose a base branch
from
dvirdukhan/parallel-second-pass
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+90
−11
Open
Changes from all commits
Commits
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
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.
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.
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.
Don't continue phase B after a worker failure.
Line 232 swallows any
_resolve_fileexception, but Lines 241-243 still emit graph edges. That makes correctness depend onCODE_GRAPH_INDEX_WORKERS:workers=1still fails fast, whileworkers>1can silently write a partial graph for the failed file. Track failed files and abort before phase B, or explicitly exclude/clear them before writing edges.🛠️ Proposed fix
done = 0 log_every = max(1, total // 50) if total else 1 + failed_files: list[Path] = [] if n_workers == 1: for fp in resolvable: _resolve_file(fp) done += 1 if done % log_every == 0 or done == total: @@ with ThreadPoolExecutor(max_workers=n_workers, thread_name_prefix="sa-resolve") as ex: futures = {ex.submit(_resolve_file, fp): fp for fp in resolvable} for fut in as_completed(futures): fp = futures[fut] try: fut.result() except Exception: - logging.warning( - "second_pass: resolution failed for %s: %s", - fp, exc, - ) + failed_files.append(fp) + logging.exception( + "second_pass: resolution failed for %s", + fp, + ) done += 1 if done % log_every == 0 or done == total: logging.info("second_pass: resolved %d/%d files", done, total) + + if failed_files: + raise RuntimeError( + f"second_pass aborted after symbol resolution failed for {len(failed_files)} file(s)" + ) # Phase B: serial edge writes, in the original file order so # the graph is bit-identical to the single-threaded path. for file_path in resolvable:🧰 Tools
🪛 Ruff (0.15.14)
[warning] 232-232: Do not catch blind exception:
Exception(BLE001)
🤖 Prompt for AI Agents