elixir-lang/elixir

Side effect of mix compile in `iex -S mix` session

alco opened this issue · 11 comments

alco commented

When I run iex -S mix, if there is some work for mix to perform (e.g. compile the source), iex will receive an exit message upon launch.

λ mix clean

λ iex -S mix
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Compiled lib/gochan.ex
Generated gochan.app
Interactive Elixir (0.8.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> flush()
{:EXIT,#PID<0.47.0>,:normal}
:ok

Running iex -S mix the second time starts a clean shell, because nothing needs to be compiled this time:

λ iex -S mix
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]

Interactive Elixir (0.8.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> flush()
:ok

Any idea from where it comes from? Maybe it is from the parellel compiler: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/parallel_compiler.ex#L33 ?

If so, could we clean up after the parallel compiler?

Can't we just launch a new process for the shell?

On Sun, May 12, 2013 at 4:55 PM, José Valim notifications@github.comwrote:

Any idea from where it comes from? Maybe it is from the parellel compiler:
https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/parallel_compiler.ex#L33?

If so, could we clean up after the parallel compiler?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1050#issuecomment-17787930
.

@yrashk Based on the 398421987321 different experiments I have performed on the shell, no. :( I can't remember the specifics now.

Besides, clean up after the parallel compiler will be a good idea regardless. :)

alco commented

Any idea from where it comes from?

No idea. But it is always #PID<0.47.0> on my machine.

alco commented

I'm going to do another take on this, moving the compilation into a separate process, so that nothing is left behind after it.

It still happens with the elixir command. Given this source:

https://gist.github.com/pragdave/5779347

I'm seeing (with 0.9.2):

light-boy% elixir t.ex
MESSAGE RECEIVED: {:EXIT,#PID<0.36.0>,:normal}
light-boy% elixir t.ex
MESSAGE RECEIVED: {:EXIT,#PID<0.36.0>,:normal}
light-boy% elixirc t.ex
Nothing happened as far as I am concerned
Compiled t.ex
light-boy% elixir t.ex
/Users/dave/BS2/titles/elixir/Book/code/spawn/t.ex:3: redefining module Link1
MESSAGE RECEIVED: {:EXIT,#PID<0.36.0>,:normal}
Interactive Elixir (0.9.3.dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> flush
:ok
iex(2)> defmodule A do end
{:module,A,<<70,79,82,49,0,0,6,80,66,69,65,77,65,116,111,109,0,0,0,96,0,0,0,10,8,69,108,105,120,105,114,46,65,8,95,95,105,110,102,111,95,95,9,109,111,100,117,108,101,100,...>>,nil}
iex(3)> flush
{:EXIT,#PID<0.39.0>,:normal}
:ok
iex(4)> defmodule A do end ; defmodule B do end
iex:4: redefining module A
{:module,B,<<70,79,82,49,0,0,6,80,66,69,65,77,65,116,111,109,0,0,0,96,0,0,0,10,8,69,108,105,120,105,114,46,66,8,95,95,105,110,102,111,95,95,9,109,111,100,117,108,101,100,...>>,nil}
iex(5)> flush                                  
{:EXIT,#PID<0.42.0>,:normal}
{:EXIT,#PID<0.45.0>,:normal}

To me this is very indicative of a fact that module compiler is being spawn_linked (or spawned and linked thereafter) as there a very clear correlation between # of modules built and # of EXIT messages

I have a solution, will send a pull req for review

alco commented

https://github.com/alco/elixir/compare/1050-parallel-compiler

With this change, Kernel tests hang closer to the end. Presumably it has something to do with the Kernel.CLI.ParallelCompilerTest. If I comment this test module out, subsequent tests pass until we get to mix -- it hangs again:

mix hang

I can no longer reproduce this issue, nor in Dynamo nor in Gochan. It is probably related to the refactoring in mix involving the smart compiler.