Commit f62a9f6
authored
Speed up fastscan package (#249)
I looked a little bit into why the `fastscan` package was slower than I
expected. And it's because I accidentally left stuff in the lexer that
is totally unused but is the primary source of allocations and memory
usage (and thus also bad for latency since allocations aren't free).
Once upon a time, in an older version of the lexer in protoparse (on
which this fastscan lexer is based), this stuff was used to capture the
actual raw text for a token. The new lexer in protocompile uses a
completely different approach, to reduce the memory usage. But it's
completely unused here.
Removing it basically doubles the throughput of `fastscan` and causes it
to use 1/3rd as many allocations and 1/4th as much memory.
```
-- before --
BenchmarkGoogleapisFastScan-10 5 210397558 ns/op 468123099 B/op 11217259 allocs/op
BenchmarkGoogleapisFastScan-10 5 202723933 ns/op 468156548 B/op 11217275 allocs/op
-- after --
BenchmarkGoogleapisFastScan-10 12 93760795 ns/op 111257610 B/op 3710000 allocs/op
BenchmarkGoogleapisFastScan-10 12 94548743 ns/op 111259758 B/op 3710010 allocs/op
```1 parent f4c4a6f commit f62a9f6
1 file changed
+0
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | | - | |
102 | | - | |
103 | 97 | | |
104 | 98 | | |
105 | 99 | | |
106 | 100 | | |
107 | 101 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 102 | | |
115 | 103 | | |
116 | 104 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | 105 | | |
128 | 106 | | |
129 | 107 | | |
| |||
161 | 139 | | |
162 | 140 | | |
163 | 141 | | |
164 | | - | |
165 | | - | |
166 | 142 | | |
167 | 143 | | |
168 | 144 | | |
| |||
181 | 157 | | |
182 | 158 | | |
183 | 159 | | |
184 | | - | |
185 | 160 | | |
186 | 161 | | |
187 | 162 | | |
| |||
0 commit comments