Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103927 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24109 invoked from network); 31 Jan 2019 19:21:41 -0000 Received: from unknown (HELO mail-io1-f50.google.com) (209.85.166.50) by pb1.pair.com with SMTP; 31 Jan 2019 19:21:41 -0000 Received: by mail-io1-f50.google.com with SMTP id s22so3034493ioc.8 for ; Thu, 31 Jan 2019 08:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ehvcdnETjUrWwduTn4f18P2x3dzSAFkZGcSayIT/4ew=; b=sJwp2TWtZmfjU83fx4ncyN+QKOH7+ZCI8Enq5r+v/VjRpD9ngX7txdOZDBhnTScMFC 29v0j+SFSelT/MtFfZhHCi4GQ1DOavigHrorX6SJ7rkd6Mm4A8dEYxaxc9kdEVxCAQQv tcRupf8zmB0gbQ+lz+thD8M9gAsKoiVr6/g8nPixpHj6tM+WJQIDAHmmQ0P0gDdkd3Qd sklyhB3rADs+2rt47dsncYOhPjpVm2xOEQTkIApsY+FSQLhKqckF1iD6s25cGKoOuRn7 Z/9aianfauOWd8krW23xf/ho/bnS+hTzho+9o2M+DLCymZJb2SpnjLiVjHJoBK2zwKWA 1BWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ehvcdnETjUrWwduTn4f18P2x3dzSAFkZGcSayIT/4ew=; b=gl2hpb4SYPZfLP1fuaV/4mpQCWiBKN32Qge3ROjx55ScA7RX0hO5rW5QZNQ5lCsZ/n AguTmRX5bACFpNnaQtoE+ImmLZ/ZoiGF7u1naP4Xlzvj+y97WAslvUHlFjEeaDQ60Bp/ AUDUfQhSwOn9QL3s2bTbzcSRQ0USxKF/pb/pQ5qc9vt3WuitzkKYhnUIMhJ1L1H2J6x8 ZdBUDzlsto8U/bVgxcyhIv3u0Ficxb5AwdNrQdooINxWOi6p39sSeAtR49AWop2VGtmk luSDSptSafIASLGRkc5zs1LXxNNpRYbz/seNNkJExDOjRrt8BPUsN+cdf3qZzGCRQ6eq k3aQ== X-Gm-Message-State: AHQUAuaHqTdnhJNnJ30Elfn034UncYpWM1PtjQwNgqj7P/k4DJl1Mbj3 mk3n0HGGXb9svQyChIDAGS8etjruDYdYOTGcefU= X-Google-Smtp-Source: AHgI3IbbA7Tcg5V+tmGlrztTl90BDVpUspABSyhC76XHVuXSLzRhSg6ctfc+a9NRL1Xa0sA3fSgbbZg6/Z0ztAst3dM= X-Received: by 2002:a6b:5804:: with SMTP id m4mr20040777iob.47.1548950495622; Thu, 31 Jan 2019 08:01:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 31 Jan 2019 17:01:18 +0100 Message-ID: To: Dmitry Stogov Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000010fd8a0580c3246e" Subject: Re: [PHP-DEV] [RFC] JIT From: nikita.ppv@gmail.com (Nikita Popov) --00000000000010fd8a0580c3246e Content-Type: text/plain; charset="UTF-8" On Thu, Jan 31, 2019 at 10:44 AM Dmitry Stogov wrote: > Hi Internals, > > > I'm glad to finally propose including JIT into PHP. > > > https://wiki.php.net/rfc/jit > > > In the current state it may be included both into PHP-8, where we are > going to continue active improvement, and into PHP-7.4, as an experimental > feature. > > > Thanks. Dmitry. > This has been a long time on the horizon, nice to see this finally moving forward :) Here are some initial thoughts: I think that it's best to approach this issue from a cost/benefit angle. The benefits of the JIT compiler are roughly (and as already outlined in the RFC): * Significantly better performance for numerical code. * Slightly better performance for "typical" PHP web application code. * The potential to move more code from C to PHP, because PHP will now be sufficiently fast. However, there are also a number of costs, on which I'll expand in more detail: a) Maintenance: This is really my main concern. Right now there are about 3-4 people who I would trust to carry out a non-trivial language change, which will require touching the compiler, the virtual machine, the optimizer and the persistence layer. Each of those components is quite complex, in different ways. Some people who are comfortable with doing VM changes will struggle with implementing optimizer changes. Adding a JIT compiler exacerbates this issue further. Because this JIT is dynasm based, the core JIT code is essentially written in raw x86 assembly. This will further limit the pool of people who will be able to make non-trivial engine changes. Personally, I don't have any particular familiarity with writing x86 assembly, so it will likely take a while to get up to speed with this code. b) Bugs and stability: I think that everyone is aware that the initial PHP 7.3 release suffered from substantial stability issues, more than new minor version releases tend to do. I think there are multiple reasons for that (and we might want to start a conversation about our QA processes in a separate thread), but one main contributing factor were opcache optimizer bugs. Compiler optimizations are tricky and hard to verify, and we often only learn about issues once the optimizer makes contact with production codebases, which feature a much richer collection of code patterns than our test suite. One can wonder whether the relatively minor speedups we get from our optimization framework are really worth having these stability issues... Adding a JIT compiler adds a new dimension of stability issues. Next to "simple" executor bugs, and optimizer bugs, we now get additional bugs in the JIT. These are probably going to be hard to debug, as we'll have to drop down from our usual C-level tooling, down to inspecting assembly. c) Platform support: Having a JIT segregates platforms into two tiers: Those that have JIT support and those that don't. While that is not a problem per se, it does introduce some dangers. For example, if we decide to more parts of our C code into PHP because PHP is fast enough with a JIT, that will of course only be true for platforms that actually have JIT support. I'm not terribly concerned about loosing out some performance on MIPS, but we do need to make sure that all our main platforms are supported (Windows is a must there, imho). d) Debugging: I'm not sure whether or not this is an issue (maybe the RFC can clarify?), but I'm wondering if this will have an impact on things like XDebug. Will it be possible to using XDebug to accurately inspect variables at any point in time while the JIT is running? If not, that would be a big tooling regression. I think those are the main points that come to mind right now... Regards, Nikita --00000000000010fd8a0580c3246e--