Hi,
I've been expermenting with hconsing with NBE for lambda calculus. This library is the primary inspiration, which I've mostly copied. Originally, I was using the library, but ran into some performance problems:
- I believe the
uid is not needed, the internal NonNull pointer data in the Rc is enough to act as a unique reference. As every Rc is the spoke on a fuzzy ball surrounding a RcBox, even if the location of the RcBox were to somehow move, it must move in a way such that all constructed Rc's remain sound. Of course, the Weak stored in the HConsign has the same properties, because it references the same RcBox. Moreover, once the pointer is reclaimed, that is the exact condition in which the unique id would be reusable because the original Weak would fail to upgrade.
- The usage of
Arc with no ability to switch to an Rc. In my case, there is no point in being multithreaded. Parallelization in evaluating lambda terms is not very good unless you take an optimal lambda evaluator route.
"Fixing" those two problems were about a 2-3x speedup for my benchmarks, especially because lambda terms are explosive in terms of size, so halving the pointer size ends up being a useful win.
Ideally, I'd like these changes to make it into this library, because then I can just pull it from cargo :)
Unrelated, I would prefer if the pointer types where called Hc and Ahc, but this is a minor thing that is not important to me, I can just rename the types in my project.
If you are interested I could draft a PR with the above changes.
Hi,
I've been expermenting with hconsing with NBE for lambda calculus. This library is the primary inspiration, which I've mostly copied. Originally, I was using the library, but ran into some performance problems:
uidis not needed, the internalNonNullpointer data in theRcis enough to act as a unique reference. As everyRcis the spoke on a fuzzy ball surrounding aRcBox, even if the location of theRcBoxwere to somehow move, it must move in a way such that all constructedRc's remain sound. Of course, theWeakstored in theHConsignhas the same properties, because it references the sameRcBox. Moreover, once the pointer is reclaimed, that is the exact condition in which the unique id would be reusable because the originalWeakwould fail to upgrade.Arcwith no ability to switch to anRc. In my case, there is no point in being multithreaded. Parallelization in evaluating lambda terms is not very good unless you take an optimal lambda evaluator route."Fixing" those two problems were about a 2-3x speedup for my benchmarks, especially because lambda terms are explosive in terms of size, so halving the pointer size ends up being a useful win.
Ideally, I'd like these changes to make it into this library, because then I can just pull it from cargo :)
Unrelated, I would prefer if the pointer types where called
HcandAhc, but this is a minor thing that is not important to me, I can just rename the types in my project.If you are interested I could draft a PR with the above changes.