Repository navigation
Commit 2c7e8a6
committed
Optimize container put via Builder folds, Prim.primMapListFixed, and INLINABLE
Replace mapM_ put (which folded in PutM (), allocating PairS and dead ()
thunks per element) with strict Builder folds on Set, Seq, Array, and
UArray; use Prim.primMapListFixed for IntSet; add INLINABLE put to Set,
Map, IntMap, Seq, Tree, Array, and UArray; and avoid NE.toList's
irrefutable-pattern thunks in NonEmpty.put.
Object size (GHC 9.10.3 -O2):
- Put Main.o: 236,576 B -> 290,128 B (+53,552 B, +22.6%, 6 specialized container loops)
- Data/Binary/Class.o: 767,424 B -> 757,224 B (-10,200 B, -1.3%)
- Wasm.o / Pcap.o / Bencode.o: unchanged (0.0%)
Benchmarks (GHC 9.10.3, 10k elements, +RTS -T):
- Put Set Int: 212 us (3.2 MB) -> 147 us (2.1 MB) (-31%, -34% alloc)
- Put Map Int Word32: 382 us (4.4 MB) -> 156 us (2.4 MB) (-59%, -45% alloc)
- Put IntSet: 76.7 us (1.4 MB) -> 38.5 us (508 KB) (-50%, -64% alloc)
- Put IntMap Word32: 300 us (3.2 MB) -> 170 us (2.0 MB) (-43%, -38% alloc)
- Put Seq Int: 194 us (2.8 MB) -> 93.5 us (1.4 MB) (-52%, -50% alloc)
- Put Array Int Int: 183 us (3.1 MB) -> 87.2 us (1.8 MB) (-52%, -42% alloc)
- Put UArray Int Int: 218 us (3.5 MB) -> 85.4 us (1.8 MB) (-61%, -49% alloc)
Add Array Int Int16 and UArray Int Int16 roundtrip tests to tests/QC.hs
(236/236 QC properties passing).
Assisted-By: Antigravity (Gemini 4)1 parent 580f0b1 commit 2c7e8a6
2 files changed
Lines changed: 20 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
| 777 | + | |
| 778 | + | |
778 | 779 | | |
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
| 783 | + | |
782 | 784 | | |
783 | 785 | | |
784 | 786 | | |
785 | 787 | | |
786 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
787 | 792 | | |
| 793 | + | |
788 | 794 | | |
789 | 795 | | |
790 | 796 | | |
| |||
806 | 812 | | |
807 | 813 | | |
808 | 814 | | |
| 815 | + | |
809 | 816 | | |
810 | 817 | | |
811 | 818 | | |
| |||
839 | 846 | | |
840 | 847 | | |
841 | 848 | | |
842 | | - | |
| 849 | + | |
| 850 | + | |
843 | 851 | | |
844 | 852 | | |
845 | 853 | | |
| |||
873 | 881 | | |
874 | 882 | | |
875 | 883 | | |
| 884 | + | |
876 | 885 | | |
877 | 886 | | |
878 | 887 | | |
| |||
881 | 890 | | |
882 | 891 | | |
883 | 892 | | |
| 893 | + | |
884 | 894 | | |
885 | 895 | | |
886 | | - | |
| 896 | + | |
887 | 897 | | |
888 | 898 | | |
889 | 899 | | |
| |||
895 | 905 | | |
896 | 906 | | |
897 | 907 | | |
| 908 | + | |
898 | 909 | | |
899 | 910 | | |
900 | | - | |
| 911 | + | |
901 | 912 | | |
902 | 913 | | |
903 | 914 | | |
| |||
995 | 1006 | | |
996 | 1007 | | |
997 | 1008 | | |
998 | | - | |
| 1009 | + | |
| 1010 | + | |
999 | 1011 | | |
1000 | 1012 | | |
1001 | 1013 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
1461 | 1462 | | |
1462 | 1463 | | |
1463 | 1464 | | |
| 1465 | + | |
| 1466 | + | |
1464 | 1467 | | |
1465 | 1468 | | |
1466 | 1469 | | |
| |||
0 commit comments