Skip to content

Commit 70c8f41

Browse files
committed
Prebuild cache
1 parent 76de440 commit 70c8f41

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

lib/elixir/scripts/infer.exs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,31 @@
44
# using the locally inferred types to infer all types
55
# for stdlib itself.
66
parent = self()
7+
ebin = Path.expand("../ebin", __DIR__)
78
{:ok, checker} = Module.ParallelChecker.start_link()
89

910
# Validate we are loading Elixir modules and that they are all in place
1011
[:elixir] = Code.get_compiler_option(:infer_signatures)
11-
true = URI in Application.spec(:elixir, :modules)
12+
13+
# Now we prefill all exports so the cache is prebuilt instead of depending
14+
# on the concurrency of the async stream below
15+
[_ | _] =
16+
modules =
17+
for module <- Application.spec(:elixir, :modules),
18+
match?("Elixir." <> _, Atom.to_string(module)) do
19+
Enum.each(module.__info__(:functions), fn {fun, arity} ->
20+
Module.ParallelChecker.fetch_export(checker, module, fun, arity, true)
21+
end)
22+
23+
module
24+
end
1225

1326
{time, modules} =
1427
:timer.tc(fn ->
15-
[_ | _] = paths = Path.wildcard(Path.join(__DIR__, "../ebin/Elixir.*.beam"))
16-
17-
paths
28+
modules
1829
|> Task.async_stream(
19-
fn path ->
20-
path = Path.expand(path)
30+
fn module ->
31+
path = Path.join(ebin, "#{module}.beam")
2132
Module.ParallelChecker.put(parent, checker)
2233
cache = Module.ParallelChecker.get()
2334
binary = File.read!(path)

0 commit comments

Comments
 (0)