Premature Optimization with Ilia Alshanetsky @ Dutch PHP Conference | Notes
-> demonstrate the user concept with an imperfect solution that does the job, optimize along the way
-> tune the right portions of the application, not over-engineer from the very beginning
—> scale the scope to the nature of the problem
-> simplify
—> less code does not mean that it’s faster
—> PHP doubled the # of LOC in a few years but it’s faster, not slower
-> hardware [HW]
—> since it’s cheaper, maybe throwing HW at it this might get it faster & buy you time to find the solution to the problem
—> SW development time to optimize might be more expensive
—> CPU bottlenecks & RAM issues are easier to solve lately
—> drives, the well-known bottleneck, have also received SSD [measurements show it's a lot better]
-> HW caveat
—> might only temporarily solve issues
—> DB saturation
—> non-scalable code [this is NOT the same as high-performing code]
—> network bottlenecks [latency]
—> extremely low # of sessions per server [Smarty: 50 reqs/sec]
-> optimization
—> start by trying to make the code faster without modifying a LOC [this way you avoid introducing new bugs & QA cycle, easier deployment]
-> how PHP works in 30 secs
—> each require/include triggers compile+execute
—> compilation is expensive
—> opcode cache [if the file is not changed, you get it from the cache]
—> APC vs Zend’s solution vs X-Cache
-> in-memory cache
—> do the PHP sessions in memcache instead of filesystem
-> ways of caching data
—> complete page [caching proxy, e.g. Squid; pre-generate; on-demand]
—> cache the parts that are really slowing down the page [example using memcache for SQL results caching]
—> partial caching of code [example using memcache for results of a function call; cache TTL of 1h]
-> output buffering
—> Apache’s SendBufferSize should be the same as PageSize
—> tcp_wmem | affects everything on tcp-ip
—> tcp_mem |
-> use profiling to understand the real bottleneck in the code, without the “educated assumptions”
—> Xdebug & XHProf [last one comes from Facebook]
—> Kcachegrind
-> code that generates notices / errors is slowed down by them, because resources are allocated for them, even if you don’t see them

Recent Comments