Add SmallArray# and SmallMutableArray# types
authorJohan Tibell <johan.tibell@gmail.com>
Sun, 23 Mar 2014 11:06:56 +0000 (12:06 +0100)
committerJohan Tibell <johan.tibell@gmail.com>
Sat, 29 Mar 2014 10:24:07 +0000 (11:24 +0100)
commit90329b6cc183b3cd05956ae6bdeb6ac6951549c2
treeba7d31656fe75fad2555c8a66b7ebd13dd9ebeb1
parent4c8edfd2c722504baaa6896d194fd3a8c3f9b652
Add SmallArray# and SmallMutableArray# types

These array types are smaller than Array# and MutableArray# and are
faster when the array size is small, as they don't have the overhead
of a card table. Having no card table reduces the closure size with 2
words in the typical small array case and leads to less work when
updating or GC:ing the array.

Reduces both the runtime and memory allocation by 8.8% on my insert
benchmark for the HashMap type in the unordered-containers package,
which makes use of lots of small arrays. With tuned GC settings
(i.e. `+RTS -A6M`) the runtime reduction is 15%.

Fixes #8923.
39 files changed:
compiler/cmm/CLabel.hs
compiler/cmm/CmmParse.y
compiler/cmm/SMRep.lhs
compiler/codeGen/StgCmmBind.hs
compiler/codeGen/StgCmmCon.hs
compiler/codeGen/StgCmmForeign.hs
compiler/codeGen/StgCmmLayout.hs
compiler/codeGen/StgCmmPrim.hs
compiler/ghci/ByteCodeGen.lhs
compiler/ghci/RtClosureInspect.hs
compiler/prelude/PrelNames.lhs
compiler/prelude/TysPrim.lhs
compiler/prelude/primops.txt.pp
includes/Cmm.h
includes/rts/storage/ClosureMacros.h
includes/rts/storage/ClosureTypes.h
includes/rts/storage/Closures.h
includes/stg/MiscClosures.h
rts/CheckUnload.c
rts/ClosureFlags.c
rts/LdvProfile.c
rts/Linker.c
rts/PrimOps.cmm
rts/Printer.c
rts/ProfHeap.c
rts/RetainerProfile.c
rts/StgMiscClosures.cmm
rts/sm/Compact.c
rts/sm/Evac.c
rts/sm/Scav.c
testsuite/tests/codeGen/should_run/CopySmallArray.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/CopySmallArray.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/CopySmallArrayStressTest.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/CopySmallArrayStressTest.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/SizeOfSmallArray.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/SizeOfSmallArray.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/all.T
utils/deriveConstants/DeriveConstants.hs
utils/genprimopcode/Main.hs