lib43 icon indicating copy to clipboard operation
lib43 copied to clipboard

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

Open lunixbochs opened this issue 10 years ago • 4 comments

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 avatar Feb 22 '15 01:02 lunixbochs

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

lunixbochs avatar Feb 22 '15 01:02 lunixbochs

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 [email protected] 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.

tmcarthur avatar Feb 22 '15 02:02 tmcarthur

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

lunixbochs avatar Feb 22 '15 08:02 lunixbochs

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 [email protected] 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.

tmcarthur avatar Feb 22 '15 15:02 tmcarthur