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 upUse serde_bytes crate #2598
Use serde_bytes crate #2598
Conversation
| @@ -395,7 +395,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
|
|
|||
| [[package]] | |||
| name = "freetype" | |||
| version = "0.3.0" | |||
| version = "0.4.0" | |||
This comment has been minimized.
This comment has been minimized.
jonleighton
Apr 1, 2018
Author
Contributor
This update happened automatically, I believe it is due to d162942
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jonleighton
Apr 1, 2018
Author
Contributor
I guess not? Though I don't know, I haven't contributed to webrender before. I've opened a separate PR to fix this: #2599
| External(ExternalImageData), | ||
| } | ||
|
|
||
| mod serde_image_data_raw { |
This comment has been minimized.
This comment has been minimized.
jonleighton
Apr 1, 2018
Author
Contributor
This is necessary because we are dealing with an Arc. However, maybe it would be better to patch serde_bytes to support this?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dtolnay
Apr 1, 2018
Could you propose a more general signature for serde_bytes that could work here?
This comment has been minimized.
This comment has been minimized.
jonleighton
Apr 1, 2018
Author
Contributor
Perhaps not, though I haven't looked into it very closely. Assuming a more general signature is not workable, maybe serde_bytes could also ship serde_bytes_rc/serde_bytes_arc modules though? (Essentially what I've done here, but inside the serde_bytes crate.)
| use serde::{Deserializer, Serializer}; | ||
|
|
||
| pub fn serialize<'a, S: Serializer>(bytes: &'a Arc<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error> { | ||
| serde_bytes::serialize(&bytes.as_slice(), serializer) |
This comment has been minimized.
This comment has been minimized.
dtolnay
Apr 1, 2018
There was a missing T: ?Sized in serde_bytes::serialize. I fixed it in 0.10.4 so the & on this line should no longer be necessary.
|
It seems like this should only be needed when using ipc-channel. i.e. not
with Gecko
…On Sun, Apr 1, 2018, 5:04 AM Jon Leighton ***@***.***> wrote:
This speeds up serializing and deserializing of binary data.
------------------------------
You can view, comment on, or merge this pull request online at:
#2598
Commit Summary
- Use serde_bytes crate
File Changes
- *M* Cargo.lock
<https://github.com/servo/webrender/pull/2598/files#diff-0> (16)
- *M* webrender_api/Cargo.toml
<https://github.com/servo/webrender/pull/2598/files#diff-1> (1)
- *M* webrender_api/src/api.rs
<https://github.com/servo/webrender/pull/2598/files#diff-2> (8)
- *M* webrender_api/src/image.rs
<https://github.com/servo/webrender/pull/2598/files#diff-3> (21)
Patch Links:
- https://github.com/servo/webrender/pull/2598.patch
- https://github.com/servo/webrender/pull/2598.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2598>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUTbfeBMX-aN9cksBPJVA553xsIDJIrks5tkJgugaJpZM4TCxBX>
.
|
This speeds up serializing and deserializing of binary data.
|
@jrmuizel It looks like this would be used even in Gecko (due to the changes to FontData and the Blob structs), wouldn't it? Is there any issue with having this enabled for Gecko? Do we need to do anything further here (benchmarks?) or is this ready to merge? |
|
To give a bit of context to this, I discovered it while profiling the code I was working on for servo/servo#20506 While profiling that code, I was seeing lots of time being spent serializing and deserializing font data bytes when passing them over an IPC channel. I tried using (I haven't included |
|
@jonleighton Thanks for the info! What does this mean in terms of the Gecko integration which doesn't use the Does it have any effect at all? Should we be only enabling it in WR when the |
|
If the Gecko integration never serializes/deserializes, then yeah, I guess this code has no effect there. However, wouldn't the compiler be able to figure out that the code is not used and exclude it from the binary? I'm a bit out of my depth here so I don't know if that is really the case, just struck me as something that might happen. If that isn't the case, then should WebRender exclude the |
I.e. don't they also bloat the binary? |
|
Well, Gecko does serialize / deserialize things (such as the display list) - but they are sent over the Gecko IPC mechanism, rather than the rust So, I guess the question is does this change provide a benefit in that situation? I would think yes, but I just want to make sure that's the case, since @jrmuizel seems to suggest it's only useful if using ipc-channel, per the comment above. |
|
Right, so I also think the answer is yes since |
|
That makes sense to me. @jrmuizel Any issues with getting this merged? |
|
Gecko doesn't serialize those structs in normal usage, only the display list. That being said, we probably do serialize them when doing a binary recording (we should probably only support this on Nightly) I guess it's probably ok to take the extra dependency for now and have a feature flag to disable recording support in a follow up. |
|
Sounds good, thanks! @bors-servo r+ |
|
|
Use serde_bytes crate This speeds up serializing and deserializing of binary data. <!-- 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/2598) <!-- Reviewable:end -->
|
|
jonleighton commentedApr 1, 2018
•
edited by larsbergstrom
This speeds up serializing and deserializing of binary data.
This change is