Wolfgang Jeltsch pushed to branch wip/jeltsch/file-and-dir-cache-with-fast-string-keys at Glasgow Haskell Compiler / GHC Commits: d71894eb by Wolfgang Jeltsch at 2026-11-25T00:13:25+02:00 Switch from `UniqMap FastString` to `FastStringEnv` - - - - - 1 changed file: - compiler/GHC/Unit/Finder.hs Changes: ===================================== compiler/GHC/Unit/Finder.hs ===================================== @@ -56,6 +56,7 @@ import GHC.Data.IOEnv (IOEnv, runIOEnv, getEnv) import GHC.Data.OsPath import qualified GHC.Data.ShortText as ST import GHC.Data.FastString (FastString, unpackFS) +import GHC.Data.FastString.Env (emptyFsEnv, lookupFsEnv, extendFsEnv) import GHC.Driver.Env import GHC.Driver.Config.Finder @@ -122,30 +123,30 @@ type BaseName = OsPath -- Basename of file initFinderCache :: IO FinderCache initFinderCache = do home_cache <- newHomeFinderCache - file_cache <- newIORef emptyUniqMap - dir_cache <- newIORef emptyUniqMap + file_cache <- newIORef emptyFsEnv + dir_cache <- newIORef emptyFsEnv let flushFinderCaches :: IO () flushFinderCaches = do clearHomeFinderCache home_cache - atomicModifyIORef' file_cache $ \_ -> (emptyUniqMap, ()) - atomicModifyIORef' dir_cache $ \_ -> (emptyUniqMap, ()) + atomicModifyIORef' file_cache $ \_ -> (emptyFsEnv, ()) + atomicModifyIORef' dir_cache $ \_ -> (emptyFsEnv, ()) lookupFileCache :: FastString -> IO Fingerprint lookupFileCache key = do c <- readIORef file_cache - case lookupUniqMap c key of + case lookupFsEnv c key of Nothing -> do hash <- getFileHash (unpackFS key) - atomicModifyIORef' file_cache $ \c -> (addToUniqMap c key hash, ()) + atomicModifyIORef' file_cache $ \c -> (extendFsEnv c key hash, ()) return hash Just fp -> return fp lookupDirCache :: FastString -> IO Fingerprint lookupDirCache key = do c <- readIORef dir_cache - case lookupUniqMap c key of + case lookupFsEnv c key of Nothing -> do hash <- getDirHash (unpackFS key) - atomicModifyIORef' dir_cache $ \c -> (addToUniqMap c key hash, ()) + atomicModifyIORef' dir_cache $ \c -> (extendFsEnv c key hash, ()) return hash Just fp -> return fp return $ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d71894eb719ad89318e5b8645d65e342... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d71894eb719ad89318e5b8645d65e342... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Wolfgang Jeltsch (@jeltsch)