Re-work how fine grained targets are processed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Currently, fine grained targets are processed per updated module. This can lead to files being processed multiple times (and also a bit hard to reason, but this may be subjective). I propose to reorganise them to be processed in topologically sorted order. So the algorithm would be like this:
- Process all edited files, calculate all fired triggers, chain them to find all invalid targets, check for blocking errors.
- Group targets per module, order them per SCC, then per same heuristics we use to order modules within SCCs in coarse grained incremental. Within module targets are ordered by line number, this is unchanged.
- Process targets in one module from the queue, calculate updated deps and fired triggers, update invalid targets queue (maintaining the sort order), check blockers
- Continue step 3 until no modules left in the queue at this SCC
- Flush error messages
- Continue steps 3-5 until no SCCs left
This way it is much less likely that we will reprocess the same module twice. This will probably give an especially significant performance gain for cold runs, where many modules are updated w.r.t. to remote cache. Also IMO this algorithm is easier to reason about (and more similar to what happens in coarse-grained mode).
This idea appeared some time ago, but was postponed. Filing an issue to not forget about this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing fine-grained incremental processing and the coarse-grained module-ordering logic. Compare the current per-updated-module flow with the proposed SCC-ordered target queue, including blocker checks and error flushing. Done means targets are processed in the stated order without unnecessary module reprocessing, with performance and behavior validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100