on master help sign in
Change small chunk size from 4KB to 256B

--HG-- extra : convert_revision : 3834278b15b1c4206cedcc7ebdf36d2d0b9668dd

commit7636c9608c76c09b63f216203d0bc53f196b39d7 authorBryan O'Sullivan <bos@serpentine.com> dateThu 15 Jul 2010, 21:49 (16 years ago) parentcba5e77
1 file changed+8−8
Data/Text/Lazy/Internal.hs+8−8
Data/Text/Lazy/Internal.hs+8−8
@@ -32,8 +32,8 @@ module Data.Text.Lazy.Internal
3232
3333import qualified Data.Text.Internal as T
3434import Data.Text ()
35+import Data.Text.UnsafeShift
3536import Data.Typeable (Typeable)
36−import Data.Word (Word16)
3737import Foreign.Storable (sizeOf)
3838
3939data Text = Empty
@@ -87,17 +87,17 @@ foldlChunks f z = go z
8787 go !a (Chunk c cs) = go (f a c) cs
8888{-# INLINE foldlChunks #-}
8989
90−-- | Currently set to 32k, less the memory management overhead.
90+-- | Currently set to 32KB, less the memory management overhead.
9191defaultChunkSize :: Int
92−defaultChunkSize = 32 * k - chunkOverhead
93− where k = 1024 `div` sizeOf (undefined :: Word16)
92+defaultChunkSize = 16384 - chunkOverhead
9493{-# INLINE defaultChunkSize #-}
9594
96−-- | Currently set to 4k, less the memory management overhead.
95+-- | Currently set to 256 bytes, less the memory management overhead.
9796smallChunkSize :: Int
98−smallChunkSize = 4 * k - chunkOverhead
99− where k = 1024 `div` sizeOf (undefined :: Word16)
97+smallChunkSize = 128 - chunkOverhead
98+{-# INLINE smallChunkSize #-}
10099
101100-- | The memory management overhead. Currently this is tuned for GHC only.
102101chunkOverhead :: Int
103−chunkOverhead = 2 * sizeOf (undefined :: Int)
102+chunkOverhead = sizeOf (undefined :: Int) `shiftL` 1
103+{-# INLINE chunkOverhead #-}