Description
I am not sure if this is possible with the design of libuv and Node, but it would be great to be able to do:
stream.read(buffer, offset, length, callback)
buffer
is the buffer that the data will be written to.
offset
is the offset in the buffer to start writing at.
length
is an integer specifying the number of bytes to read.
Especially for net and tls sockets.
I am not sure if Node itself currently manages and re-uses the underlying buffers for net sockets? But if not, then this would make it possible to do static memory allocation in a server. In the past, streams did not support pull mode at all, now they support pull mode, but the user still has no control over the allocation of the underlying buffers, so this creates more allocations and more work for the GC.
I am working on a client-side program at the moment and am finding that V8's GC is just too lazy. Things work and eventually get collected but memory usage climbs and climbs. I would like to have more control and rather statically allocate buffers and re-use them. This would also have a positive side-effect of controlling queue sizes and workloads in various parts of the program more explicitly.