From: "byroot (Jean Boussier)" Date: 2022-11-29T09:56:54+00:00 Subject: [ruby-core:111049] [Ruby master Feature#6047] read_all: Grow buffer exponentially in generic case Issue #6047 has been updated by byroot (Jean Boussier). I just tried my hand at this one: https://github.com/ruby/ruby/pull/6829 I think such a change would make sense. Not that `IO#read` without a size if common, but might as well do something sensible. ---------------------------------------- Feature #6047: read_all: Grow buffer exponentially in generic case https://bugs.ruby-lang.org/issues/6047#change-100311 * Author: MartinBosslet (Martin Bosslet) * Status: Open * Priority: Normal ---------------------------------------- In the general case, read_all grows its buffer linearly by just the amount that is currently read from the underlying source. This results in a linear number of reallocs, It might turn out beneficial if the buffer were grown exponentially by multiplying with a constant factor (e.g. 1.5 or 2), thus resulting in only a logarithmic numver of reallocs. I will provide a patch and benchmarks, but I'm already opening this issue so I won't forget. See also https://bugs.ruby-lang.org/issues/5353 for more details. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/