Make @behaviour an export dependency instead of compile?

168 views
Skip to first unread message

Victor Rodrigues

unread,
Oct 7, 2020, 3:20:02 AM10/7/20
to elixir-lang-core
Hi there!

We have a project with hundreds of modules, and it has been pretty bad on recompilation times. I was waiting for 1.11 to see how that would improve, and it actually did, but only marginally (~10% less modules), still ~300 modules-ish on every change.

There’s definitely work to do in our end to reduce that dependency chain, but it seems `@behaviour` is a important culprit here.

I wonder if `@behaviour` could become a “export” type dependency in the future, does this make sense from the point of view of the compiler? From a user perspective, it looks to me it would be fine if modules that implement a behaviour would only need to recompile if callbacks changed. I think this would improve a lot on our case.

Thanks!

José Valim

unread,
Oct 7, 2020, 3:28:41 AM10/7/20
to elixir-l...@googlegroups.com
Unfortunately this is a bit complicated, implementation wise, because "@behaviour Foo" is just a regular attribute.

I assume that your @behaviour modules define both callbacks and functions, I would suggest splitting those for now into two separate modules and see how/if it changes things.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2e71f930-999b-46aa-9231-15b62838b0ccn%40googlegroups.com.

Victor Rodrigues

unread,
Oct 7, 2020, 4:25:32 AM10/7/20
to elixir-lang-core
Thanks José!

I suspect a lot of it might be the callbacks depending on remote types, but indeed, some of these modules have functions too, I'll work on it and experiment, thanks!

I wouldn't mind a `defbehaviour` at all eheh, if it would help reduce this coupling.

José Valim

unread,
Oct 7, 2020, 4:44:46 AM10/7/20
to elixir-l...@googlegroups.com
Remote types should not add compile time deps. If they do, it is a bug.

Victor Rodrigues

unread,
Oct 7, 2020, 4:56:36 AM10/7/20
to elixir-lang-core
I still need to understand this better, but from what I get, the remote type is a runtime dep of the module that defines the callback using it, but the module that implements the behaviour has a compile-time dependency on the module that defines the behaviour, and ends up recompiling whenever that remote type module changes, or anything it has a runtime dependency on.

José Valim

unread,
Oct 7, 2020, 5:33:20 AM10/7/20
to elixir-l...@googlegroups.com
Ah, that explains it. Since remote types are not checked at compilation time, I am inclined to not even make them runtime dependencies. Can you please open up an issue?

Victor Rodrigues

unread,
Oct 7, 2020, 5:36:36 AM10/7/20
to elixir-lang-core
Awesome 🚀

Reply all
Reply to author
Forward
0 new messages