-
Couldn't load subscription status.
- Fork 13.9k
Description
This is a tracking issue for the RFC std::hint:_black_box.
Original RFC: RFC 2360
Public API:
// std::hint
pub fn black_box<T>(dummy: T) -> T;Steps:
- Implementation
- FCP
- Stabilization PR
Unresolved questions:
-
const fn: it is unclear whetherbench_black_boxshould be aconst fn. If it
were, that would hint that it cannot have any side-effects, or that it cannot
do anything thatconst fns cannot do. -
Naming: during the RFC discussion it was unclear whether
black_boxis the
right name for this primitive but we settled onbench_black_boxfor the time
being. We should resolve the naming before stabilization.Also, we might want to add other benchmarking hints in the future, like
bench_inputandbench_output, so we might want to put all of this
into abenchsub-module within thecore::hintmodule. That might
be a good place to explain how the benchmarking hints should be used
holistically.Some arguments in favor or against using "black box" are that:
- pro: [black box] is a common term in computer programming, that conveys
that nothing can be assumed about it except for its inputs and outputs.
con: [black box] often hints that the function has no side-effects, but
this is not something that can be assumed about this API. - con:
_boxhas nothing to do withBoxorbox-syntax, which might be confusing
Alternative names suggested:
pessimize,unoptimize,unprocessed,unknown,
do_not_optimize(Google Benchmark). - pro: [black box] is a common term in computer programming, that conveys