TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Kohana 3 performance
  • I think one of the best arguments by using the newer version of a framework is performance.

    I have benchmarked Kohana 3 yesterday and I have found a few interesting things.

    When I tested a simple ‘hello world’ KO3 was 2 times faster than KO2.

    KO3 60 rps
    KO2 30 rps

    After I did a very simple sql select and KO3 lost about 75% of its performance while KO2 performance was near the same. Here is performance in numbers:

    KO3 15 rps
    KO2 28 rps

    What caused this huge performance loss? The new DB driver or something else?
  • that's almost impossible that the rps drops /4 by just adding a simple select statement... Is there nothing else changed between the first and second test?
  • I tested it several times of course, and I also think this is near impossible. I ran the tests on localhost with apache benchmark.

    Did you test it?
  • I think the K02 performance being virtually the same in both tests is more suspect than the K03 performance dropping by 3/4.
    To me it's understandable that a trip to the DB would take some time, though perhaps not that much.
  • I think one of the best arguments by using the newer version of a framework is performance.

    Then you would be generally wrong. Performance is extremely hard to test (what extensions did you have enabled? localhost database, or remote? etc etc) and the framework is almost never to blame for slow websites... typically it is the database that becomes the bottleneck in a high-traffic site. I know Yii Framework is convinced that "hello, world" performance tests are a selling point, but I couldn't disagree more.

  • The DB classes' implement structures look ridiculous to some extends.
    DB::select() --> new Database_Query_Builder_Select

    abstract class Database_Query_Builder_Select
    extends Kohana_Database_Query_Builder_Select
    extends Database_Query_Builder_Where
    extends Kohana_Database_Query_Builder_Where
    extends Database_Query_Builder
    extends Kohana_Database_Query_Builder
    extends Database_Query
    extends Kohana_Database_Query{}

    I never see such kind of complicating code before. There're so many files have to load for one query. Yes, caching system shell work. But I have no idea it does well as just loading one file.
  • Merge them all in the index.php, so only one file is loaded per request. :)
  • @dyron are you serious? you can look at the code. there half of them are empty classes (no methods or vars, sorry my poor English). I think their are just extra burden.
  • @Shadowhand

    Why do you talk about Yii, I have never talked about it.

    At this time I use Kohana 2.3.4 and I really like it. Maybe the best framework that I ever seen. My question is simple that you see and nothing more. I don’t want to generate a flame.
  • @Subi, I think the only reason Yii comes up is because they champion themselves as the fastest framework based on running a hello world test similar to above. It's fairly obvious that a hello world test is not worth a lot in terms of comparison of frameworks.
    I don't believe that's what this is though. You were just using 'hello world' to illustrate the decline in performance between a test that does nothing and a test that instantiates the db and makes a query. You were suggesting that 2.x does not suffer from the same decline in performance when using the db.

    @shadowhand I don't believe this to be a worthless exercise. If there's some inherent lag in using the db class in K03 it needs to be brought to light. More people investigating the issue can help decide it's a real a real issue at all and if it is, what can be done about it.
  • @Yahasana: it allows you to transparently extend the Kohana classes, without Kohana::auto_load() having to use eval().

  • I have an idea: I ran the tests on localhost (Windows + Apache), and the DB library uses a lot of files, and Windows file handling is really slow… Maybe it’s not a real problem on a Linux server.
  • Yes, the class hierarchy is pretty ridiculous when you first see it, but it provides flexibility that you won't find in any other framework. Using eAccellerator or APC will make a huge reduction in overhead, for both UNIX and Windows.

  • You should also turn profiling off, that was found to be a pretty big bottlekneck in K2.
  • It's also worth pointing out the reason your "hello world" test is so much faster in Kohana 3 is because Kohana 3 doesn't do any automatic xss filtering or utf8 conversions. Once you remove these things from the benchmark both versions have more or less the same startup overhead.
  • @Geert, I know this amazing feature offered by Kohana, I love it. I must say that I would like to let my class extend Kohana_ClassName but not the one ClassName, which is nothing. It's good to append my code to ClassName, but I can't. This file is maintained by the devs core team, I don't want to touch it. And do you (developers) really append some functions to ClassName but not Kohana_ClassName in some days? I hope all the classes that serve like an align will be got rid of thoroughly. No more reduction.
  • You don't need to touch it, just create a file called classname.php in your application/classes folder and Kohana will use that one instead.

  • The cascading filesystem is all explained in the user guide (both v2 and v3).

  • Posted By: Shadowhand

    Yes, the class hierarchy is pretty ridiculous when you first see it, but it provides flexibility that you won't find in any other framework. Using eAccellerator or APC will make a huge reduction in overhead, for both UNIX and Windows.

    Any preference? APC? eAccellerator? xCache?

    APC will be included in PHP6, xCache seems to come with some sort of admin page, and has atomic INC/DECR functions..

    Any (Kohana-related) reasons why I should prefer one above the others?!
  • APC does proper caching of commenting, and eAccelerator doesn't.. which only means that the user guide module will not work with eAccelerator. Other than that, I find them to be basically the same. No experience with xCache.

  • I have tested it on Linux server with xcache. In this situation the performance loss isn’t critical. Here is the result:

    ab –n1000 –c100


    hello 426 - 432 rps
    simple query 426 - 432 rps


    hello 487 - 497 rps
    simple query 325 - 367 rps
  • That sounds about right. Are you using the query builder, or direct queries?

    The query builder will certainly be slower in v3.0, but the functionality it provides makes it worth it; namely separate object spaces for each query ensures that no queries will ever "cross pollinate".

  • I used simple query. I see the KO2 and KO3 performance near the same.

    What is the main benefit(s) of KO3?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion