Skip to content

Conversation

wojtekmach
Copy link
Member

Before this patch, I have seen the following with some extra debugging
statements and modules with @on_load that makes them slow to load:

$ mix test --slowest-modules=5
[lib/mix/tasks/test.ex:614: Mix.Tasks.Test.do_run/3]
app_start_args #=> ["--slowest-modules=5"]

[lib/mix/tasks/app.config.ex:43: Mix.Tasks.App.Config.run/1]
opts[:preload_modules] #=> nil

Running ExUnit with seed: 829176, max_cases: 1

Mod1Test [test/mod1_test.exs]
  * test mod1 [L#4]Mod1.__on_load__/0...
Mod1.__on_load__/0 ok
  * test mod1 (5004.1ms) [L#4]

Mod2Test [test/mod2_test.exs]
  * test mod2 [L#4]Mod2.__on_load__/0...
Mod2.__on_load__/0 ok
  * test mod2 (5005.7ms) [L#4]

Finished in 10.0 seconds (10.0s async, 0.00s sync)

Top 5 slowest (10.0s), 99.9% of total time:

Mod2Test (5005.7ms)
 [test/mod2_test.exs]
Mod1Test (5004.1ms)
 [test/mod1_test.exs]

2 tests, 0 failures

Additionally passing --preload-modules fixed the issue.

With this patch, preloading is correctly set.

Before this patch, I have seen the following with some extra debugging
statements and modules with `@on_load` that makes them slow to load:

    $ mix test --slowest-modules=5
    [lib/mix/tasks/test.ex:614: Mix.Tasks.Test.do_run/3]
    app_start_args #=> ["--slowest-modules=5"]

    [lib/mix/tasks/app.config.ex:43: Mix.Tasks.App.Config.run/1]
    opts[:preload_modules] #=> nil

    Running ExUnit with seed: 829176, max_cases: 1

    Mod1Test [test/mod1_test.exs]
      * test mod1 [L#4]Mod1.__on_load__/0...
    Mod1.__on_load__/0 ok
      * test mod1 (5004.1ms) [L#4]

    Mod2Test [test/mod2_test.exs]
      * test mod2 [L#4]Mod2.__on_load__/0...
    Mod2.__on_load__/0 ok
      * test mod2 (5005.7ms) [L#4]

    Finished in 10.0 seconds (10.0s async, 0.00s sync)

    Top 5 slowest (10.0s), 99.9% of total time:

    Mod2Test (5005.7ms)
     [test/mod2_test.exs]
    Mod1Test (5004.1ms)
     [test/mod1_test.exs]

    2 tests, 0 failures

Additionally passing `--preload-modules` fixed the issue.

With this patch, preloading is correctly set.
@wojtekmach
Copy link
Member Author

Please back port to v1.19 if sounds good. :)

@josevalim josevalim merged commit e3cd399 into elixir-lang:main Oct 5, 2025
13 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants