You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Building on the work in the parent commit, now that the data being
passed to the `ram_file` is a binary, we can instead build the entire
output gradually within the process. We pay in terms of I/O overhead
from writing and then reading from the `ram_file` since `ram_file` is a
port - all data is passed between the VM and the port driver. The memory
consumed by a port driver is also invisible to the VM's allocator, so
large port driver resource usage should be avoided where possible.
Instead this change refactors the `registry_collect_callback` to fold
over collectors and build an accumulator. The `create_mf` callback's
return of `ok` forces us to store this rather than pass and return it.
So it's a little less hygienic but is more efficient than passing data
in/out of a port.
This also introduces a function `format_into/3` which can use this
folding function directly. This can be used to avoid collecting the
entire response in one binary. Instead the response can be streamed
with `cowboy_req:stream_body/3` for example.
0 commit comments