On Fri, Apr 3, 2015 at 11:57 AM, Anthony Ferrara <ircmax...@gmail.com>
wrote:

> All,
>
> I spent a little bit of time today trying to debug an issue with 7
> that Drupal 8 was facing, specifically regarding an array index not
> behaving correctly ($array["key"] returned null, even though the key
> existed in the hash table).
>
> I noticed that the hash table implementation has gotten orders of
> magnitude more complex in recent times (since phpng was merged).
>
> Specifically, that ardata and arhash are now the same block of memory,
> and that we're now doing negative indexing into arData to get the hash
> map list. From Dmitry's commit message, it was done to keep the data
> that's accessed most often in the same CPU cache line. While I am sure
> that there are definitive performance gains to doing this, I do worry
> about the development and debugging costs of this added complexity.
>
> As well as the way it increases the busfactor of the project.
>
> There is definitely a tradeoff there, as the change is pretty well
> encapsulated behind macros. But that introduces a new level of
> abstraction. But deeper than that it really makes debugging with gdb a
> pain in the neck.
>
> Without hard data on this particular patch, I'm not suggesting we roll
> back the change or anything. I more just want to express concern with
> the trend lately to increase complexity significantly on developers
> for the sake of performance.
>
> While I'm definitely not saying performance doesn't matter, I also
> think performance at all costs is dangerous. And I wonder if some of
> the more fundamental (even if isolated) changes such as this should be
> way more documented and include the performance justification for
> them. I'm definitely not suggesting an RFC, but perhaps some level of
> discussion should be required for these sorts of changes...
>
> Thoughts?


I think it is generally true that increased performance often requires more
sophisticated approaches.
Generally speaking I've observed that the faster, more modern runtime
engines all need to deal with that additional sophistication.
JIT runtime engines typically are the worst because they deal with hundreds
of micro-optimizations around code generation (register allocation, cache
line optimization, etc...).
So what you have in PHP 7 today is actually not "that" bad compared to some
of the other runtimes (IMO).
I think it can be partially addressed in a combination of documenting key
datastructures (some of which was already written) and maybe some
additional comments in areas of code where the complexity level goes up for
some very specific "tricks".

You can see by the level of interest in performance (whether ones opinion
is that this is fully warranted or not) around PHP 7, HHVM and other
languages, that this is an area we need to invest in on an ongoing basis.
And sophistication will likely go up.

Andi

Reply via email to