Commit 2bfe32c
committed
Avoid regenerating the
`FileSearch::search()` traverses one or more directories. For each
directory it generates a `Vec<PathBuf>` containing one element per file
in that directory.
In some benchmarks this occurs enough that the allocations done for the
`PathBuf`s are significant, and in practice a small number of
directories are being traversed over and over again. For example, when
compiling the `tokio-webpush-simple` benchmark, two directories are
traversed 58 times each. Each of these directories have more than 100
files.
This commit changes things so that all the `Vec<PathBuf>`s that will be
needed by a `Session` are precomputed when that `Session` is created;
they are stored in `SearchPath`. `FileSearch` gets a reference to the
necessary `SearchPath`s. This reduces instruction counts on several
benchmarks by 1--5%.
The commit also removes the barely-used `visited_dirs` hash in
`for_each_lib_searchPath`. It only detects if `tlib_path` is the same as
one of the previously seen paths, which is unlikely.Vec<PathBuf> in FileSearch::search().1 parent f130061 commit 2bfe32c
3 files changed
+42
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | | - | |
35 | 33 | | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
49 | 46 | | |
50 | 47 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 48 | + | |
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
| |||
65 | 57 | | |
66 | 58 | | |
67 | 59 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 60 | | |
75 | 61 | | |
76 | 62 | | |
77 | 63 | | |
78 | 64 | | |
79 | 65 | | |
80 | 66 | | |
81 | | - | |
82 | | - | |
| 67 | + | |
| 68 | + | |
83 | 69 | | |
84 | 70 | | |
85 | 71 | | |
| |||
98 | 84 | | |
99 | 85 | | |
100 | 86 | | |
101 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
102 | 90 | | |
103 | 91 | | |
104 | 92 | | |
105 | | - | |
106 | 93 | | |
| 94 | + | |
| 95 | + | |
107 | 96 | | |
108 | 97 | | |
109 | 98 | | |
| |||
137 | 126 | | |
138 | 127 | | |
139 | 128 | | |
140 | | - | |
141 | | - | |
| 129 | + | |
142 | 130 | | |
143 | 131 | | |
144 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | 22 | | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
699 | 702 | | |
700 | 703 | | |
701 | 704 | | |
| 705 | + | |
| 706 | + | |
702 | 707 | | |
703 | 708 | | |
704 | 709 | | |
| |||
707 | 712 | | |
708 | 713 | | |
709 | 714 | | |
| 715 | + | |
710 | 716 | | |
711 | 717 | | |
712 | 718 | | |
| |||
1106 | 1112 | | |
1107 | 1113 | | |
1108 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1109 | 1124 | | |
1110 | 1125 | | |
1111 | 1126 | | |
| |||
1134 | 1149 | | |
1135 | 1150 | | |
1136 | 1151 | | |
| 1152 | + | |
| 1153 | + | |
1137 | 1154 | | |
1138 | 1155 | | |
1139 | 1156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
0 commit comments