Found a memory savings for `Indexer.Sequence`: store Ranges as tuples in the `:queue` as the tuples take up less space than than the `%Range{}` struct, but only after garbage-collection. The incoming and outgoing format is still Ranges, so this is a non-breaking implementation detail only. ```elixir test "memory usage" do {:ok, pid} = Sequence.start_link(ranges: [max_block_number..0], step: -10) Process.info(pid, :memory) |> IO.inspect(label: "BEFORE GC") :erlang.garbage_collect(pid) Process.info(pid, :memory) |> IO.inspect(label: "AFTER GC") end ``` | max_block_number | Garbage Collection | Ranges (bytes) | Tuples (bytes) | Tuples / Ranges (%) | |------------------|--------------------|----------------|----------------|---------------------| | 5,000,000 | Before | 41,050,964 | 22,445,660 | 54.68 | | 5,000,000 | After | 34,386,756 | 23,879,996 | 69.45 | | 10,000,000 | Before | 80,889,772 | 47,928,116 | 59.24 | | 10,000,000 | After | 71,303,316 | 49,516,492 | 69.44 |pull/917/head
parent
9570295f5c
commit
753319de4a
Loading…
Reference in new issue