-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit ab06e51
refactor: WIP. Module name to filepath optimisation
This is related to #4598.
This changes the file to module associating logic done during dependency
graph building.
Before, each time a module `Foo.Bar` is found, HLS is testing inside all
the import path for the existence of a relevant fiel.. It means that for
`i` import paths and `m` modules to locate, `m * n` filesystem
operations are done. Note also that this involves a lot of complex
string concatenation primitive to build the `FilePath`.
A module is tested for each `import` for each of the file of the
project. We also test for `boot` files, doubling the number of test.
In #4598 we have a project with `1100` modules, in more than 250 import
paths and we count more than `17000` `import` statments, resulting on
over 6 millions test for file existences. This project was blocking for
more than 3 minutes during HLS startup.
This commit changes the way this is computed:
- At startup, a `Map ModuleName FilePath` (the real type is a bit more
involved for performance, multiples unit and boot files handling) is
built by scanning all the import paths for files representing the
different modules.
- Directory scanning is efficient and if import path only contains
haskell module, this will never do more job that listing the files of
the project.
- The lookup is now simplify a `Map` lookup.
The performance improvement is as follows:
- The number of IO operation is dramatically reduced, from multiples
millions to a few recursive directories listing.
- A lot of the boilerplate of converting path had be removed.
- TODO: add an RTS stats before / after with number of allocations
- On my project, the graph building time is reduced from a few minutes
to 3s.
Limitations:
- How to rebuild the `Map` if the content of one directory change?
- If one directory is filled with millions of files which are not of
interested, performance can be damaged. TODO: add a diagnostic during
this phase so the user can learn about this issue.
Code status:
- The `lookup` is not fully restored, especially it does not include the
handling of home unit as well as reexport.
- The initialisation phase is cached inside a `TVar` stored as a top
level identifier using `unsafePerformIO`. This is to be improved.1 parent 321e12e commit ab06e51
File tree
5 files changed
+96
-16
lines changed- ghcide
- src/Development/IDE
- Core
- Import
- Types
5 files changed
+96
-16
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
110 | + | ||
110 | 111 |
| |
111 | 112 |
| |
112 | 113 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
392 | 392 |
| |
393 | 393 |
| |
394 | 394 |
| |
395 | + | ||
396 | + | ||
397 | + | ||
395 | 398 |
| |
396 | 399 |
| |
397 | 400 |
| |
| |||
494 | 497 |
| |
495 | 498 |
| |
496 | 499 |
| |
500 | + | ||
501 | + | ||
502 | + | ||
503 | + | ||
504 | + | ||
505 | + | ||
506 | + | ||
497 | 507 |
| |
498 | 508 |
| |
499 | 509 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 | + | ||
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
| |||
93 | 94 |
| |
94 | 95 |
| |
95 | 96 |
| |
96 | - | ||
97 | + | ||
97 | 98 |
| |
98 | 99 |
| |
99 | 100 |
| |
| |||
173 | 174 |
| |
174 | 175 |
| |
175 | 176 |
| |
177 | + | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
182 | + | ||
176 | 183 |
| |
177 | 184 |
| |
178 | 185 |
| |
| |||
311 | 318 |
| |
312 | 319 |
| |
313 | 320 |
| |
321 | + | ||
314 | 322 |
| |
315 | 323 |
| |
316 | 324 |
| |
| |||
333 | 341 |
| |
334 | 342 |
| |
335 | 343 |
| |
344 | + | ||
345 | + | ||
336 | 346 |
| |
337 | - | ||
347 | + | ||
348 | + | ||
338 | 349 |
| |
339 | 350 |
| |
340 | 351 |
| |
| |||
624 | 635 |
| |
625 | 636 |
| |
626 | 637 |
| |
638 | + | ||
639 | + | ||
640 | + | ||
641 | + | ||
642 | + | ||
643 | + | ||
644 | + | ||
645 | + | ||
646 | + | ||
647 | + | ||
648 | + | ||
649 | + | ||
650 | + | ||
651 | + | ||
652 | + | ||
653 | + | ||
654 | + | ||
655 | + | ||
656 | + | ||
657 | + | ||
658 | + | ||
659 | + | ||
660 | + | ||
661 | + | ||
662 | + | ||
663 | + | ||
664 | + | ||
665 | + | ||
666 | + | ||
667 | + | ||
668 | + | ||
669 | + | ||
670 | + | ||
671 | + | ||
672 | + | ||
673 | + | ||
674 | + | ||
627 | 675 |
| |
628 | 676 |
| |
629 | 677 |
| |
| |||
632 | 680 |
| |
633 | 681 |
| |
634 | 682 |
| |
683 | + | ||
635 | 684 |
| |
685 | + | ||
686 | + | ||
636 | 687 |
| |
688 | + | ||
637 | 689 |
| |
638 | 690 |
| |
639 | 691 |
| |
| |||
1232 | 1284 |
| |
1233 | 1285 |
| |
1234 | 1286 |
| |
1287 | + | ||
1235 | 1288 |
| |
1236 | 1289 |
| |
1237 | 1290 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 | - | ||
9 | 8 |
| |
10 | 9 |
| |
11 | 10 |
| |
| |||
14 | 13 |
| |
15 | 14 |
| |
16 | 15 |
| |
17 | - | ||
18 | 16 |
| |
19 | - | ||
17 | + | ||
20 | 18 |
| |
21 | 19 |
| |
22 | 20 |
| |
| |||
26 | 24 |
| |
27 | 25 |
| |
28 | 26 |
| |
29 | - | ||
27 | + | ||
28 | + | ||
30 | 29 |
| |
31 | 30 |
| |
32 | 31 |
| |
| |||
70 | 69 |
| |
71 | 70 |
| |
72 | 71 |
| |
72 | + | ||
73 | 73 |
| |
74 | 74 |
| |
75 | 75 |
| |
| |||
94 | 94 |
| |
95 | 95 |
| |
96 | 96 |
| |
97 | + | ||
97 | 98 |
| |
98 | 99 |
| |
99 | 100 |
| |
| |||
110 | 111 |
| |
111 | 112 |
| |
112 | 113 |
| |
113 | - | ||
114 | + | ||
115 | + | ||
114 | 116 |
| |
115 | 117 |
| |
116 | 118 |
| |
117 | 119 |
| |
118 | 120 |
| |
119 | 121 |
| |
120 | 122 |
| |
121 | - | ||
123 | + | ||
122 | 124 |
| |
123 | 125 |
| |
124 | 126 |
| |
127 | + | ||
125 | 128 |
| |
126 | - | ||
129 | + | ||
127 | 130 |
| |
128 | 131 |
| |
129 | 132 |
| |
130 | 133 |
| |
131 | - | ||
134 | + | ||
132 | 135 |
| |
133 | 136 |
| |
134 | 137 |
| |
135 | 138 |
| |
136 | 139 |
| |
137 | 140 |
| |
138 | - | ||
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | ||
139 | 151 |
| |
140 | 152 |
| |
141 | 153 |
| |
142 | - | ||
154 | + | ||
143 | 155 |
| |
144 | 156 |
| |
145 | 157 |
| |
| |||
180 | 192 |
| |
181 | 193 |
| |
182 | 194 |
| |
183 | - | ||
184 | - | ||
195 | + | ||
196 | + | ||
197 | + | ||
198 | + | ||
199 | + | ||
200 | + | ||
185 | 201 |
| |
186 | 202 |
| |
187 | 203 |
| |
188 | - | ||
204 | + | ||
189 | 205 |
| |
190 | 206 |
| |
191 | 207 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 | - | ||
4 | + | ||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
|
0 commit comments