Commit 6816285
committed
Improve performance of instantiating exceptions/errors
The class structure is fixed, so it makes no sense to go through all the
logic of looking up property info etc if there are no hooks.
This patch introduces a local function `zend_update_property_num_checked()` to
help with that.
For this benchmark:
```php
for ($i = 0; $i < 1000000; $i++)
new Error;
```
On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 141.6 ms ± 9.3 ms [User: 138.7 ms, System: 2.0 ms]
Range (min … max): 135.4 ms … 177.7 ms 20 runs
Benchmark 2: ../RELx64_old/sapi/cli/php x.php
Time (mean ± σ): 214.1 ms ± 7.0 ms [User: 207.6 ms, System: 5.0 ms]
Range (min … max): 206.6 ms … 230.9 ms 13 runs
Summary
./sapi/cli/php x.php ran
1.51 ± 0.11 times faster than ../RELx64_old/sapi/cli/php x.php
```
For this benchmark:
```php
for ($i = 0; $i < 1000000; $i++)
new Exception("message", 0, null);
```
On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 184.3 ms ± 9.5 ms [User: 181.2 ms, System: 1.8 ms]
Range (min … max): 173.8 ms … 205.1 ms 15 runs
Benchmark 2: ../RELx64_old/sapi/cli/php x.php
Time (mean ± σ): 253.7 ms ± 7.0 ms [User: 247.6 ms, System: 4.6 ms]
Range (min … max): 245.7 ms … 263.7 ms 11 runs
Summary
./sapi/cli/php x.php ran
1.38 ± 0.08 times faster than ../RELx64_old/sapi/cli/php x.php
```
For this benchmark:
```php
for ($i = 0; $i < 1000000; $i++)
new ErrorException("message", 0, 0, "xyz", 0, null);
```
On an i7-4790:
```
Benchmark 1: ./sapi/cli/php x.php
Time (mean ± σ): 223.6 ms ± 7.7 ms [User: 220.1 ms, System: 2.4 ms]
Range (min … max): 216.9 ms … 242.5 ms 12 runs
Benchmark 2: ../RELx64_old/sapi/cli/php x.php
Time (mean ± σ): 343.5 ms ± 8.1 ms [User: 337.1 ms, System: 4.6 ms]
Range (min … max): 337.3 ms … 362.8 ms 10 runs
Summary
./sapi/cli/php x.php ran
1.54 ± 0.06 times faster than ../RELx64_old/sapi/cli/php x.php
```1 parent 00f0175 commit 6816285
2 files changed
+44
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
515 | 516 | | |
516 | 517 | | |
517 | 518 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
257 | 280 | | |
258 | 281 | | |
259 | 282 | | |
260 | 283 | | |
261 | | - | |
262 | 284 | | |
263 | 285 | | |
264 | 286 | | |
| |||
269 | 291 | | |
270 | 292 | | |
271 | 293 | | |
272 | | - | |
| 294 | + | |
273 | 295 | | |
274 | | - | |
275 | 296 | | |
276 | | - | |
| 297 | + | |
277 | 298 | | |
278 | 299 | | |
279 | 300 | | |
280 | 301 | | |
281 | | - | |
282 | | - | |
| 302 | + | |
283 | 303 | | |
284 | | - | |
| 304 | + | |
285 | 305 | | |
286 | | - | |
287 | | - | |
| 306 | + | |
| 307 | + | |
288 | 308 | | |
289 | | - | |
| 309 | + | |
290 | 310 | | |
291 | | - | |
292 | 311 | | |
293 | 312 | | |
294 | 313 | | |
| |||
308 | 327 | | |
309 | 328 | | |
310 | 329 | | |
311 | | - | |
312 | 330 | | |
313 | 331 | | |
314 | | - | |
315 | 332 | | |
316 | 333 | | |
317 | 334 | | |
318 | 335 | | |
319 | 336 | | |
320 | 337 | | |
321 | | - | |
322 | | - | |
| 338 | + | |
| 339 | + | |
323 | 340 | | |
324 | 341 | | |
325 | 342 | | |
326 | 343 | | |
327 | | - | |
| 344 | + | |
328 | 345 | | |
329 | 346 | | |
330 | 347 | | |
331 | | - | |
| 348 | + | |
| 349 | + | |
332 | 350 | | |
333 | 351 | | |
334 | 352 | | |
| |||
368 | 386 | | |
369 | 387 | | |
370 | 388 | | |
371 | | - | |
372 | | - | |
| 389 | + | |
373 | 390 | | |
374 | 391 | | |
375 | 392 | | |
376 | 393 | | |
377 | | - | |
| 394 | + | |
378 | 395 | | |
379 | 396 | | |
380 | 397 | | |
381 | | - | |
| 398 | + | |
| 399 | + | |
382 | 400 | | |
383 | 401 | | |
384 | 402 | | |
385 | | - | |
| 403 | + | |
386 | 404 | | |
387 | 405 | | |
388 | 406 | | |
389 | | - | |
390 | | - | |
| 407 | + | |
391 | 408 | | |
392 | 409 | | |
393 | 410 | | |
394 | 411 | | |
395 | | - | |
| 412 | + | |
396 | 413 | | |
397 | 414 | | |
398 | | - | |
| 415 | + | |
399 | 416 | | |
400 | 417 | | |
401 | 418 | | |
| |||
0 commit comments