Follow us on Google+ Follow us on Facebook Follow us on Twitter

Opened 8 years ago

Last modified 3 years ago

#201 new enhancement

fflush() should be cheap if output buffer is empty

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone: 0.7.1
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

Currently a non-standard synchronization scheme is used for the console. The console/fb drivers assume that they can delay screen update until an explicit sync operation. This sync operation is achieved via fsync(). fflush() calls fsync() every time.

In POSIX fflush() only writes out (flushes) the output buffer (if it is non-empty). But it does not sync the file descriptor, fsync() is a stronger operation. Terminal output in POSIX is updated immediately when data is written to the file descriptor.

The big problem in HelenOS is that fflush() is expensive (does fsync(), which results in IPC) even when there is no data in the output buffer. This contributes to the slowness of operations such as fgetc() which try to flush output streams (and currently do it always, not just when we are reading from stdin).

Another question is, whether it would be better to make the console behavior more standard, so that an fsync() is not necessary.

Change History (6)

comment:1 Changed 8 years ago by Jiri Svoboda

See also #200 and #202.

comment:2 Changed 8 years ago by Jiri Svoboda

I have alleviated the problem. FILE structures now have a boolean field need_sync. It is set when data is written to the file descriptor and cleared when the fd is synced. fflush() only syncs the fd if need_sync is set.

This makes the fflush() operation cheap when no data has been written. However, I still think we rather need to re-define console behavior and not to require a sync to propagate data. Therefore I am not considering this ticked resolved yet.

comment:3 Changed 7 years ago by Jakub Jermář

Milestone: 0.4.30.5.0

comment:4 Changed 7 years ago by Jakub Jermář

Type: defectenhancement

comment:5 Changed 6 years ago by Jakub Jermář

Milestone: 0.5.00.5.1

comment:6 Changed 3 years ago by Jakub Jermář

Milestone: 0.5.10.7.1
Note: See TracTickets for help on using tickets.