`Borrow` & `make_mut`
01mf02 opened this issue · 7 comments
I tried to integrate rclite
in a project of mine (jaq), but I can't because jaq needs Rc::make_mut
and Borrow
. Could you implement these? If so, then I could integrate rclite
into jaq, providing you with some real-life performance benchmarks of alloc::rc::Rc
vs rclite::Rc
. :)
Hi, thanks for reporting this, I'm working on it and going to add these functionalities for 0.1.6
That is great to hear; thanks!
@01mf02 Hi! I updated the crate, please check the 0.2.0
I used another method to implement make_mut
that could be possibly less efficient than the standard library but uses less unsafe code. If you observe less performance for this function let me know to update it to a better implementation.
Thanks a lot! I hope to have time in the next days to report on performance.
I have now integrated rclite::Rc
into jaq for test purposes (diff to reproduce the changes). I compiled two versions, one using alloc::rc::Rc
, one using rclite::Rc
, and benchmarked them with ./bench.sh ./jaq-alloc-rc ./jaq-rclite-rc
. The results show the runtime in seconds for both versions:
Benchmark | n | ./jaq-alloc-rc | ./jaq-rclite-rc |
---|---|---|---|
empty | 512 | 0.74 | 0.80 |
bf-fib | 13 | 0.56 | 0.61 |
reverse | 1048576 | 0.04 | 0.03 |
sort | 1048576 | 0.11 | 0.13 |
add | 1048576 | 0.53 | 0.54 |
kv | 131072 | 0.20 | 0.22 |
kv-update | 131072 | 0.22 | 0.23 |
kv-entries | 131072 | 0.78 | 0.78 |
ex-implode | 1048576 | 0.72 | 0.79 |
reduce | 1048576 | 0.90 | 0.92 |
tree-flatten | 17 | 0.46 | 0.48 |
tree-update | 17 | 0.32 | 0.31 |
to-fromjson | 65536 | 0.04 | 0.04 |
We can see that rclite::Rc
yields roughly the same performance as alloc::rc::Rc
, but it takes longer in a large majority of the benchmarks. Therefore, I will stick to alloc::rc::Rc
for now and hope that these benchmarks are useful for you if you wish to improve performance. :)
(Just to clarify: I used rclite 0.2.1.)