[Issue 19075] New: rt.util.random.Rand48.defaultSeed should prefer RDTSC or mach_absolute_time to ctime.time
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Jul 11 01:45:11 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=19075
          Issue ID: 19075
           Summary: rt.util.random.Rand48.defaultSeed should prefer RDTSC
                    or mach_absolute_time to ctime.time
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com
`rt.util.random.Rand48.defaultSeed` generates a seed from the clock using
`ctime.time`. With `D_InlineAsm_X86_64` it would be better to use the `rdtsc`
instruction because it is much faster as well as being finer precision. (Finer
precision is a benefit not because we care about accurate time, but because the
differences between seeds generated this way are potentially greater.) The same
is true of `mach_absolute_time` on macOS. The Microsoft Windows equivalent
would be `QueryPerformanceCounter` but I haven't benchmarked it to verify that
it is faster than `ctime.time`.
--
    
    
More information about the Digitalmars-d-bugs
mailing list