import-linter icon indicating copy to clipboard operation
import-linter copied to clipboard

Two pass layers

Open seddonym opened this issue 3 years ago • 0 comments

Currently, checking layers for containers deep in the module hierarchy take a long time. I think this is because the current optimisations, which squash the layers under test, work best for shallower modules. For deep modules, there will be a lot of modules that are unsquashed and the shortest paths need to be checked repeatedly.

This PR experiments with a two-pass approach in which all the other non-ancestor modules are squashed in a first pass and then we see if there is at least one import between layers. In theory this would optimise for passing contracts, though it will be slower for failing contracts as it will then need to check the graph again to get the actual imports.

Unfortunately in its current form it is about twice as slow for the deep modules I sampled. I still think there is potential with this approach but it needs more thought. Profiling the code is probably the next step to understand what is taking a long time.

seddonym avatar Sep 02 '22 11:09 seddonym