stripe / subprocess

A port of Python's subprocess module to Ruby
MIT License
209 stars 17 forks source link

Make Process#communicate do less work on every iteration #69

Closed jez-stripe closed 2 years ago

jez-stripe commented 2 years ago

Authored-by @synfo-stripe

Without this change communicating 700MB worth of data to 'cat' takes
~1h, with it it's closer to 1s.

My hypothesis is that `input[0...written] = ''` causes ruby to either
allocate a whole new string buffer, or at the very least rewrite the
entirety of the existing buffer, whereas `input = input[written..]` lets
ruby use shared string optimization and only create a new RString
pointing to the same buffer.