D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20746 - Change LCG in garbage collector treap to use full 64 bits of state instead of 48
Summary: Change LCG in garbage collector treap to use full 64 bits of state instead of 48
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-04-19 05:10 UTC by Nathan S.
Modified: 2020-05-20 09:24 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nathan S. 2020-04-19 05:10:03 UTC
rt.util.random.Rand48 is an LCG that holds its state in a 64-bit long but only makes use of the low 48 bits. Replacing it with an LCG that makes use of the full 64 bits would be a strict improvement as it would take no additional space and would not be slower.

Rand48 is used only in rt.util.container.treap.Treap which in turn is used only by the garbage collector.
Comment 1 Dlang Bot 2020-04-19 05:43:38 UTC
@n8sh created dlang/druntime pull request #3042 "Change LCG in garbage collector treap to use full 64 bits of state instead of 48" fixing this issue:

- Fix Issue 20746 - Change LCG in garbage collector treap to use full 64 bits of state instead of 48

https://github.com/dlang/druntime/pull/3042
Comment 2 Dominikus Dittes Scherkl 2020-04-19 07:15:44 UTC
Sorry, but there was no bug and this is NOT an improvement.
The generator output is 32 bit and the internal state of course will use the whole 64 bit (even if not from the start), but it put out bits from the middle of the state.
Output the lowest 32 bits will make it less "random" - if fact very predictable.

Please, this is not a good pseudo-random number generateor, but at least it worked. now its destroyed.
Revert this change!
Comment 3 Dlang Bot 2020-05-20 09:24:03 UTC
dlang/druntime pull request #3042 "Change LCG in garbage collector treap to use full 64 bits of state instead of 48" was merged into master:

- 275a33117e5266da65cb5a6393634bbdde7fd00d by Nathan Sashihara:
  Fix Issue 20746 - Change LCG in garbage collector treap to use full 64 bits of state instead of 48

https://github.com/dlang/druntime/pull/3042