You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I commented on #4242 (comment), digest package now requires R >= 3.3. digest::digest() is used for hashing guides so that we can merge overlapped guides by guides_merge().
Since the hashing we need is very simple, it's probably possible to implement another hashing function (Maybe paste() with some nice separator is enough...?), but I'm not sure if it's worth. I feel it's time to consider dropping support for R 3.2. If this sounds good, I'll prepare a pull request.
Thanks, but, though it doesn't seem to be very difficult to implement a new startsWith(), I don't feel this is something worth asking the maintainer to release the new version for us because, as @thomasp85 says, R 3.2 is out of the tidyverse's "4 last versions" rule.
Thomas said "dropping digest" instead of "dropping support for R 3.2". Maybe we're all a bit confused. I just looked up the past R versions and I agree we should be fine with dropping 3.2:
Sorry. The confusion was my doing. We are not bound by our support commitment. Still, I think it would be beneficial to investigate whether dropping digest is viable from a performance point of view
One problem may be that the string can be of arbitrary length. One way around this would be to write a digestlight package that takes the string and runs it through a C++ hash function. That would be maybe 100 lines of code total, including everything needed to have a complete package.
Some benchmarking to see how fast the various parts are. serialize() doesn't seem to be the bottleneck, but just paste0() on the serialized object is quite expensive.
I didn't notice caching is this costly... Interesting. What about just using rawToChar()? Calculating BASE64 string on a non-ASCII binary seems the fastest, but considering there's the cost of ::, there's no significant difference.
This is weird. When I looked at the digest() source code, I thought it starts by calling serialize(). Does it call the binary version? Does this work: rawToChar(serialize(x, NULL, FALSE))?
Yeah. There might be nicer way to convert a binary into ASCII (e.g. BASE64 encoding), but I think variable names are limited to 10000 bytes means we need some hashing anyway to ensure the length of the result.
Implementing a hashing algorithm doesn't seem trivial, and digest package is already very fast; it took only twice than bare serialization (serialize(x, NULL, FALSE)). Though it would probably get a bit faster by using XXH3, a latest variant provided by xxHash (digest uses xxHash, but only provides XXH32 and XXH64), I don't think it's worth implementing another package just for this as there's little room for speed up. Serialization might be improved by not relying on serialize(), but I have no idea at the moment.
Can we agree to drop support for R 3.2? We might eventually implement another hashing package, but I don't think it will happen in the near future. So, I think it's better to make it clear that ggplot2 cannot be installed on R 3.2, at least at the moment.
Activity
thomasp85 commentedon Oct 25, 2020
We have a commitment to support the last 4 versions of R. I think we should look into dropping digest
clauswilke commentedon Oct 25, 2020
Or alternatively help the digest package support 3.2? It seems a minor issue that caused them to bump the version:
eddelbuettel/digest#159
yutannihilation commentedon Oct 25, 2020
Thanks, but, though it doesn't seem to be very difficult to implement a new
startsWith(), I don't feel this is something worth asking the maintainer to release the new version for us because, as @thomasp85 says, R 3.2 is out of the tidyverse's "4 last versions" rule.clauswilke commentedon Oct 25, 2020
Thomas said "dropping digest" instead of "dropping support for R 3.2". Maybe we're all a bit confused. I just looked up the past R versions and I agree we should be fine with dropping 3.2:
yutannihilation commentedon Oct 25, 2020
Oh, true... Definitely, I'm a bit confused, sorry.
thomasp85 commentedon Oct 25, 2020
Sorry. The confusion was my doing. We are not bound by our support commitment. Still, I think it would be beneficial to investigate whether dropping digest is viable from a performance point of view
clauswilke commentedon Oct 26, 2020
So
digest()basically callsserialize()on the object and then creates a hash value. Can we just use the serialized string?Created on 2020-10-25 by the reprex package (v0.3.0)
One problem may be that the string can be of arbitrary length. One way around this would be to write a digestlight package that takes the string and runs it through a C++ hash function. That would be maybe 100 lines of code total, including everything needed to have a complete package.
clauswilke commentedon Oct 26, 2020
Some benchmarking to see how fast the various parts are.
serialize()doesn't seem to be the bottleneck, but justpaste0()on the serialized object is quite expensive.Created on 2020-10-25 by the reprex package (v0.3.0)
yutannihilation commentedon Oct 26, 2020
I didn't notice caching is this costly... Interesting. What about just using
rawToChar()? Calculating BASE64 string on a non-ASCII binary seems the fastest, but considering there's the cost of::, there's no significant difference.Created on 2020-10-27 by the reprex package (v0.3.0)
yutannihilation commentedon Nov 2, 2020
If I replace
digest::digest()withrawToChar(serialize(x, NULL, TRUE)), I got this error:What's worse, this isn't very fast. Here is the result on a realistic data on which I got the error above.
ascii = TRUEseems very expensive.Created on 2020-11-02 by the reprex package (v0.3.0)
clauswilke commentedon Nov 2, 2020
This is weird. When I looked at the
digest()source code, I thought it starts by callingserialize(). Does it call the binary version? Does this work:rawToChar(serialize(x, NULL, FALSE))?clauswilke commentedon Nov 2, 2020
To answer my own question: No, it doesn't work, because C strings cannot contain binary zeros.
yutannihilation commentedon Nov 3, 2020
Yeah. There might be nicer way to convert a binary into ASCII (e.g. BASE64 encoding), but I think
variable names are limited to 10000 bytesmeans we need some hashing anyway to ensure the length of the result.Implementing a hashing algorithm doesn't seem trivial, and digest package is already very fast; it took only twice than bare serialization (
serialize(x, NULL, FALSE)). Though it would probably get a bit faster by using XXH3, a latest variant provided by xxHash (digest uses xxHash, but only provides XXH32 and XXH64), I don't think it's worth implementing another package just for this as there's little room for speed up. Serialization might be improved by not relying onserialize(), but I have no idea at the moment.yutannihilation commentedon Nov 15, 2020
Can we agree to drop support for R 3.2? We might eventually implement another hashing package, but I don't think it will happen in the near future. So, I think it's better to make it clear that ggplot2 cannot be installed on R 3.2, at least at the moment.
thomasp85 commentedon Nov 15, 2020
I think dropping support for 3.2 is fine for now. flange might eventually get a hashing function but I don't know the timeline for it
yutannihilation commentedon Nov 16, 2020
Thanks. Is "flange" an R package that is not yet made public? Sounds interesting.
yutannihilation commentedon Dec 2, 2020
In case someone is interested in this, xxhashlite serializes without
serialize()and the benchmark on README looks much faster than digest.https://github.com/coolbutuseless/xxhashlite