Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake the writer even more unsafe. #1830
Conversation
| @@ -523,7 +521,11 @@ fn serialize_fast<T: Serialize>(vec: &mut Vec<u8>, e: &T) { | |||
| bincode::serialize_into(&mut size,e , bincode::Infinite).unwrap(); | |||
| vec.reserve(size.0); | |||
|
|
|||
| bincode::serialize_into(&mut UnsafeVecWriter(vec), e, bincode::Infinite).unwrap(); | |||
| let old_len = vec.len(); | |||
| let ptr = unsafe { vec.as_mut_ptr().offset(vec.len() as isize) }; | |||
This comment has been minimized.
This comment has been minimized.
|
I fixed up old_len and added a debug_assert to make sure things are sane. |
Instead of changing the length every write we just adjust the pointer. This avoids rust-lang/rust#45068. However we now need to ensure that we set the length when we are done. With this patch only 1.2% of WebRender display list building is spent in serialization.
|
With this patch only 1.2% of WebRender display list building is spent in serialization. |
|
Nice! |
|
What was the fraction of time spent in serialization before? |
|
I have too few samples to get a good comparison of the unsafe serializers. We have some patches coming that get rid of the cpu time spent elsewhere so that should raise the percentage of time spent in serialization. The safe serializer accounted for roughly 5.1% of the display list construction time. |
|
r=me, don't have review rights yet |
|
@bors-servo r=Gankro |
|
|
Make the writer even more unsafe. Instead of changing the length every write we just adjust the pointer. This avoids rust-lang/rust#45068. However we now need to ensure that we set the length when we are done. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1830) <!-- Reviewable:end -->
|
|
Some reviews in WR that Gankro has worked on: servo/webrender#1830 servo/webrender#1799 servo/webrender#1834 servo/webrender#1664
Add Gankro to WR reviewers list. Some reviews in WR that Gankro has worked on: servo/webrender#1830 servo/webrender#1799 servo/webrender#1834 servo/webrender#1664 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/740) <!-- Reviewable:end -->
jrmuizel commentedOct 6, 2017
•
edited by larsbergstrom
Instead of changing the length every write we just adjust the pointer.
This avoids rust-lang/rust#45068.
However we now need to ensure that we set the length when we are done.
This change is