Commit bea3d7e
committed
Use MemoryContext API for regex memory management.
Previously, regex_t objects' memory was managed with malloc() and free()
directly. Switch to palloc()-based memory management instead.
Advantages:
* memory used by cached regexes is now visible with MemoryContext
observability tools
* cleanup can be done automatically in certain failure modes
(something that later commits will take advantage of)
* cleanup can be done in bulk
On the downside, there may be more fragmentation (wasted memory) due to
per-regex MemoryContext objects. This is a problem shared with other
cached objects in PostgreSQL and can probably be improved with later
tuning.
Thanks to Noah Misch for suggesting this general approach, which
unblocks later work on interrupts.
Suggested-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com1 parent fcd77d5 commit bea3d7e
File tree
3 files changed
+45
-20
lines changed- src
- backend
- regex
- utils/adt
- include/regex
3 files changed
+45
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| 105 | + | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| |||
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| |||
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
| |||
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
186 | 210 | | |
187 | 211 | | |
188 | 212 | | |
| |||
209 | 233 | | |
210 | 234 | | |
211 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
212 | 240 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 241 | + | |
| 242 | + | |
217 | 243 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
227 | 247 | | |
228 | 248 | | |
229 | 249 | | |
| |||
236 | 256 | | |
237 | 257 | | |
238 | 258 | | |
239 | | - | |
240 | | - | |
| 259 | + | |
| 260 | + | |
241 | 261 | | |
242 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
243 | 266 | | |
244 | 267 | | |
245 | 268 | | |
246 | 269 | | |
247 | 270 | | |
248 | 271 | | |
| 272 | + | |
| 273 | + | |
249 | 274 | | |
250 | 275 | | |
251 | 276 | | |
| |||
1990 | 2015 | | |
1991 | 2016 | | |
1992 | 2017 | | |
1993 | | - | |
| 2018 | + | |
1994 | 2019 | | |
1995 | 2020 | | |
1996 | 2021 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
0 commit comments