Yii Framework Forum: Memory overhead and C module optimizations - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Memory overhead and C module optimizations

#1 User is offline   mindplay 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 397
  • Joined: 03-September 09
  • Location:New York

Posted 21 May 2012 - 09:21 AM

I came across this little benchmark/comparison of some frameworks - it includes Yii:

http://phalconphp.co...ation/benchmark

Yii scores amazingly well in all of those benchmarks!

Except for the last one: memory usage of the framework, where Yii scores worse than any other framework. I wonder why the memory use is so high compared to other frameworks? 3.5 MB compared to e.g. Fuel at 1 MB, is a pretty substantial difference. Is any consideration being given to lowering the memory-footprint of Yii 2.0?

Note that one aspect of this benchmark you can safely ignore, is "framework time per request" - Yii is as fast as the fastest PHP frameworks, and yes, Phalcon is faster, but instead of being taken and impressed by the blue bars, pay attention to the actual numbers: Yii at 1.311 and Phalcon at 0.385.

In my opinion, all this proves, is that maintaining a C codebase is not worth the effort - with less than one millisecond saved per request, there is only a very few, very marginal applications where this would actually matter. Basically, in any application that uses a relational database, one millisecond won't matter at all, because the bottleneck is the database, and the 1 millisecond of overhead per request is insignificant compared to even a single database PK query and roundtrip.

I can't see how this type of optimization delivers any significant value, but what it does deliver, is a codebase that is far less accessible to those trying to understand the inner workings of the framework, setting a high barrier for potential framework-contributors, effectively putting a cap on contributions.

For 99% of applications, this optimization won't matter at all. If I did have to write an application where request overhead was this critical, I would not write that component of the application in PHP in the first-place. I hope Yii does not take that course.
1

#2 User is offline   binkabir 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 194
  • Joined: 25-July 10
  • Location:Abuja,Nigeria

Posted 21 May 2012 - 10:27 AM

i agree 100% with your opinion.
speed is not the ultimate criteria for picking up a framework and average/optimally Yii sound great when it comes to full analysis for a framework.
0

#3 User is offline   mindplay 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 397
  • Joined: 03-September 09
  • Location:New York

Posted 21 May 2012 - 05:23 PM

For the record, I just had a discussion with folks on the internals php mailing-list, where I argued for an optimization, preventing duplicate storage of the property-names.

It turns out, in php 5.4, this was actually implemented!

Memory overhead in a little benchmark/test-script I posted was one third in 5.4, compared to 5.3. Fantastic!

So basically, starting with 5.4, if you don't use dynamic properties, php does not maintain a property-hash for the object.

That means you no longer have to compromise on legible property-names ($_m, $_p) in heavily-used classes.

Very nice :-)
3

#4 User is offline   fleuryc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 09-November 11

Posted 03 May 2013 - 04:34 AM

Hi!

Very interresting point. How about these numbers :
* Yii :

Quote

Requests per second: 961.28 [#/sec] (mean)
Time per request: 10.403 [ms] (mean)
Time per request: 1.040 [ms] (mean, across all concurrent requests)
Transfer rate: 238.44 [Kbytes/sec] received

* Phalcon :

Quote

Requests per second: 2535.82 [#/sec] (mean)
Time per request: 3.943 [ms] (mean)
Time per request: 0.394 [ms] (mean, across all concurrent requests)
Transfer rate: 517.56 [Kbytes/sec] received


Wich suggests that Phalcon is almost 3 times faster than Yii...

So if indeed the gain in memory overhead is not huge, the gain in speed definitively is.

The framework seems perfectly extensible with modules and extensions, exactly as Yii, event if those extensions will not be directly integrated into the C module (or will they : https://github.com/phalcon/incubator). So of course any extension will create processing overhead, but no more than in any other "usual" framework (like Yii).

In Yii, we have a "compiled" version : Yiilite. They went the extra mile and compiled their framework into a php module... This does'nt seem totally wrong to me, but I might be mistaking...

Cheers!
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,782
  • Joined: 17-January 09
  • Location:Russia

Posted 03 May 2013 - 04:58 AM

2.0 eats less memory and is faster. Can't say it's as significant as rewriting everything as PECL though.

At one of latest Moscow conferences a guy from mtt.ru ISP told me that they're considering implementing a PECL for 1.1 and I think they'll opensource it in this case. We can do it as well but since it will take significant time we prefer focusing on the framework itself.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#6 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 03 May 2013 - 06:07 AM

I hope that this is the case also without APC enabled.

There already is a huge difference between with or without APC.

A Yii C module would only make the difference between people who are able to configure their server (and install APC and PECL's) even bigger.

Yii should, IMO, be the fastest framework out of the box - without anything extraneous. :)
"Less noise - more signal"
1

#7 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,782
  • Joined: 17-January 09
  • Location:Russia

Posted 03 May 2013 - 07:29 AM

Yes, it's the case w/ and w/o APC. Still I do not recommend using PHP w/o APC since execution time and memory usage is significantly worse.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#8 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 03 May 2013 - 07:42 AM

If only I could afford a VPS, then APC would be the first thing to install.

But it sounds great. I am really looking forward to digging into Yii 2. :)
"Less noise - more signal"
0

#9 User is offline   fleuryc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 09-November 11

Posted 03 May 2013 - 07:47 AM

Yep, so am I!!

Anyway, Yii rules and Yii2 will definitively rock.

Yii is just perfect to me, but I found Phalcon's approach very interresting, and wondered why no (or few) other framework did the same...
0

#10 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,782
  • Joined: 17-January 09
  • Location:Russia

Posted 03 May 2013 - 09:34 AM

fleuryc
That's about maintainability of the framework itself. If it's PECL, you don't know C and PHP internals, framework devs are busy and you've got a core framework error then you're in trouble. In case with Yii you can fix it yourself.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#11 User is offline   fleuryc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 09-November 11

Posted 03 May 2013 - 09:44 AM

Yeah, that's exactly why I'm so glad I work with PHP and open source technologies.

A teammate is using ASP, this archaic monstruosity, and I can bearly understand that he is using DLLs (the .Net framework) without even knowing what's inside them. He actually can't know!

I pity the fool...
0

#12 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,782
  • Joined: 17-January 09
  • Location:Russia

Posted 03 May 2013 - 10:05 AM

Well, .net is opensourced.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#13 User is offline   xicond 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 06-October 12

Posted 05 May 2013 - 11:48 PM

View Postsamdark, on 03 May 2013 - 04:58 AM, said:

2.0 eats less memory and is faster. Can't say it's as significant as rewriting everything as PECL though.

At one of latest Moscow conferences a guy from mtt.ru ISP told me that they're considering implementing a PECL for 1.1 and I think they'll opensource it in this case. We can do it as well but since it will take significant time we prefer focusing on the framework itself.



woah, I like good benchmark, but don't want to depend on pecl, better rewrite standalone pecl
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users