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)
Thu, Dec 5, 12:18 PM
Unknown Object (File)
Wed, Dec 4, 12:00 PM
Unknown Object (File)
Tue, Dec 3, 2:05 AM
Unknown Object (File)
Fri, Nov 22, 10:30 AM
Unknown Object (File)
Nov 13 2024, 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
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 Skipped
Unit
Tests Skipped

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
139

This can be grouped with "FreeBSD includes" above.

15148

Random whitespace change.

sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace_xoroshiro128_plus.h
2

This file and the next are missing license headers.

10

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

Not sure why these are needed?

1172

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.