Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85743 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81068 invoked from network); 8 Apr 2015 00:52:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2015 00:52:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=andi@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=andi@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.173 as permitted sender) X-PHP-List-Original-Sender: andi@zend.com X-Host-Fingerprint: 209.85.220.173 mail-qk0-f173.google.com Received: from [209.85.220.173] ([209.85.220.173:36815] helo=mail-qk0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/54-55418-4BB74255 for ; Tue, 07 Apr 2015 20:52:06 -0400 Received: by qku63 with SMTP id 63so66397434qku.3 for ; Tue, 07 Apr 2015 17:52:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=uex6miXNWyHamTMlJeZxZg0r/9gVw8nQjNKKNP48TzY=; b=Gih2z0/yH2HBNweS+YHbwMBO0XPiFQz3aqhJ3ODeOvV60IdSXXUPjeYp5z5l7qrTAQ wxwNNtnIcrJ3/I/2fJ0fYomfz962Xw0DxbBfccfniu1X/y+JeXE5tpD6lr6ul2VeFjcN jYp336+1q6O3OgwDPhdsSJOrirlWN1DABF+h4WnrF0RwzHUVKAOVehQ9GktgdeaZTjOy KJWsViExc9770kPy0sX0Vpo0fGHWnvpaOlJjJb8nczAWIzM0RckBd79dMyc9SeZ6EczD uYOaFSO8hf9zmD6gw1MmT6aOID5Q7hFEbBqaphCbMUVHFnPsFdAQ2BZWYDGdVS2VjFcx Tamw== X-Gm-Message-State: ALoCoQnw4yUcv9vlFp/x6iR/F6W/CoZxwkgxbJZdeO8AnhT7h2HtJP69YWuwumgMTFCw9kd0ESL0wODk9O4QAVvRF84qxQnZWndCM79yzZilLPyg+lSXpk5eXipS5oDr7XsZehe6+JhNFNbVTOHnljlrO1DiItgaag== MIME-Version: 1.0 X-Received: by 10.55.21.224 with SMTP id 93mr44875955qkv.89.1428454321832; Tue, 07 Apr 2015 17:52:01 -0700 (PDT) Received: by 10.140.91.40 with HTTP; Tue, 7 Apr 2015 17:52:01 -0700 (PDT) In-Reply-To: References: Date: Tue, 7 Apr 2015 17:52:01 -0700 Message-ID: To: Anthony Ferrara Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1147b1526e511105132bf0de Subject: Re: [PHP-DEV] Concern around growing complexity in engine - hash table specifically From: andi@zend.com (Andi Gutmans) --001a1147b1526e511105132bf0de Content-Type: text/plain; charset=UTF-8 On Fri, Apr 3, 2015 at 11:57 AM, Anthony Ferrara 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 --001a1147b1526e511105132bf0de--