Caching to PLT single modules? Dialyzer

Some projects with large modules (example generated protobuf) take very long for dialyzer to parse every run. These modules don’t change until they get regenerated, is it possible to get dialyzer to add to PLT certain modules in an app without adding the entire app to the PLT?

I tried using

> dialyzer --add_to_plt -c _build/dev/lib/app/ebin/Elixir.Table.Item.beam --plt priv/plts/dialyzer.plt

Adding information to priv/plts/dialyzer.plt...=ERROR REPORT==== 24-Oct-2020::08:43:55.814352 ===
Error in process <0.83.0> with exit value:
{undef,
    [{elixir_erl,debug_info,
         [core_v1,'Elixir.Table.Item'

And my module has @compile :debug_info defined.

Also the solution would ideally probably have to live at the dialyxer level so if the module changed that got cached it should be readded to the PLT.

(We assume we dont need to walk any dependencies, nor parse config.ex because these modules are autogenerated)

PLTs exist only for dependencies. Including modules from your main project will not work. Moreover, the logic governing PLTs and really dialyzer itself is determined entirely upstream in dialyzer.erl in OTP, so changes there are much more… involved than PRs to Dialyxir.

For your case, I would recommend generating the protobufs into a separate library, and including it in mix.exs, so that you amortize the cost to 1x per regeneration. Andrea goes into his approach for that here https://andrealeopardi.com/posts/sharing-protobuf-schemas-across-services/

1 Like

Moved it over into a separate project, thanks.