You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dont call fflush for each line written when generating a tmp file
fclose contains a fflush or equivelent call per posix/C. Calling fflush
after every line will mean <=80 byte writes to the disk/FS driver/kernel.
Calling fflush after every write of a line console is understandable, for
a disk it isn't. By removing/merging the fflush with fclose, in most cases
the entire temp file will be buffered in stdio in user mode and sent to the
kernel only when the file is closed. Move the error check to fclose. On
VS >= 2005, this also means that the MT lock will be aquired once for the
fclose, not once (or more) for fflush then again for fclose.
My test workload for dmake (a perl build) makes 3 temp files per
"dmake all". The number of fflush calls was reduced from 140 to 137 with
this patch. The number of WriteFile calls stayed the same at 145, probably
since the temp files are 1 line long. The majority of fflush calls are
writing to console in my workload.
0 commit comments