elixir-google-api
elixir-google-api copied to clipboard
STOP GENERATING THOUSANDS OF MODULES!!!
I know the use of meta-programming is fun. But the BEAM doesn't handle loading thousands of modules very well. We have several Google libraries in our deployment Elixir and just loading Google API libraries takes over a minute!!! OVER A MINUTE for a few APIs!!!!
iex -S mix run --no-start
fn ->
times =
Application.loaded_applications()
|> Enum.map(fn {app, _desc, _vsn} ->
modules = Application.spec(app, :modules)
{time, _result} = :timer.tc(fn -> Enum.each(modules, &Code.ensure_loaded!/1) end)
{app, System.convert_time_unit(time, :microsecond, :millisecond)}
end)
|> Enum.sort_by(&elem(&1, 1), :asc)
Enum.each(times, &IO.inspect/1)
times |> Enum.map(&elem(&1, 1)) |> Enum.sum() |> IO.inspect()
end.()
# {application, time_in_ms}
...
{:google_api_you_tube, 6336}
{:google_api_dfa_reporting, 11710}
{:google_api_vision, 15091}
{:google_api_content, 29394}