Skip to content

Commit b0e8e42

Browse files
committed
Use a lower compression level (1) to speed up manifest writing.
1 parent 6b70e16 commit b0e8e42

File tree

1 file changed

+38
-31
lines changed
  • apps/language_server/lib/language_server/dialyzer

1 file changed

+38
-31
lines changed

apps/language_server/lib/language_server/dialyzer/manifest.ex

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,44 @@ defmodule ElixirLS.LanguageServer.Dialyzer.Manifest do
2424

2525
def write(root_path, active_plt, mod_deps, md5, warnings, timestamp) do
2626
Task.start_link(fn ->
27-
manifest_path = manifest_path(root_path)
28-
29-
plt(
30-
info: info,
31-
types: types,
32-
contracts: contracts,
33-
callbacks: callbacks,
34-
exported_types: exported_types
35-
) = active_plt
36-
37-
manifest_data = {
38-
@manifest_vsn,
39-
mod_deps,
40-
md5,
41-
warnings,
42-
:ets.tab2list(info),
43-
:ets.tab2list(types),
44-
:ets.tab2list(contracts),
45-
:ets.tab2list(callbacks),
46-
:ets.tab2list(exported_types)
47-
}
48-
49-
# Because the manifest file can be several megabytes, we do a write-then-rename
50-
# to reduce the likelihood of corrupting the manifest
51-
JsonRpc.log_message(:info, "[ElixirLS Dialyzer] Writing manifest...")
52-
File.mkdir_p!(Path.dirname(manifest_path))
53-
tmp_manifest_path = manifest_path <> ".new"
54-
File.write!(tmp_manifest_path, :erlang.term_to_binary(manifest_data, compressed: 9))
55-
File.rename(tmp_manifest_path, manifest_path)
56-
File.touch!(manifest_path, timestamp)
57-
JsonRpc.log_message(:info, "[ElixirLS Dialyzer] Done writing manifest.")
27+
{us, _} =
28+
:timer.tc(fn ->
29+
manifest_path = manifest_path(root_path)
30+
31+
plt(
32+
info: info,
33+
types: types,
34+
contracts: contracts,
35+
callbacks: callbacks,
36+
exported_types: exported_types
37+
) = active_plt
38+
39+
manifest_data = {
40+
@manifest_vsn,
41+
mod_deps,
42+
md5,
43+
warnings,
44+
:ets.tab2list(info),
45+
:ets.tab2list(types),
46+
:ets.tab2list(contracts),
47+
:ets.tab2list(callbacks),
48+
:ets.tab2list(exported_types)
49+
}
50+
51+
# Because the manifest file can be several megabytes, we do a write-then-rename
52+
# to reduce the likelihood of corrupting the manifest
53+
JsonRpc.log_message(:info, "[ElixirLS Dialyzer] Writing manifest...")
54+
File.mkdir_p!(Path.dirname(manifest_path))
55+
tmp_manifest_path = manifest_path <> ".new"
56+
File.write!(tmp_manifest_path, :erlang.term_to_binary(manifest_data, compressed: 1))
57+
File.rename(tmp_manifest_path, manifest_path)
58+
File.touch!(manifest_path, timestamp)
59+
end)
60+
61+
JsonRpc.log_message(
62+
:info,
63+
"[ElixirLS Dialyzer] Done writing manifest in #{div(us, 1000)} milliseconds."
64+
)
5865
end)
5966
end
6067

0 commit comments

Comments
 (0)