Uh oh!
There was an error while loading. Please reload this page.
Reduce a table used for Debug impl of str. - #40709
Merged
Merged
Conversation
rust-highfive
commented
Mar 21, 2017
Contributor
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
lifthrasiirforce-pushed
the
leaner-unicode-debug-str
branch
from
March 21, 2017 19:07
17466fa to
c4fc592Comparelifthrasiir
commented
Mar 21, 2017
ContributorAuthor
I forgot to remove a test code (and run tidy, I didn't know tidy does not run with |
alexcrichton
commented
Apr 4, 2017
Member
@bors: r+ Thanks @lifthrasiir! |
bors
commented
Apr 4, 2017
Collaborator
📌 Commit c4fc592 has been approved by |
bors
commented
Apr 5, 2017
Collaborator
🔒 Merge conflict |
This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most u16 entries are common in its upper byte. Specifically: - SINGLETONS now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared. - NORMAL now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set). The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones.
alexcrichtonforce-pushed
the
leaner-unicode-debug-str
branch
from
April 5, 2017 16:13
c4fc592 to
44bcd26Comparealexcrichton
commented
Apr 5, 2017
Member
@bors: r+ |
bors
commented
Apr 5, 2017
Collaborator
📌 Commit 44bcd26 has been approved by |
frewsxcv added a commit
to frewsxcv/rust
that referenced
this pull request
Apr 5, 2017
…r, r=alexcrichton Reduce a table used for `Debug` impl of `str`. This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most `u16` entries are common in its upper byte. Specifically: - `SINGLETONS` now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared. - `NORMAL` now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set). The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones. In my x86-64 macOS laptop with `rustc 1.17.0-nightly (0aeb9c1 2017-03-15)`, `-C opt-level=3 -C lto` gives the following: * The old routine compiles to 2,102 bytes of data and 416 bytes of code. * The new routine compiles to 1,197 bytes of data and 448 bytes of code. Counting a number of all printable Unicode scalar values (128,003, if you wonder) by filtering `0..0x110000` with `std::char::from_u32` and `is_printable` took 50±7ms for both. This can be surprising as the new routine *has* to do more calculations; this is partly explained by the fact that a linear search of `SINGLETONS` has been replaced by *two* linear searches for upper and lower bytes, which greatly reduces the iteration count.
arielb1 pushed a commit
to arielb1/rust
that referenced
this pull request
Apr 5, 2017
…r, r=alexcrichton Reduce a table used for `Debug` impl of `str`. This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most `u16` entries are common in its upper byte. Specifically: - `SINGLETONS` now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared. - `NORMAL` now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set). The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones. In my x86-64 macOS laptop with `rustc 1.17.0-nightly (0aeb9c1 2017-03-15)`, `-C opt-level=3 -C lto` gives the following: * The old routine compiles to 2,102 bytes of data and 416 bytes of code. * The new routine compiles to 1,197 bytes of data and 448 bytes of code. Counting a number of all printable Unicode scalar values (128,003, if you wonder) by filtering `0..0x110000` with `std::char::from_u32` and `is_printable` took 50±7ms for both. This can be surprising as the new routine *has* to do more calculations; this is partly explained by the fact that a linear search of `SINGLETONS` has been replaced by *two* linear searches for upper and lower bytes, which greatly reduces the iteration count.
bors
commented
Apr 6, 2017
Collaborator
⌛ Testing commit 44bcd26 with merge a1ef100... |
bors
commented
Apr 6, 2017
Collaborator
💔 Test failed - status-appveyor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most
u16entries are common in its upper byte. Specifically:SINGLETONSnow uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared.NORMALnow uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set).The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones.
Some useless benchmarks
In my x86-64 macOS laptop with
rustc 1.17.0-nightly (0aeb9c129 2017-03-15),-C opt-level=3 -C ltogives the following:Counting a number of all printable Unicode scalar values (128,003, if you wonder) by filtering
0..0x110000withstd::char::from_u32andis_printabletook 50±7ms for both. This can be surprising as the new routine has to do more calculations; this is partly explained by the fact that a linear search ofSINGLETONShas been replaced by two linear searches for upper and lower bytes, which greatly reduces the iteration count.