Optimizing Packwerk for Large Monoliths: Seeking Workflow Suggestions

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

:wave: hello from GitHub! We are still in the early stages of utilizing packwerk but it has been brought up that it is fairly slow to run for every PR against our admittedly large monolith. What workflows do other organizations use for packwerk? Do you require all deprecated_references.yml files to be updated as part of the content of every PR? Or do you do something out of band? Or is the speed just not an issue?

We at gusto are looking into performance improvements. At the same time we don’t yet have check as a blocking check on CI. We did recently turn on validate as a blocking step! Slowly getting there :slightly_smiling_face:

great to hear @stephan! I’m hacking on a branch to parallelize the run and I’m seeing about 3x perf improvement so far. I should have something pushed tomorrow. I’ll let you know if you are interested.

it also makes your computer double as a space heater if your monolith is big enough :smile:

Message originally sent by slack user U78DVPB73JQ

Heater? We can probably cook food on ours :sweat_smile:

nice! Yes we are interested! Also, my room is a bit cold so I could doubly benefit :slightly_smiling_face:

It’s an extremely rough proof of concept right now but the basic idea if to run file_processor.call in parallel processes. There is quite a lot of refactoring needed because the current implementations rely on mutating a reference_lister but I’m fairly confident that is not a necessary mutation and that work can be done on the parent process after the parallel execution is done https://github.com/Shopify/packwerk/compare/main...mclark:parallel-packwerk

Message originally sent by slack user U783MOJYF8Z

Shopify is running packwerk checks in parallel to tests, and also splitting the packwerk run over 4 parallel workers.

<@U783MOJYF8Z> what about on dev machines?

Message originally sent by slack user U783MOJYF8Z

Usually they don’t have to run it on the whole code base.

Message originally sent by slack user U783MOJYF8Z

If they do, it takes a long time. It’s a problem I’d like to fix but we have no resources for right now.

Message originally sent by slack user U783MOJYF8Z

When I last checked, >>80% of time was spent parsing Ruby code in a full run.

Message originally sent by slack user U783MOJYF8Z

We had an experiment using a faster parser, which lead to a 5x speedup. Things came up though and we had to drop that work.

oh that’s interesting! I briefly looked into what parser options there were but didn’t find a clear alternative that would work. I’d be interested to hear what you were considering. The parallel gem has been amazingly simple to leverage so I just kept ploughing forward with that for now.

Message originally sent by slack user U783MOJYF8Z

https://ruby-doc.org/core-2.7.0/RubyVM/AbstractSyntaxTree.html