Conversation
That's cheaper than the current t=T() which includes several atomic ops For the cases I changed, it was clear that T was Lazy_*. In Lazy.h, there are other cases where one would need to check what the valid types are, and maybe create a reset utility which does t=T() by default and is overloaded for types that derive from Handle.
The exact choice of memory_order_* is hard, and even for versions that seem to work on x86_64 TSAN complains like crazy. TODO: a version that, instead of blocking if another thread is updating, also does the computation, with suitable protection to ensure that pruning the tree cannot happen while anyone is computing on it. TODO: try having AT in Lazy instead of Lazy_rep (i.e. not shared) to avoid the indirection. We can possibly choose one or the other depending on the type.
This doesn't seem to provide anything useful with the current implementations. It probably helped avoid an atomic operation in some earlier version.
|
Benchs of this PR seems good. I will merge it. |
The issue is fixed by CGAL/cgal#5402. Unfortunately it's not officially released yet, so this is an internal build.
|
@mglisse Thank you for the update. Is it possible to apply this change to CGAL5.2.3? |
|
Considering how invasive is the patch, I wonder what could prevent you from switching to the master branch (and 5.4 when released). |
|
By the way, I think the change of this PR should be announced in |
I have tried 5.3 and find that boolean set operations become slower. I don't tend to upgrade right now. Is there any solution |
|
Could you share a case that shows the regression? We have been working recently to improve the runtime of boolean set operations so it might show a bug. Thanks. |
Indeed, please open a new issue about this.
Uh, I thought we had written something, but apparently not... |
OK. I will test a simple case and make sure this is a problem. Later I will open a new issue about this. |
|
CHANGES.md: in the Kernel_23 section:
and in the section "dD Geometry Kernel":
? ("most" because for instance |
Where do you see that? It seems it was never committed, or never pushed. |
Ah no, sorry, that wasn't clear enough, I was suggesting that we could add that, not saying that it was already there. |
Please refer to #6092 . As I can't upgrade to higher version, I wonder if I could merge some of the code in #5402 to CGAL 5.2.3 to solve the multithread problem? If so, which code should I merge? |
|
I already did that merge somewhere but I'd need some time to get a non-official patched release. |
Thank you for your hard work. The patched release of CGAL 5.2.3 is sorely needed for me. |
|
@Supranaturaler You can try https://cgal.geometryfactory.com/~sloriot/CGAL-5.2.2-mt.tgz. I hope I did not mess up while setting it up. Note that it is not official and patched master should be the best choice. |
|
|
@sloriot plz offer the right url to me, thanks! |
|
Should be fine now. |


Summary of Changes
A preview of a prototype of some changes to make Epeck safer in multi-threaded applications, in case some people want to play with it, look at the code, or discuss the topic. Alternative to #648, it makes more sense as a separate PR than a comment at the end of that PR.
It is surprising that the hardest part is cleaning up. If we were ok with not pruning the Lazy trees after update_exact (or if we had garbage collection?), other strategies would become possible. Anyway, call_once seems rather efficient and once_flag is small, at least on linux (it is bigger on windows), and it avoids reinventing the (spinning) wheel.
I think the worst overhead is for operations on Lazy_exact_nt, but people shouldn't do a lot of computations in that type.
One thing I hope is that the overhead will prove small enough that we don't need a thread-unsafe version for use in multi-threaded applications that do not share objects.
This change means that copying a Handle(_for) is now expensive, so work to reduce copies (for instance for mpq_rational) would also benefit reference-counted types (Gmpq, Lazy).
Some possible future steps:
Release Management