Page MenuHomeFreeBSD

Replacement for DTrace's RAND subroutine
ClosedPublic

Authored by graeme.jenkinson_cl.cam.ac.uk on Jan 5 2017, 6:56 PM.
Tags
Referenced Files
Unknown Object (File)
Wed, Nov 13, 7:51 PM
Unknown Object (File)
Oct 7 2024, 2:14 AM
Unknown Object (File)
Oct 4 2024, 1:11 AM
Unknown Object (File)
Oct 2 2024, 11:35 PM
Unknown Object (File)
Oct 1 2024, 2:13 PM
Unknown Object (File)
Sep 30 2024, 12:34 PM
Unknown Object (File)
Sep 22 2024, 7:31 PM
Unknown Object (File)
Sep 18 2024, 12:05 AM
Subscribers

Details

Summary

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.

Test Plan

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:

dtrace-random.png (529×640 px, 19 KB)

dtrace-rand.png (529×640 px, 19 KB)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

graeme.jenkinson_cl.cam.ac.uk retitled this revision from to Replacement for DTrace's RAND subroutine .
graeme.jenkinson_cl.cam.ac.uk updated this object.
graeme.jenkinson_cl.cam.ac.uk edited the test plan for this revision. (Show Details)
markj edited edge metadata.

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.

This revision is now accepted and ready to land.Jan 6 2017, 1:56 AM
This revision now requires review to proceed.Jan 13 2017, 10:12 AM
gnn edited edge metadata.
This revision is now accepted and ready to land.Jan 13 2017, 3:27 PM
markj edited edge metadata.
This revision was automatically updated to reflect the committed changes.