Performance tweaks
All checks were successful
Build & Test / nix-build (pull_request) Successful in 2m36s
Build & Test / nix-build (push) Successful in 2m40s

This commit is contained in:
Kodi Craft 2024-10-03 17:55:43 +02:00
parent 18a80874df
commit 847644d8cf
Signed by: kodi
GPG Key ID: 69D9EED60B242822

View File

@ -87,11 +87,13 @@ defmodule Amethyst.ConnectionHandler do
new_chunks = MapSet.difference(chunks, prev_chunks) new_chunks = MapSet.difference(chunks, prev_chunks)
# We can process all chunks in parallel # We can process all chunks in parallel
me = self() me = self()
Task.Supervisor.async_stream(state |> Map.get(:game) |> Map.get(:refs) |> Map.get(:task_supervisor), ts = state |> Map.get(:game) |> Map.get(:refs) |> Map.get(:task_supervisor)
Task.Supervisor.async(ts, fn ->
Task.Supervisor.async_stream(ts,
new_chunks, new_chunks,
fn chunk -> process_chunk(me, chunk, state) end, fn chunk -> process_chunk(me, chunk, state) end,
[ordered: false] [ordered: false]
) |> Stream.run() ) |> Stream.run() end)
end end
loop(socket, connstate, version, state) loop(socket, connstate, version, state)
{:send_packet, packet} -> {:send_packet, packet} ->