- Notifications
You must be signed in to change notification settings - Fork28
Commitc64d0cd
committed
Use perfect hashing, instead of binary search, for keyword lookup.
We've been speculating for a long time that hash-based keyword lookupought to be faster than binary search, but up to now we hadn't founda suitable tool for generating the hash function. Joerg Sonnenbergerprovided the inspiration, and sample code, to show us that rolling ourown generator wasn't a ridiculous idea. Hence, do that.The method used here requires a lookup table of approximately 4 bytesper keyword, but that's less than what we saved in the predecessor commitafb0d07, so it's not a big problem. The time savings is indeedsignificant: preliminary testing suggests that the total time for rawparsing (flex + bison phases) drops by ~20%.Patch by me, but it owes its existence to Joerg Sonnenberger;thanks also to John Naylor for review.Discussion:https://postgr.es/m/20190103163340.GA15803@britannica.bec.de1 parent5d59a6c commitc64d0cd
File tree
14 files changed
+516
-107
lines changed- src
- common
- include
- common
- parser
- interfaces/ecpg/preproc
- pl/plpgsql/src
- tools
- msvc
14 files changed
+516
-107
lines changedLines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 |
| |
67 | 72 |
| |
68 | 73 |
| |
| |||
118 | 123 |
| |
119 | 124 |
| |
120 | 125 |
| |
121 |
| - | |
122 |
| - | |
| 126 | + | |
| 127 | + | |
123 | 128 |
| |
124 | 129 |
| |
125 | 130 |
| |
|
Lines changed: 32 additions & 41 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 |
| - | |
| 38 | + | |
39 | 39 |
| |
40 | 40 |
| |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
50 | 44 |
| |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
51 | 50 |
| |
52 |
| - | |
53 |
| - | |
54 |
| - | |
55 |
| - | |
| 51 | + | |
56 | 52 |
| |
57 | 53 |
| |
58 |
| - | |
59 |
| - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
60 | 57 |
| |
61 |
| - | |
62 |
| - | |
63 |
| - | |
| 58 | + | |
64 | 59 |
| |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 |
| - | |
69 |
| - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
70 | 63 |
| |
71 | 64 |
| |
72 |
| - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
73 | 69 |
| |
74 |
| - | |
75 |
| - | |
76 |
| - | |
77 |
| - | |
78 |
| - | |
| 70 | + | |
| 71 | + | |
79 | 72 |
| |
80 |
| - | |
81 |
| - | |
| 73 | + | |
82 | 74 |
| |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
91 | 79 |
| |
| 80 | + | |
| 81 | + | |
92 | 82 |
| |
93 |
| - | |
| 83 | + | |
| 84 | + | |
94 | 85 |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 |
| |
18 | 21 |
| |
19 | 22 |
| |
| |||
23 | 26 |
| |
24 | 27 |
| |
25 | 28 |
| |
| 29 | + | |
26 | 30 |
| |
27 | 31 |
| |
28 | 32 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
24 |
| - | |
25 |
| - | |
| 24 | + | |
26 | 25 |
| |
27 | 26 |
| |
28 | 27 |
| |
|
Lines changed: 8 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 |
| - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 |
| |
33 | 36 |
| |
34 | 37 |
| |
| |||
56 | 59 |
| |
57 | 60 |
| |
58 | 61 |
| |
59 |
| - | |
60 |
| - | |
| 62 | + | |
| 63 | + | |
61 | 64 |
| |
62 |
| - | |
63 |
| - | |
| 65 | + | |
| 66 | + | |
64 | 67 |
| |
65 | 68 |
| |
66 | 69 |
| |
|
Lines changed: 24 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
13 |
| - | |
14 | 12 |
| |
15 | 13 |
| |
16 | 14 |
| |
| |||
32 | 30 |
| |
33 | 31 |
| |
34 | 32 |
| |
35 |
| - | |
| 33 | + | |
36 | 34 |
| |
37 | 35 |
| |
38 | 36 |
| |
39 |
| - | |
| 37 | + | |
40 | 38 |
| |
41 |
| - | |
42 |
| - | |
43 |
| - | |
44 |
| - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 |
| |
46 |
| - | |
47 |
| - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
48 | 56 |
| |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 |
| - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
53 | 60 |
| |
54 |
| - | |
55 |
| - | |
56 |
| - | |
57 |
| - | |
| 61 | + | |
58 | 62 |
| |
59 |
| - | |
60 |
| - | |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 |
| - | |
65 |
| - | |
66 |
| - | |
67 |
| - | |
| 63 | + | |
| 64 | + | |
68 | 65 |
| |
69 | 66 |
| |
70 | 67 |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
24 |
| - | |
| 23 | + | |
25 | 24 |
| |
26 | 25 |
| |
27 | 26 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
24 |
| - | |
| 23 | + | |
25 | 24 |
| |
26 | 25 |
| |
27 | 26 |
| |
|
Lines changed: 8 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 |
| |
34 | 37 |
| |
35 | 38 |
| |
| |||
76 | 79 |
| |
77 | 80 |
| |
78 | 81 |
| |
79 |
| - | |
80 |
| - | |
| 82 | + | |
| 83 | + | |
81 | 84 |
| |
82 |
| - | |
83 |
| - | |
| 85 | + | |
| 86 | + | |
84 | 87 |
| |
85 | 88 |
| |
86 | 89 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
| 23 | + | |
24 | 24 |
| |
25 |
| - | |
26 |
| - | |
| 25 | + | |
27 | 26 |
| |
28 | 27 |
| |
29 | 28 |
| |
|
Lines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
23 |
| - | |
24 |
| - | |
| 23 | + | |
| 24 | + | |
25 | 25 |
| |
26 |
| - | |
27 |
| - | |
| 26 | + | |
28 | 27 |
| |
29 | 28 |
| |
30 | 29 |
| |
|
0 commit comments
Comments
(0)