Commit 0be5bb0
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.
This patch introduces a local function `zend_obj_prop_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 c919ab4 commit 0be5bb0
2 files changed
+57
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
472 | 475 | | |
473 | 476 | | |
474 | 477 | | |
| |||
| 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 | + | |
257 | 272 | | |
258 | 273 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | 274 | | |
263 | 275 | | |
264 | 276 | | |
265 | 277 | | |
| 278 | + | |
266 | 279 | | |
267 | 280 | | |
268 | | - | |
| 281 | + | |
269 | 282 | | |
270 | 283 | | |
271 | 284 | | |
272 | | - | |
| 285 | + | |
273 | 286 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | 287 | | |
278 | 288 | | |
279 | 289 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 290 | + | |
| 291 | + | |
285 | 292 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 293 | + | |
| 294 | + | |
290 | 295 | | |
291 | | - | |
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
| |||
307 | 311 | | |
308 | 312 | | |
309 | 313 | | |
310 | | - | |
311 | | - | |
| 314 | + | |
312 | 315 | | |
313 | 316 | | |
314 | | - | |
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
321 | | - | |
322 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
323 | 326 | | |
324 | 327 | | |
325 | 328 | | |
326 | | - | |
327 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
331 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
332 | 338 | | |
333 | 339 | | |
334 | 340 | | |
| |||
358 | 364 | | |
359 | 365 | | |
360 | 366 | | |
361 | | - | |
| 367 | + | |
362 | 368 | | |
363 | 369 | | |
364 | 370 | | |
| |||
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
376 | | - | |
377 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
378 | 385 | | |
379 | 386 | | |
380 | 387 | | |
381 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
382 | 391 | | |
383 | 392 | | |
384 | | - | |
385 | | - | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
386 | 398 | | |
387 | 399 | | |
388 | | - | |
389 | | - | |
390 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
391 | 403 | | |
392 | 404 | | |
| 405 | + | |
| 406 | + | |
393 | 407 | | |
394 | | - | |
395 | | - | |
| 408 | + | |
396 | 409 | | |
397 | | - | |
398 | | - | |
| 410 | + | |
399 | 411 | | |
400 | 412 | | |
401 | 413 | | |
| |||
0 commit comments