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

Stop zeroing out the scratch buffer in float_to_decimal_common #41259

Closed
bzbarsky opened this issue Apr 12, 2017 · 5 comments
Closed

Stop zeroing out the scratch buffer in float_to_decimal_common #41259

bzbarsky opened this issue Apr 12, 2017 · 5 comments

Comments

@bzbarsky
Copy link

float_to_decimal_common in src/libcore/fmt/float.rs does this:

let mut buf = [0; 1024];

which zeroes out the big buffer. Given that it's a scratch buffer, there shouldn't be a reason to do that, I would think.

@eddyb
Copy link
Member

eddyb commented Apr 12, 2017

Link to the code in question. IMO we should start using ArrayVec and variations of it (including ring buffers and even arbitrary number of ranges or other "partial initialization patterns") throughout the libs.

cc @rust-lang/libs

@sfackler
Copy link
Member

Is there a concrete performance issue that this is proposing to tackle? I would like to avoid moving from use of initialized to uninitialized memory "just because".

@eddyb
Copy link
Member

eddyb commented Apr 12, 2017

@sfackler It came up in a Servo profile. But regardless, I would like to use safe abstractions over partial initialization of stack arrays, to better represent the semantics involved.

@bzbarsky
Copy link
Author

Is there a concrete performance issue that this is proposing to tackle?

Yes. The zeroing out was about 5% of the time taken in a "get the specified value of top" microbenchmark for stylo.

Or another way to think of it is that it's 15% of the time Safari takes to execute the entire operation. ;)

@sfackler
Copy link
Member

Cool, seems worth fixing then 👍

@bors bors closed this as completed in b2c3102 Apr 30, 2017
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

No branches or pull requests

3 participants