Skip to content

Recompilation speedup: don't make MediaProxy be a compile-dep of Router

Alex Gleason requested to merge cycles-router-mediaproxy 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_13-13-40

https://www.diffchecker.com/2TQViXQh

This one small change is dramatic. It removes an entire compile-time cycle on its own, and it also reduces the size of 17 other cycles.

In a Router, calling scope creates a compile-time dependency on whatever module you pass, while get, post, etc do not.

Merge request reports