@@ -62,36 +62,76 @@ cpp-options: -DBENCH_containers_Map -DBENCH_containers_IntMap -DBENCH_hashmap_Ma
6262
6363## Inspecting the generated code
6464
65- The library section in ` unordered-containers. cabal` contains a commented-out set of ` ghc-options ` for
66- dumping Core and other forms of generated code. To dump this code, uncomment these options and run
65+ The file ` cabal.project.local.dump-code ` contains ` ghc-options ` for dumping Core and
66+ other forms of generated code. To generate these dump files, run
6767
6868```
69+ cp cabal.project.local.dump-code cabal.project.local
6970cabal clean
70- cabal build
71+ cabal build benches tests
72+ ```
73+
74+ You can find the resulting ` .dump-* ` files in ` dist-newstyle/build/*/*/unordered-containers-*/ ` , e.g.
75+
76+ ```
77+ $ tree dist-newstyle/build/*/*/unordered-containers-*/
78+ dist-newstyle/build/x86_64-linux/ghc-9.12.2/unordered-containers-0.2.20.1/
79+ ├── b
80+ │ ├── fine-grained
81+ │ │ ├── build
82+ │ │ │ └── fine-grained
83+ │ │ │ ├── autogen
84+ │ │ │ │ ├── cabal_macros.h
85+ │ │ │ │ ├── PackageInfo_unordered_containers.hs
86+ │ │ │ │ └── Paths_unordered_containers.hs
87+ │ │ │ ├── fine-grained
88+ │ │ │ └── fine-grained-tmp
89+ │ │ │ ├── benchmarks
90+ │ │ │ │ ├── FineGrained.dump-asm
91+ │ │ │ │ ├── FineGrained.dump-cmm
92+ │ │ │ │ ├── FineGrained.dump-prep
93+ │ │ │ │ ├── FineGrained.dump-simpl
94+ ...
7195```
7296
73- You can find the resulting ` .dump-* ` files in ` dist-newstyle/build/**/unordered-containers-*/build/ ` , e.g.
97+ To visually compare the generated code from two different states of the source tree,
98+ you can copy the ` dist-newstyle/build/*/*/unordered-containers-*/ ` directory from
99+ each state to separate directories and then use a diff tool like
100+ [ Meld] ( https://meldmerge.org/ ) to compare them:
74101
75102```
76- $ tree dist-newstyle/build/x86_64-linux/ghc-9.2.2/unordered-containers-0.2.16.0/build/
77- dist-newstyle/build/x86_64-linux/ghc-9.2.2/unordered-containers-0.2.16.0/build/
78- ├── Data
79- │ ├── HashMap
80- │ │ ├── Internal
81- │ │ │ ├── Array.dump-asm
82- │ │ │ ├── Array.dump-cmm
83- │ │ │ ├── Array.dump-simpl
84- │ │ │ ├── Array.dump-stg-final
85- ...
103+ cabal clean
104+ cabal build benches tests
105+ mkdir dump-$(git rev-parse HEAD)
106+ cp -r dist-newstyle/build/*/*/unordered-containers-*/ dump-$(git rev-parse HEAD)
107+ # Repeat at different commit
108+ meld dump-*
109+ ```
110+
111+ Because the files with the generated code are so large, it can be helpful to
112+ temporarily add a small "playground module" to the library:
113+
114+ In ` unordered-containers ` :
115+
116+ ``` diff
117+ library:
118+ exposed-modules:
119+ ...
120+ Data.HashSet
121+ Data.HashSet.Internal
122+ + Playground
86123```
87124
88- To visually compare the generated code from two different states of the source tree, you can copy
89- the ` dist-newstyle/build/**/unordered-containers-*/build/ ` directory from each state to two
90- directories ` a ` and ` b ` and then use a diff tool like [ Meld] ( https://meldmerge.org/ ) to compare
91- them:
125+ ` Playground.hs ` :
92126
93127```
94- meld a/ b/
128+ {-# language TypeApplications #-}
129+ module Playground where
130+
131+ import qualified Data.HashMap.Internal as HMI
132+ import qualified Data.HashMap.Strict as HS
133+
134+ f = HS.union @String
95135```
96136
97137### References
0 commit comments