forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7f380c5
committed
Reduce size of backend scanner's tables.
Previously, the core scanner's yy_transition[] array had 37045 elements.Since that number is larger than INT16_MAX, Flex generated the array tocontain 32-bit integers. By reimplementing some of the bulkier scannerrules, this patch reduces the array to 20495 elements. The much smallertotal length, combined with the consequent use of 16-bit integers forthe array elements reduces the binary size by over 200kB. This wasaccomplished in two ways:1. Consolidate handling of quote continuations into a new start condition,rather than duplicating that logic for five different string types.2. Treat Unicode strings and identifiers followed by a UESCAPE sequenceas three separate tokens, rather than one. The logic to de-escapeUnicode strings is moved to the filter code in parser.c, which alreadyhad the ability to provide special processing for token sequences.While we could have implemented the conversion in the grammar, thatapproach was rejected for performance and maintainability reasons.Performance in microbenchmarks of raw parsing seems equal or slightlyfaster in most cases, and it's reasonable to expect that in real-worldusage (with more competition for the CPU cache) there will be a largerwin. The exception is UESCAPE sequences; lexing those is about 10%slower, primarily because the scanner now has to be called three timesrather than one. This seems acceptable since that feature is veryrarely used.The psql and epcg lexers are likewise modified, primarily because wewant to keep them all in sync. Since those lexers don't use thespace-hogging -CF option, the space savings is much less, but it'sstill good for perhaps 10kB apiece.While at it, merge the ecpg lexer's handling of C-style comments usedin SQL and in C. Those have different rules regarding nested comments,but since we already have the ability to keep track of the previousstart condition, we can use that to handle both cases within a singlestart condition. This matches the core scanner more closely.John NaylorDiscussion:https://postgr.es/m/CACPNZCvaoa3EgVWm5yZhcSTX6RAtaLgniCPcBVOCwm8h3xpWkw@mail.gmail.com1 parent259bbe1 commit7f380c5
File tree
19 files changed
+671
-619
lines changed- src
- backend/parser
- fe_utils
- include
- fe_utils
- mb
- parser
- interfaces/ecpg
- preproc
- test/expected
- pl/plpgsql/src
- test/regress
- expected
- sql
19 files changed
+671
-619
lines changedLines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
598 | 598 |
| |
599 | 599 |
| |
600 | 600 |
| |
| 601 | + | |
| 602 | + | |
| 603 | + | |
601 | 604 |
| |
602 | 605 |
| |
603 | 606 |
| |
604 |
| - | |
| 607 | + | |
605 | 608 |
| |
606 | 609 |
| |
607 | 610 |
| |
| |||
691 | 694 |
| |
692 | 695 |
| |
693 | 696 |
| |
694 |
| - | |
695 |
| - | |
| 697 | + | |
| 698 | + | |
696 | 699 |
| |
697 | 700 |
| |
698 | 701 |
| |
| |||
15374 | 15377 |
| |
15375 | 15378 |
| |
15376 | 15379 |
| |
| 15380 | + | |
15377 | 15381 |
| |
15378 | 15382 |
| |
15379 | 15383 |
| |
|
Lines changed: 281 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 |
| |
27 | 33 |
| |
28 | 34 |
| |
| |||
75 | 81 |
| |
76 | 82 |
| |
77 | 83 |
| |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 |
| |
79 | 89 |
| |
80 | 90 |
| |
| |||
104 | 114 |
| |
105 | 115 |
| |
106 | 116 |
| |
107 |
| - | |
| 117 | + | |
108 | 118 |
| |
109 | 119 |
| |
110 | 120 |
| |
| |||
117 | 127 |
| |
118 | 128 |
| |
119 | 129 |
| |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
120 | 134 |
| |
121 | 135 |
| |
122 | 136 |
| |
| |||
190 | 204 |
| |
191 | 205 |
| |
192 | 206 |
| |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
193 | 276 |
| |
194 | 277 |
| |
195 | 278 |
| |
196 | 279 |
| |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + |
0 commit comments
Comments
(0)