mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: musl <musl@lists.openwall.com>
Subject: Re: Re: [PATCH] make fflush_unlocked(NULL) work
Date: Sun, 25 Sep 2016 01:49:38 +0200	[thread overview]
Message-ID: <CAK1hOcO+b_J5AcvfOnHtoUyqGN_Bv6wDH9gdsgTLjMPQhbz9iw@mail.gmail.com> (raw)
In-Reply-To: <20160918203608.GB15995@brightrain.aerifal.cx>

On Sun, Sep 18, 2016 at 10:36 PM, Rich Felker <dalias@libc.org> wrote:
> This patch introduces significant code duplication and complexity for
> the sake of saving something like 10 cycles in an operation that makes
> syscalls (i.e. takes thousands if not tens of thousands of cycles).

fflush(NULL) does not _always_ perform syscalls.
It may well find that none of the streams need any work.

In fact, in some applications it may end it not doing any writes
most of the times it is called: for example, I call it before (v)fork()
(unless I know that I for sure do not have any buffered writes).

Sometimes I call it before vfork out of sheer paranoia,
even if it "looks like it's not needed":
having stdio buffering in vfork-shared mm is huge PITA
and a source of nasty bugs. Been there.

> As
> mentioned on the bb list, the right fix is just making fflush_unlocked
> an alias for fflush. Then __fflush_unlocked can be eliminated
> completely and the file simplified rather than increased in
> complexity.

Your call.


      reply	other threads:[~2016-09-24 23:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18 19:44 Denys Vlasenko
2016-09-18 20:36 ` Rich Felker
2016-09-24 23:49   ` Denys Vlasenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK1hOcO+b_J5AcvfOnHtoUyqGN_Bv6wDH9gdsgTLjMPQhbz9iw@mail.gmail.com \
    --to=vda.linux@googlemail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).