lunixbochs / lib43

portable libc optimized for code size and readability
MIT License
80 stars 6 forks source link

implement a cleanup function (_fini?) instead of manually invoking fflush(stdout) #14

Open lunixbochs opened 9 years ago

lunixbochs commented 9 years ago

Going forward, I want to think about the ability of a lib43 user to tune the runtime. One of the most useful cases right now is beating the startup/teardown cost of every other libc and crt0 I've tested, sometimes by a significant margin.

Adding a _fini function that does anything like fflush() on all file descriptors could waste even precious nanoseconds which is useful if using lib43 for competitive reasons.

lunixbochs commented 9 years ago

Probably either cmake -DUNSAFE_BUT_FAST=1 or individual flags like cmake -DFLUSH_WRITES=1

tmcarthur commented 9 years ago

Agreed but it should maybe be tunable on a by feature basis in an organized way. Same arguments could apply to argv passing in some cases and other things as well.

On Feb 21, 2015, at 5:26 PM, Ryan Hileman notifications@github.com wrote:

Probably either cmake -DUNSAFE_BUT_FAST=1 or individual flags like cmake -DFLUSH_WRITES

— Reply to this email directly or view it on GitHub.

lunixbochs commented 9 years ago

setting up argv is like two instructions, while "flush all open file handles" is actually a ton of work and potentially many syscalls.

tmcarthur commented 9 years ago

I realize that - my point is just that there may be other things people may want to turn on and off as more stuff goes into library so having a methodical way to do so is good. Unwrapping argv is potentially more depending on what compiler decides to do for function prologue but it still wouldn't be that expensive true.

On Feb 22, 2015, at 12:11 AM, Ryan Hileman notifications@github.com wrote:

argv is like two instructions, while "flush all open file handles" is actually a ton of work and potentially many syscalls.

— Reply to this email directly or view it on GitHub.