-
Notifications
You must be signed in to change notification settings - Fork 218
Description
short version
When uploading many files under 16KiB, busboy will read ahead as fast as possible, emitting to all the .on('file', ...) listeners, even if the streams for previous files haven't been read yet.
long version
For large files I have a mechanism in place to apply backpressure through a consistent sleep time after each chunk, and the sleep time is based on data about uploads of "parts" of the file to the destination (ex: S3). The plan is to support multiple destinations, so that's why this rate is per-file (so each file's stream as potentially a different upload rate).
For very small files, this mechanism is effectively useless, but that's what I expect. However, I also expected that after busboy gives me some number of small files (let's say 64 of 1KiB files, because 64KiB was the mode chunk size I measured while uploading large files), and I haven't read the streams for any of these files yet (the streams which would only have one 1KiB chunk if read and then end immediately), that busboy would pause the stream to apply backpressure. This does not happen.
However, for files in the range [~16KiB, 64KiB] backpressure appears to work, despite that I'm only reading one chunk from each file. I'm not sure what makes the difference between [1B, ~16KiB) and [~16KiB, 64KiB], so I suspect that 16KiB might be a significant value in busboy somewhere.