axelson

axelson

Scenic Core Team

We’re now on the day 2 talks!

ElixirConf US 2018 – Understanding Elixir’s (Re)compilation – Renan Ranelli

Elixir’s code-generation capabilities require a sophisticated compiler with complex dependency tracking. Given such complexity, it is often unclear why sometimes changing a single line in a single file triggers the recompilation of 100 other files. This talk aims to clarify that.

Most of the content presented in this talk was “discovered” while struggling with recompilations of 500+ files in a 2000+ .beam file Phoenix app. We learned things the hard way so that you don’t have to.

In this talk we are going to take a deep dive into what happens when you type “mix compile”, why and when modules need to be recompiled, and how compilation behavior interacts with umbrella apps. You will learn how to “debug” recompilation problems, which tools to use, and how to avoid common pitfalls.

Audience: Beginner, Intermediate, Advanced
Topics: compiling

All talks are available in the ElixirConf US 2018 Talks List or via the elixirconf2018 tag

Showing Posts 1 to 7

gon782

gon782

I like this talk and I think it’s good but it still doesn’t give me enough insight into our current compilation problems in a Phoenix project. We’ve ended up with a smaller version of the cited issue in the talk and recompilation currently takes 4-5 seconds which is enough to annoy us.

About the struct dependency bit; the speaker says this was changed. Does anyone know exactly how a struct dependency currently behaves in terms of recompilation? Does the Elixir compiler do analysis of struct-only changes or is it simply recompiling the module always regardless?

josevalim

josevalim

Creator of Elixir

If your module A only depends on the struct of a module B, then we will only recompile A if the fields in the struct B change. But we always recompile the whole file the module is at. The beam of a module is always assembled as a unit.

A lot of it still comes from things like plugs and phoenix helpers, which are effectively fixed in the next Phoenix v1.4 version.

LostKobrakai

LostKobrakai

What I always wondered. If the compiler knows when to recompile which module, couldn’t that information be surfaced to the user? Like a “list me all modules, which are recompiled if module x changes (and why)”. mix xref is alreally nice, but even with all the knowledge about why and when modules depend on each other and need recompiling it’s still quite a lot of work to mitigate things in this space. I’ve had a few shots in a current project of mine and I while sometimes I found the spots to change I also had quite a few times, where I didn’t even find why modules would depend on each other even with the data xref produced. Maybe I should just try updating it to phoenix 1.4 and see how much it helps.

josevalim

josevalim

Creator of Elixir

This information is already available via xref, no? So it is a bit unclear what you are asking for. :slight_smile:

LostKobrakai

LostKobrakai

As I mention xref is already doing much, but I found it still hard to go from two modules being listed as dependant on one another to which part of my code is causing this dependency. Even more so if there’s no direct dependency, but rather up to a handful of intermediate modules in between. I’ve had cases where I sat in front of the xref output and wondered “how the **** are those things related to each other in my code”, where modules were handling totally different domains.

josevalim

josevalim

Creator of Elixir

I see, thanks!

The sink option can be really useful for you to find how two things supposedly related to each other. For example: mix xref graph --sink lib/ecto/query.ex in Ecto will show all the paths that reach lib/ecto/query.ex. Some of those are quite long but it does provide the relationship information.

We could also add functionality to provide all paths between two places in particular. Right now it is not possible to filter with a source and sink at the same time.

LostKobrakai

LostKobrakai

That would be really helpful I imagine, because if one is really trying to reduce compile time coupling it just comes down to break apart sections at specific edges. The other thing useful, which was mentioned in the talk would be to have a flag to not only filter dependencies by compile/struct/runtime dependencies, but also have a way to have xref list all modules, which will be recompiled a.k.a. compile time dependencies and runtime dependencies, with are implicitly compile time dependencies. I’m not sure if something’s already possible in that direction.

— All posts loaded —

Where Next? Top

Trending in Talks Top

CodeSync
That’s a wrap on Code BEAM Europe 2026! Thanks to everyone who came to Haarlem or joined online, and to our speakers, trainers and sponso...
New
CodeSync
The Graveyard of Good Ideas - Quinn Wilton | ElixirConf US 2026 Comments welcome! View the <span class="hashtag-icon-plac...
New
CodeSync
Building High-Performing Engineering Teams | Christian Koch | ElixirConf US 2026 Rountable <span class="hashtag-icon-placeholder"></span>...
New
CodeSync
LT: E-mail is broken! | Zach Supalla | ElixirConf US 2026 https://www.youtube.com/watch?v=BoHx136rgbE Comments welcome! View the <span...
New
CodeSync
LT: Quillex Hits 1.0 – the First Native Elixir Text Editor - Luke Taylor | ElixirConf US 2026 https://www.youtube.com/watch?v=6d69M74qRK...
New
CodeSync
LT: Elixir for Gaming! Using Network to Power a Sophisticated Multiplayer Simulation - Mik Ahmed https://www.youtube.com/watch?v=wbkIld3...
New
CodeSync
LT: Process Dictionary Debugger - Andrew Glassman | ElixirConf US 2026 https://www.youtube.com/watch?v=ATN67Hj0C-8 Comments welcome! V...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews