4 ms·
I’ve always felt the “if you use Arc” why not just use GC is a weak response. The benefit of rust is that you only pay the cost if you need it. I’m not saying “
by olliej 4y ago
I’ve always felt the “if you use Arc” why not just use GC is a weak response. The benefit of rust is that you only pay the cost if you need it. I’m not saying “yay it’s all easy” I found concurrency frustrating in rust because it refused to let me do things that I “knew” we’re safe :)
The always use Arc model is actually what swift and objc fundamentally do. Everything’s lifetime has to be threadsafe, so the refcount itself must be threadsafe, and so any refchurn is atomic. For a single thread as I understand it modern CPUs handle uncontended churn without a real perf hit.
But I was writing a raytracer in swift, and once I made it multithreaded the refcount cost on my non mutating objects became a massive perf cost. It was super frustrating, and is fundamentally what would happen if you took the “Arc everything” approach. But you don’t have to, and this get perf where it’s safe and possible.
- aaaaaaaaaaab 4y ago>But I was writing a raytracer in swift, and once I made it multithreaded the refcount cost on my non mutating objects became a massive perf cost. Then access them through `unowned` references?
- olliej 4y agoBecause I was not skilled enough in swift land to know of such. I'll read up and adopt and see what happens, and try to remember to update here :D [edit: Just discovered the last thing I was trying to do was separate out some core data structures into packages. It turns out that if the pop() function on your priority heap gets left out of line, that becomes vastly more expensive than is reasonable. So fixing may take a wee bit long than expected]
- aaaaaaaaaaab 4y agoPriority heap in a raytracer? :thinking_face:
- olliej 4y agoPhoton mapping collection :)
- Thaxll 4y agoOne of the downside is that the programmer now needs to use different way to allocate and create objects because it's just too complicated to make it work with the borrow checker.