-
Notifications
You must be signed in to change notification settings - Fork 279
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
Make the writer even more unsafe. #1830
Conversation
webrender_api/src/display_list.rs
Outdated
@@ -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) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with this changed to old_len
43705c1
to
eaa5d63
Compare
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. |
eaa5d63
to
94e88a5
Compare
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 |
📌 Commit 94e88a5 has been approved by |
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 -->
☀️ Test successful - status-appveyor, status-travis |
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 -->
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