zerovec slower than cow? #4515
-
I found this project through https://manishearth.github.io/blog/2022/08/03/zero-copy-2-zero-copy-all-the-things/ and was trying some benchmark using I am just wondering: Did I misunderstand something or did I implement something the wrong way? Basically what I am doing is:
where
for a 5 to 80 MB xml file containing around 60 different nested elements. For the benchmark I replace all However I am suprised by the benchmark:
So my question is: Is this expected, or do I need to change something to gain the full advantage of zerotovec? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I don't understand, There's no advantage to using ZeroVec over Cow: ZeroVec supports doing more things in zero-copy. If you can do it in Cow without allocating you don't need this crate. |
Beta Was this translation helpful? Give feedback.
-
XML supports character escape sequences, so it is not generally possible to get a |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your input. Still learning how the details of Rust are working. I guess I need to read some more @Manishearth I am not sure if I understand your last comment correctly. Does quick_xml::de with serde use zero copy deserialization if I choose Cow<'a, str> as type? |
Beta Was this translation helpful? Give feedback.
I don't understand,
VarZeroVec<str>
is not the equivalent ofCow<str>
andString
. It's the equivalent ofVec<String>
(which cannot be represented inCow
in a way that will not allocate on deserialization).There's no advantage to using ZeroVec over Cow: ZeroVec supports doing more things in zero-copy. If you can do it in Cow without allocating you don't need this crate.