Skip to content

Recompilation speedup: move StaticFEPlug to a pipeline

Alex Gleason requested to merge cycles-router into develop

#2651 (closed)

Over the next few days I'll be sending over about ten (maybe twenty) granular MRs to speed up recompilation by limiting compile-time dependencies and breaking compile-time cycles.

A cycle occurs when A -> B -> C -> A

(-> means "depends on" and the letter are modules)

A compile-time cycle occurs when any module in a cycle has a compile-time dependency on another module. When this happens, changing any file in the cycle will cause the entire cycle to recompile. What's worse is that cycles can overlap, making one cycle's recompilation trigger the recompilation of a whole other cycle.

You can verify this change by running mix xref graph --format cycles --label compile before and after this change:

Screenshot_from_2021-05-28_12-57-35

https://www.diffchecker.com/5402rgcv

It reduces the length of one cycle, but when combined with the other MRs I send, it will eventually break a cycle. In my local dev, I've already eliminated all cycles and have the coveted "No cycles found" message, but I've decided to send many granular MRs so they can be reviewed individually. You'll have to trust that this will eventually lead us to 0.

In this particular case, it turns out that putting a Plug in pipe_through causes it to become a compile-time dependency of Router. Who knew. 🤷 Moving it to a pipeline turns it into a runtime dependency, breaking cycles.

Edited by Alex Gleason

Merge request reports