sergeyklay/php-orm-benchmark

$this->read(1) triggers identity map of Doctrine (and others?)

beberlei opened this issue · 2 comments

The read scenario always gets entity by id 1, which leads to triggering identity map, and these fast results compared to phalcon:

root@82c267f32816:/app# php run doctrine read 1000
Start Doctrine benchmarking...

Method:                           read
Call times:                       1000
Elapsed time:                     0.23 ms.
Memory usage:                     1.31 KiB.
Memory peak:                  2,318.59 KiB.

Total elapsed time:             245.17 ms.
Total memory usage:       2,028,436.57 KiB.
Total memory peak:            4,096.00 KiB.

root@82c267f32816:/app# php run phalcon read 1000
Start Phalcon benchmarking...

Method:                           read
Call times:                       1000
Elapsed time:                     0.76 ms.
Memory usage:                     0.07 KiB.
Memory peak:                    856.21 KiB.

Total elapsed time:             772.19 ms.
Total memory usage:         754,452.58 KiB.
Total memory peak:            2,048.00 KiB.

I would assume other ORMs also have identity maps, not mamking the query another time, which makes the read benchmarks not comparable.

It can't be changed to $i+1 though, because only id 1 has the fixture data with the comments available.

IN addition compared to my numbers, your seems way too extreme. Why kind of base system do you have for docker? I honestly wouldnt trust any numbers coming out of a docker dev environment.

root@3cef799d36ef:/app# ./run phalcon read 1000
Start Phalcon benchmarking without metadata caching...

Method:                           read
Call times:                       1000
Elapsed time:                     0.75 ms.
Memory usage:                     9.87 KiB.
Memory peak:                 10,568.09 KiB.

Total elapsed time:             854.38 ms.
Total memory usage:          10,787.45 KiB.
Total memory peak:           12,288.00 KiB.

root@3cef799d36ef:/app# ./run doctrine read 1000
Start Doctrine benchmarking without metadata caching...

Method:                           read
Call times:                       1000
Elapsed time:                     1.07 ms.
Memory usage:                     5.08 KiB.
Memory peak:                  5,780.91 KiB.

Total elapsed time:           1,186.56 ms.
Total memory usage:           5,887.44 KiB.
Total memory peak:            8,192.00 KiB.

Fixed in 5e79627. Thank you