fd-stream buffers flushing

Bug #910213 reported by Nikodemus Siivola
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Low
Unassigned

Bug Description

From: Ken Olum
Subject: Last byte of fd-stream buffers never used
To: <email address hidden>
Date: Fri, 17 Dec 2010 12:53:01 -0500

In output-wrapper in fd-stream.lisp, we have the code

`(when (<= (buffer-length obuf) (+ tail ,size)) ...

I think this test should be <, not <=. TAIL is the pointer to the
first free location, so if TAIL + SIZE = LENGTH, then we could store
SIZE bytes leaving TAIL = LENGTH, which would be OK. (Perhaps after
writing the last byte the buffer should be flushed, instead of waiting
for the next write, but that's another story.)

This result of this code is that the buffer of a character file
stream is written out after every 4095 characters, rather than every
4096, probably reducing filesystem efficiency.

I checked it in SBCL 1.0.43 on x86_64 Linux, as follows:

(defvar *test* nil)
(trace sb-impl::flush-output-buffer :condition (eq *test* (arg 0)))
(with-open-file (*test* "delete.me" :direction :output :if-exists :supersede)
   (dotimes (i 16384)
   (format t "~D " i)
   (force-output)
   (write-char #\z *Test*)))

You can see that only 4095 characters are written between flushes.

Tags: fd-streams
Revision history for this message
Stas Boukarev (stassats) wrote :

In 18c093eb771c1ab038090863d99bf4baf4224966

Changed in sbcl:
status: Triaged → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.