You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
calibrateMtimeChangeDelay takes 25s to execute on Mac OS X with HFS+ system #4230
It's working correctly, this is a consequence of the algorithm and the HFS+ mtime delay you mention. We run it only once during setup, is that a big problem?
Much better. Since it loos like you are trying to detect what is the FileModTime resolution for the underlying filesystem I would go for that number directly by probing writes:
sampleMtime fileName = do
writeFile fileName $ ""
t0 <- getModTime fileName
let spin = do
writeFile fileName $ ""
t1 <- getModTime fileName
if t0 < t1
then return (t1 `diffModTime` t0)
else spin
spin
Or by using setModificationTime directly (requires directory >= 1.2.3):
So with direct setting of modification time it would go like this:
sampleMtime fileName = do
writeFile fileName $ ""
now <- getCurrentTime
let todayAlmost1sAfterMidnight = now { utctDayTime = pred (1 :: DiffTime) }
setModificationTime fileName todayAlmost1sAfterMidnight
modTime <- getModificatonTime fileName
return $ succ (diffUTCTime todayAlmost1sAfterMidnight modTime)
Explanation: pred (1 :: DiffTime) gives one discrete time unit before 1s. We rely on setModificationTime flooring the time specification. Then succ recovers one discrete time unit giving a modification time resolution as stored by the file system.
Note that the 'discrete time unit' is picosecond for UTCTime, but it does not really matter as succ . prec is identity.
Note: DOS-FAT12/16 has 2s file mod time resolution and it can be supported by changing (1 :: DiffTime) to (2 :: DiffTime). I do not think we care.
Activity
ezyang commentedon Jan 12, 2017
CC @ndmitchell
Probably what we should do is scale down number of calibration runs the longer the first run is.
23Skidoo commentedon Jan 12, 2017
It's working correctly, this is a consequence of the algorithm and the HFS+ mtime delay you mention. We run it only once during setup, is that a big problem?
23Skidoo commentedon Jan 13, 2017
I'm working on a patch.
Fix overly long mtime change delay calibration with HFS+.
gracjan commentedon Jan 13, 2017
Much better. Since it loos like you are trying to detect what is the FileModTime resolution for the underlying filesystem I would go for that number directly by probing writes:
Or by using
setModificationTimedirectly (requiresdirectory>= 1.2.3):gracjan commentedon Jan 13, 2017
So with direct setting of modification time it would go like this:
Explanation:
pred (1 :: DiffTime)gives one discrete time unit before 1s. We rely onsetModificationTimeflooring the time specification. Thensuccrecovers one discrete time unit giving a modification time resolution as stored by the file system.Note that the 'discrete time unit' is picosecond for
UTCTime, but it does not really matter assucc . precis identity.Note: DOS-FAT12/16 has 2s file mod time resolution and it can be supported by changing
(1 :: DiffTime)to(2 :: DiffTime). I do not think we care.23Skidoo commentedon Jan 13, 2017
We need to support old versions of
directory, so I think I'll leave it as is for now. I think that we can safely ignore FAT-16.Fix overly long mtime change delay calibration with HFS+.
gracjan commentedon Jan 13, 2017
Note that old version of calibrate managed to create the file 91k times during those 25s:
In GHCi:
Outside, 66664 is GHC pid:
23Skidoo commentedon Jan 13, 2017
You mean write to, not create.
gracjan commentedon Jan 13, 2017
I mean execute
writeFile.ttuegel commentedon Jan 14, 2017
Could this be related to the macOS timeouts we're seeing on Travis?
Fix overly long mtime change delay calibration with HFS+.
Fix overly long mtime change delay calibration with HFS+.
Fix overly long mtime change delay calibration with HFS+.