mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Nick Bray <ncbray@google.com>
To: musl@lists.openwall.com
Subject: Stdio resource usage
Date: Tue, 19 Feb 2019 15:34:52 -0800	[thread overview]
Message-ID: <CANmYxDvCe7o8Xy0A1nyx=RqCnLt6ERPBYrqH54ki0PzOtUyEWw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

Other that compiler warnings, the main pain point I ran into porting a
subset of Musl into a resource constrained environment was the resource
usage of stdio.  I don't expect any of these modifications to make it
upstream.  Talking out loud as a FYI / user feedback.  Also curious to see
if there's any wisdom out there.

Stack usage of stdio was an issue.  On arm64, printf takes 8k of stack
which is a rough when you only have 4-12k of stack.  This is because fmt_fp
allocates stack space proportional O(log(MAX_LONG_DOUBLE)).  It also gets
inlined into printf so you always take the hit.  (noinline fmt_fp is a
Faustian bargain that makes stack usage worse in the worst case... hmmm.)
On arm64, long double is defined as 128 bits, which not only increases
stack size because of the larger mantisa, but also pulls in software
emulation for fp128.  In terms of spec compliance, Musl is doing the right
thing.  But as a practical matter, none of the programs I care about will
ever use long double.  So my rough first pass was to reduce the max float
size from long double to double.  In a later pass, I'll also add a knob to
remove floating point formatting entirely.

%m calls strerror which pulls in a string table, so removing support for %m
lets static linking and DCE work its magic.  I also eliminated %n for
security hardening reasons.

The "states" structure is sparse and takes a little more memory than I'd
like -  464b of rodata.  I don't see any workarounds without deeper
changes, so for now I am living with it.

[-- Attachment #2: Type: text/html, Size: 1739 bytes --]

             reply	other threads:[~2019-02-19 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 23:34 Nick Bray [this message]
2019-02-20  2:43 ` Rich Felker
2019-02-20 10:49   ` Szabolcs Nagy
2019-02-20 15:47     ` Markus Wichmann
2019-02-20 16:37       ` Szabolcs Nagy
2019-02-20 17:13         ` Rich Felker
2019-02-20 18:34       ` A. Wilcox
2019-02-20 19:11         ` Markus Wichmann
2019-02-20 19:24           ` Rich Felker
2019-02-21 16:09             ` Markus Wichmann
2019-02-21 16:27               ` Jens Gustedt
2019-02-21 17:02               ` Rich Felker

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='CANmYxDvCe7o8Xy0A1nyx=RqCnLt6ERPBYrqH54ki0PzOtUyEWw@mail.gmail.com' \
    --to=ncbray@google.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).