Commit 5945e4d
Patrick Häcker
fix: bound type-parameter expansion to prevent gigabyte caches
FakeTypeName expanded a type's parameters recursively with no size bound.
A few types explode into enormous trees: type-domain packages whose types
recurse into themselves (e.g. TypeDomainNaturalNumbers — naturals as nested
types, rationals as continued fractions), and even some Base/LinearAlgebra
signatures whose `where`-bounded `Union`s reach tens of thousands of nodes.
This produced multi-gigabyte cache files (2.2 GB for TypeDomainNaturalNumbers)
that exhausted memory — OOMing the machine — when read back into the store.
Cap expansion with a per-type budget of expanded DataTypes
(MAX_EXPANDED_TYPES = 128): once it is spent, a type's remaining parameters
are dropped and only its name is kept. The budget bounds any shape of
explosion (depth, width, or indirect recursion through variable bounds),
while ordinary types stay far below it and are unaffected. Add a regression
test.
Ported from julia-vscode/SymbolServer.jl#320 (SymbolServer.jl is deprecated;
the code now lives here under shared/symbolserver/).1 parent 6424c73 commit 5945e4d
2 files changed
Lines changed: 54 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
18 | 36 | | |
19 | 37 | | |
20 | 38 | | |
21 | 39 | | |
22 | 40 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
27 | 47 | | |
28 | 48 | | |
29 | 49 | | |
30 | | - | |
| 50 | + | |
31 | 51 | | |
32 | | - | |
| 52 | + | |
33 | 53 | | |
34 | | - | |
| 54 | + | |
35 | 55 | | |
36 | 56 | | |
37 | 57 | | |
| |||
50 | 70 | | |
51 | 71 | | |
52 | 72 | | |
53 | | - | |
| 73 | + | |
54 | 74 | | |
55 | 75 | | |
56 | 76 | | |
57 | 77 | | |
58 | 78 | | |
59 | | - | |
| 79 | + | |
60 | 80 | | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
64 | | - | |
| 84 | + | |
65 | 85 | | |
66 | | - | |
| 86 | + | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
72 | | - | |
| 92 | + | |
73 | 93 | | |
74 | | - | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
779 | 779 | | |
780 | 780 | | |
781 | 781 | | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
0 commit comments