Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Rewrite vfprintf.c and tiny_printf.c to use __divmod for speed #2012

Merged
merged 4 commits into from
Sep 14, 2024

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Sep 14, 2024

More in a series of speeding up numeric-to-string conversions in the C library. This PR adds the fast __divmod calculation to vfprintf/sprintf/printf.c and tiny_printf.c.

Although few on faster systems are likely to notice speed improvements, those with 8086/8088 CPUs may start to see a difference when running ANSI sequence intensive terminal applications like sl, ttyclock, matrix and the like. This is because for every cursor position as well as any color sequence, a number has to get converted to a string through these routines, and then converted back to the same number by the ANSI console driver. It wasn't realized until recently how much time these conversions were taking on systems with very slow DIV instructions - all 8086/8088s and early CPUs.

The ANSI console speedups are coming next, then it might be worth measuring any speedups. @Vutshi, hopefully this will help your older system run sl and ttyclock much quicker than before, but we will see!

@ghaerr ghaerr merged commit e0dc002 into master Sep 14, 2024
3 checks passed
@ghaerr ghaerr deleted the printf branch September 14, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant