Replaced the implementation of DTrace's RAND subroutine for generating low-quality random numbers with a modern implementation (xoroshiro128+) that is capable of generating better quality randomness without compromising performance.
Details
To test the new implementation I produced a DTrace script using multiple tick-1sec probes with a predicate based on the random() subroutine:
tick-1s
/random()%2 == 0/
{
@time["sample"] = quantize(2);
}
tick-1s
/random()%4 == 0/
{
@time["sample"] = quantize(4);
}
and so on.
The resulting distribution was then compared against the same distribution using the rand() subroutine. Biases in the rand() subroutine where on longer noticeable in the new implementation. See attachments:
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
This seems fine to me - aside from the licensing, my comments are all style nits.
sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | ||
---|---|---|
138 ↗ | (On Diff #23634) | This can be grouped with "FreeBSD includes" above. |
15149 ↗ | (On Diff #23634) | Random whitespace change. |
sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace_xoroshiro128_plus.h | ||
1 ↗ | (On Diff #23634) | This file and the next are missing license headers. |
9 ↗ | (On Diff #23634) | I don't see any real reason for this since the header is only used by the kernel. |
sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h | ||
54 ↗ | (On Diff #23634) | Not sure why these are needed? |
1175 ↗ | (On Diff #23634) | It'd be better to use NCPU here too, I think. |