Commits

Markus Mottl committed 97b35f0

Reverted recent async writer space usage bug

Comments (0)

Files changed (1)

base/async/scheduler/lib/writer.ml

     (t.buf, pos)
   end else begin
     (* Preallocated buffer too small; schedule buffered writes *)
-    if desired > buf_len then begin
+    (* We have to divide the buffer length by two in the following comparison
+       to avoid wasting buffer space on subsequent writes of slightly more
+       than half the buffer length. *)
+    if desired > buf_len / 2 then begin
       schedule_unscheduled t `Keep;
       (* Preallocation size too small; allocate dedicated buffer *)
       let buf = Bigstring.create desired in