I looked at ruby's internal implementation of StringIO because I suspected that there might be additional performance to be gained by using it here instead of a raw string. Turns out StringIO is just implemented in terms of using a string. 

As far as I can tell there is no way in Ruby to initialize a string ( or buffer ) at a certain size. My assumption is that Liquid will spend quite some time in string duping and copying because the buffer keeps growing during the render run in very small increments. Would be great to avoid it.