Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Comment out CLOCK_MONOTONIC_RAW because that's not available on FreeBSD, and it looks OK to me? My understanding is that we should see some timestamps repeating if there's a collision, correct? I can't get any collisions...

  > ./clock_gettime_demo/clock_gettime_demo
  clock_getres(CLOCK_REALTIME, ...)=1 ns
  clock_getres(CLOCK_MONOTONIC, ...)=1 ns

  CLOCK_REALTIME 30 samples:
  1689957434662039455
  1689957434662039526 (diff=71)
  1689957434662039566 (diff=40)
  1689957434662039606 (diff=40)
  1689957434662039636 (diff=30)
  1689957434662039676 (diff=40)
  1689957434662039706 (diff=30)
  1689957434662039736 (diff=30)
  1689957434662039766 (diff=30)
  1689957434662039796 (diff=30)
  1689957434662039826 (diff=30)
  1689957434662039856 (diff=30)
  1689957434662039886 (diff=30)
  1689957434662039916 (diff=30)
  1689957434662039946 (diff=30)
  1689957434662039987 (diff=41)
  1689957434662040016 (diff=29)
  1689957434662040047 (diff=31)
  1689957434662040076 (diff=29)
  1689957434662040107 (diff=31)
  1689957434662040137 (diff=30)
  1689957434662040167 (diff=30)
  1689957434662040197 (diff=30)
  1689957434662040227 (diff=30)
  1689957434662040257 (diff=30)
  1689957434662040297 (diff=40)
  1689957434662040327 (diff=30)
  1689957434662040357 (diff=30)
  1689957434662040387 (diff=30)
  1689957434662040417 (diff=30)

  CLOCK_MONOTONIC 30 samples:
  2168262770533974
  2168262770534023 (diff=49)
  2168262770534054 (diff=31)
  2168262770534094 (diff=40)
  2168262770534124 (diff=30)
  2168262770534164 (diff=40)
  2168262770534194 (diff=30)
  2168262770534224 (diff=30)
  2168262770534254 (diff=30)
  2168262770534284 (diff=30)
  2168262770534314 (diff=30)
  2168262770534344 (diff=30)
  2168262770534374 (diff=30)
  2168262770534404 (diff=30)
  2168262770534435 (diff=31)
  2168262770534464 (diff=29)
  2168262770534495 (diff=31)
  2168262770534524 (diff=29)
  2168262770534555 (diff=31)
  2168262770534585 (diff=30)
  2168262770534615 (diff=30)
  2168262770534645 (diff=30)
  2168262770534685 (diff=40)
  2168262770534715 (diff=30)
  2168262770534745 (diff=30)
  2168262770534775 (diff=30)
  2168262770534805 (diff=30)
  2168262770534835 (diff=30)
  2168262770534865 (diff=30)
  2168262770534895 (diff=30)


Do you run it on 4 cores simultaneously as the author did?


I'm running it on real hardware (Ryzen 9 5900X, 12 cores 24 threads) and all I'm doing is executing the program once. My understanding is that the program is using runtime.GOMAXPROCS(0) to ensure it's using all available CPU cores because that falls back to runtime.NumCPU ?


Oh, I was only running the C program not the Go binary which orchestrates it, that's why I wasn't seeing the longer stats. But I'm still getting no duplicate collisions.

  running longer zeros test ...
  sampled 10000000 pairs; 0 time diff zeros = 0.000000%; 0 nano diff zeros = 0.000000%

  starting parallel test 24 goroutines x 10000000 samples ...
  10000000 samples from a thread; 0 collisions inside the thread; 0 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 945466 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 1982688 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 2739919 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 3334361 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 4109772 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 4489881 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 5157178 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 5596508 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 5854763 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 5937583 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 6434076 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 6521917 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 6932626 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7104428 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7285076 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7514904 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7833317 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7737265 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7723545 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7730441 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 8311161 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 7965117 collisions with other threads
  10000000 samples from a thread; 0 collisions inside the thread; 8460173 collisions with other threads
  102297835 final samples; 137702165 total collisions = 57.375902%; possible duplicate collisions? 0




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: