hawkw / sharded-slab

a lock-free concurrent slab (experimental)
MIT License
273 stars 19 forks source link

Document that `take` uses spinning #20

Closed tmandry closed 4 years ago

tmandry commented 4 years ago

Spinning has different performance/energy characteristics than mutexes/condition vars, and it would be good to document that this is what take does.

hawkw commented 4 years ago

Other options include:

hawkw commented 4 years ago

Another option is that we could consider adding a proper backoff here. We would still be spinning, but could have the thread sleep while spinning rather than just emitting pause instructions. That would be an obstacle to porting to no_std, but this code currently doesn't work on no_std, and we could just feature flag it.

This might be a good compromise between not burning CPU in a tight spin loop and having to allocate a mutex/condvar pair for every slot.