Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use code generation to further accelerate simple persistence operations #116

Merged
merged 18 commits into from
Sep 28, 2011

Conversation

fzaninotto
Copy link
Member

By leveraging code generation to replace runtime introspection, this patch boosts simple persistence operations:

  • insertions are 300% faster (replacing BasePeer::doInsert())
  • simple PK searchs are 200% faster (replacing ModelCriteria::findOne() and PropelObjectFormatter::formatOne())

The patch is backwards compatible with the current code. In particular, it doesn't use buildtime generation when it's not possible:

  • MSSQL uses some VERY exotic bindings at runtime, so PK search boost isn't enabled on this platform

The same idea can be applied to more operations (update, delete, deleteAll), but the "turbo" branch should be merged before it's too big ;)

As usual, comments are welcome.

…bindings.

This is necessary to let Oracle, for instance, use bindParam() instead of bindValue() for CLOBs.
…k() to allow preSelect() hook to be called just like the other model hooks.

This refactoring allows the turbo behavior to accelerate findPk() on every model, even those using a preSelect() hook.
It also harmonizes the AR and Query apis: just like ActiveRecord::save() calls doInsert() or doUpdate(), ActiveQuery::find() calls doSelect(), and ActiveQuery::count() calls doCount().
This is to accomodate cases where PK columns have special bindings (like timestamps... ot blobs, who knows).
I took advantage of this to refactor the custom binding code in the adapters.
The behavior now only accelerates doInsert() (until we find a way to marge this into the core, too).
And now that there is nothing in the turbo behavior, it is removed.
doInsert() acceleration is disabled on Mssql platforms, due to very exotic bindings in adapter classes
Passing the script by reference is a bad habit, but not doing so for only a few methods is confusing. In the future, if a refactoring of the builders occurs, let us not reproduce that mistake
@willdurand
Copy link
Contributor

Awesome !

[william@MBP:~/projects/php-orm-benchmark-read-only]
% php TestRunner.php
                               | Insert | findPk | complex| hydrate|  with  |
                               |--------|--------|--------|--------|--------|
                  PDOTestSuite |    132 |    125 |     96 |    123 |    108 |
             Propel14TestSuite |   1973 |    720 |    158 |    453 |    454 |
             Propel15TestSuite |   1820 |    854 |    221 |    583 |    670 |
             Propel16TestSuite |    570 |    259 |    223 |    604 |    687 |
           Doctrine12TestSuite |   3269 |   5176 |    840 |   3283 |   3185 |
  Doctrine12WithCacheTestSuite |   3540 |   2404 |    857 |   1802 |   1322 |
            Doctrine2TestSuite |    257 |    845 |    267 |   1142 |    615 |

(MBP 2,4GHz - 4GO RAM - HDD)

Propel 1.6 without this improvement:

Propel16TestSuite |   1836 |    924 |    227 |    610 |    690 |

And with it:

Propel16TestSuite |    570 |    259 |    223 |    604 |    687 |

willdurand added a commit that referenced this pull request Sep 28, 2011
Use code generation to further accelerate simple persistence operations
@willdurand willdurand merged commit 8d27ac8 into propelorm:master Sep 28, 2011
willdurand pushed a commit that referenced this pull request Sep 9, 2013
willdurand added a commit that referenced this pull request Sep 9, 2013
Fixes #116 - remove type + un-necessary code
richmulhern pushed a commit to AriaSystems/Propel that referenced this pull request Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants