on master help sign in
Change small chunk size from 4KB to 256B
7636c96Bryan O'Sullivan
Data/Text/Lazy/Internal.hs+8−8
@@ -32,8 +32,8 @@ module Data.Text.Lazy.Internal
32
32
33import qualified Data.Text.Internal as T
33import qualified Data.Text.Internal as T
34import Data.Text ()
34import Data.Text ()
35+import Data.Text.UnsafeShift
35import Data.Typeable (Typeable)
36import Data.Typeable (Typeable)
36−import Data.Word (Word16)
37import Foreign.Storable (sizeOf)
37import Foreign.Storable (sizeOf)
38
38
39data Text = Empty
39data Text = Empty
@@ -87,17 +87,17 @@ foldlChunks f z = go z
87 go !a (Chunk c cs) = go (f a c) cs
87 go !a (Chunk c cs) = go (f a c) cs
88{-# INLINE foldlChunks #-}
88{-# INLINE foldlChunks #-}
89
89
90−-- | Currently set to 32k, less the memory management overhead.
90+-- | Currently set to 32KB, less the memory management overhead.
91defaultChunkSize :: Int
91defaultChunkSize :: Int
92−defaultChunkSize = 32 * k - chunkOverhead
92+defaultChunkSize = 16384 - chunkOverhead
93− where k = 1024 `div` sizeOf (undefined :: Word16)
94{-# INLINE defaultChunkSize #-}
93{-# INLINE defaultChunkSize #-}
95
94
96−-- | Currently set to 4k, less the memory management overhead.
95+-- | Currently set to 256 bytes, less the memory management overhead.
97smallChunkSize :: Int
96smallChunkSize :: Int
98−smallChunkSize = 4 * k - chunkOverhead
97+smallChunkSize = 128 - chunkOverhead
99− where k = 1024 `div` sizeOf (undefined :: Word16)
98+{-# INLINE smallChunkSize #-}
100
99
101-- | The memory management overhead. Currently this is tuned for GHC only.
100-- | The memory management overhead. Currently this is tuned for GHC only.
102chunkOverhead :: Int
101chunkOverhead :: Int
103−chunkOverhead = 2 * sizeOf (undefined :: Int)
102+chunkOverhead = sizeOf (undefined :: Int) `shiftL` 1
103+{-# INLINE chunkOverhead #-}