-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateAndTime is way less precise on Windows than on Unix #13447
Comments
The problems comes from the fact that we use the current time to set the name of Ombu stores. But here we create 2 stores in less than 1 millisecond and DateAndTime on windows is sadly not able to give us a precision under 1 millisecond for now... See pharo-project#13447. So here is a quick hack to wait 1 millisecond before producing a new name on windows.
That is why, for example, UUIDGenerator also uses a counter and a random element. You should also check if the file exists. Like Stef suggested, we already have FileReference class>>#newTempFilePrefix:suffix: |
The code that computes that is here: https://github.com/pharo-project/pharo-vm/blob/de760673b5f108d32576b47f4bbdfd3b230520b0/extracted/vm/src/common/heartbeat.c#L113 In *nix systems we are using gettimeofday, maybe we should move to clock_gettime as proposed by this post https://stackoverflow.com/questions/69099750/what-is-the-precision-of-the-gettimeofday-function? The equivalent of clock_gettime in windows is no trivial, but we could port such a solution :) |
On windows if you do
DateAndTime now = DateAndTime now
you get true because you need to wait at least 1 millisecond to get two different DateAndTime instances from #now. On unix you get false because they have a precision at the nanosecond.This is problematic because first the API let you think you can manipulate this at the level of the nano second. And second because DateAndTime now is used to generate unique IDs in the system and that means that if we create ID too fast on windows, we end up with same IDs.
The text was updated successfully, but these errors were encountered: