As once function slow path can only happen once, it makes sense to do
a pruning on ONCE_DONE state.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
| lib/libthr/thread/thr_once.c | ||
|---|---|---|
| 69 ↗ | (On Diff #191562) | Not sure whether likely is a good idea or not? |
| lib/libthr/thread/thr_once.c | ||
|---|---|---|
| 69 ↗ | (On Diff #191562) | Exactly which idea? The only thing that is avoided by the change is the _thr_check_init() call, which is a single load and test. So I really do not see what do we win there. If doing this, organize the code in a way it is done in the loop, namely, use the fence if the observed state is ONCE_DONE. Also, it might be it is more useful to add the compiler hint to _thr_check_init() if() condition instead of this. |
| lib/libthr/thread/thr_once.c | ||
|---|---|---|
| 69 ↗ | (On Diff #191562) | As thr_once will exactly enter slow path at the first time, after that, we exactly enter ONCE_DONE state and never goes slow path. It makes sense to avoid any _thr_check_init test if possible. But yes, make init unlikely is a much better solution. I original think that it is much clear to distinguish slow path and fast path. But it is obvious that we make some redundancy here. |
| lib/libthr/thread/thr_once.c | ||
|---|---|---|
| 91 ↗ | (On Diff #191570) | This is s/space*8/tab/, right? It should be a separate commit. |