forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita3f0b3d
committed
Improve performance of our private version of qsort. Per recent testing,
the logic it contained to switch to insertion sort for near-sorted input wasin fact a big loss, because it could fairly easily be fooled into applyinginsertion sort to large subfiles that weren't all that well ordered. Removethat, and instead add a simple check for already-perfectly-sorted input, asper suggestion from Dann Corbit. This adds at worst O(N*lgN) overhead, andusually far less, while sometimes allowing a subfile sort to finish in O(N)time. Preliminary testing says this is an improvement over the basicBentley & McIlroy code for many nonrandom inputs, and it costs almostnothing when the input is random.1 parent570b726 commita3f0b3d
1 file changed
+20
-17
lines changedLines changed: 20 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
| 5 | + | |
| 6 | + | |
5 | 7 |
| |
6 |
| - | |
| 8 | + | |
7 | 9 |
| |
8 | 10 |
| |
9 | 11 |
| |
| |||
47 | 49 |
| |
48 | 50 |
| |
49 | 51 |
| |
50 |
| - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 |
| |
52 | 58 |
| |
53 | 59 |
| |
| |||
116 | 122 |
| |
117 | 123 |
| |
118 | 124 |
| |
119 |
| - | |
| 125 | + | |
120 | 126 |
| |
121 | 127 |
| |
122 |
| - | |
123 | 128 |
| |
124 | 129 |
| |
125 | 130 |
| |
| |||
128 | 133 |
| |
129 | 134 |
| |
130 | 135 |
| |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
131 | 147 |
| |
132 | 148 |
| |
133 | 149 |
| |
| |||
144 | 160 |
| |
145 | 161 |
| |
146 | 162 |
| |
147 |
| - | |
148 | 163 |
| |
149 | 164 |
| |
150 | 165 |
| |
151 | 166 |
| |
152 | 167 |
| |
153 | 168 |
| |
154 | 169 |
| |
155 |
| - | |
156 | 170 |
| |
157 | 171 |
| |
158 | 172 |
| |
| |||
162 | 176 |
| |
163 | 177 |
| |
164 | 178 |
| |
165 |
| - | |
166 | 179 |
| |
167 | 180 |
| |
168 | 181 |
| |
| |||
171 | 184 |
| |
172 | 185 |
| |
173 | 186 |
| |
174 |
| - | |
175 | 187 |
| |
176 | 188 |
| |
177 | 189 |
| |
178 |
| - | |
179 |
| - | |
180 |
| - | |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
185 |
| - | |
186 |
| - | |
187 | 190 |
| |
188 | 191 |
| |
189 | 192 |
| |
|
0 commit comments
Comments
(0)