Conversation
| ``` | ||
|
|
||
| Prevents a value or the result of an expression from being optimized away by the | ||
| compiler adding as little overhead as possible. It does not prevent |
There was a problem hiding this comment.
Also mention that it prevents outer code from "seeing" the inside optimization-wise -- values produced by black_box are from the optimizer's perspective no different from being random.
text/0000-benchmarking.md
Outdated
| ``` | ||
|
|
||
| [winsorized]: https://en.wikipedia.org/wiki/Winsorizing | ||
| Is a read/write barriert: it flushes pending writes to variables "escaped" with |
|
Could you explain what's the difference between |
ea4543f to
b37b88f
Compare
|
@kennytm sorry! for some reason I wasn't following this so I did not receive any notifications.
Maybe the implementation helps? https://gist.github.com/gnzlbg/92b00f4d5362b06e72b48f824604e64e First, What clobber says is a bit different: "at the clobber something will read all memory in the heap and do something depending on it". For the I don't know exactly how compiler_fence works internally or how it should be used, but it looks like it is intended to synchronize reads/writes across threads by preventing reorderings. Even if you prevent a reordering, if LLVM can prove that the value written by one thread is not read by any other thread, the write can be elided without reordering anything. So the use-case seems a bit different. Clobber is more like a single-threaded full-memory fence, while But as mentioned, I am not 100% sure about this. |
|
I think the above explanation is worth including in the reference-level explanation section. By the way, it's likely that rust-lang#2287 will be closed given that folks seem to prefer rust-lang#2318 (in the discussions with the team so far). In that case, we should make mem::black_box and clobber into its own RFC |
|
@Manishearth there is also rust-lang#1484 open where @SimonSapin suggests doing exactly that. Maybe we should move them already into its own RFC and ask the folks over there to get involved. |
|
works for me. Would you like to open the RFC? I can help if you need. |
|
I'll add it to my todo list, might get to it later today. |
rfc, const-repeat-expr: notes on is_rvalue_promotable(expr)
RFC 2582: Fix typo (must not -> need not)
|
I'd be willing to write up the RFC for this. Presumably not much has changed about the assumed API since this was filed? |
|
Yeah. |
No description provided.