Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92050 invoked from network); 27 Jun 2014 12:55:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2014 12:55:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=ingwie2000@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ingwie2000@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 74.125.82.177 as permitted sender) X-PHP-List-Original-Sender: ingwie2000@googlemail.com X-Host-Fingerprint: 74.125.82.177 mail-we0-f177.google.com Received: from [74.125.82.177] ([74.125.82.177:47537] helo=mail-we0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/4A-11209-4C96DA35 for ; Fri, 27 Jun 2014 08:55:32 -0400 Received: by mail-we0-f177.google.com with SMTP id u56so5076882wes.36 for ; Fri, 27 Jun 2014 05:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=WurHEbBbiQEec/2ZRI/PcG+0WLwq/DZw5B6rD03DlYo=; b=QcNb2wdeECI/vqigBRm6nvDRZPZe10LrLPhQGNj1lXlNO1G58YT2f3E7wOXJW+5NCL FUXJTQGlIKbsUjbjDLYZFUcWg6fGnYGB1O1hlLzRw6ryltJc/RYl+l6TbG4DH7wwB7Fc CRDB7YhacMcIXq9s4xlNDWLLPuQsT1nGzElm9Vq2ZP2T2+i63scwOcUMPjbsTRMtjsLA 4QxyhMu7deHyM50IYAYeW4ZTIAxhW0X1ULpKLPm69/QV+LHHfQ15vV5Vg9ktefpJxcxG ByP0xK8vICqdhx+10sZU/TtADwWgRGwPrmh9xE07N8Tl0t7Pw6BecCmTiISsEBQd1xvJ UVFQ== X-Received: by 10.194.84.101 with SMTP id x5mr25738505wjy.52.1403873729574; Fri, 27 Jun 2014 05:55:29 -0700 (PDT) Received: from juergenensimac6.speedport_w723_v_typ_a_1_01_001 (p5B1500CB.dip0.t-ipconnect.de. [91.21.0.203]) by mx.google.com with ESMTPSA id 10sm9545275wjx.26.2014.06.27.05.55.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Jun 2014 05:55:28 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.2\)) In-Reply-To: <1403860716.12695.34.camel@guybrush> Date: Fri, 27 Jun 2014 14:55:22 +0200 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <02B340AD-6EED-497D-85EC-F5C37A7504B6@googlemail.com> References: <1403777679.12695.14.camel@guybrush> <0DF815F8-5991-46EC-9BD4-53575F774BAC@googlemail.com> <1403860716.12695.34.camel@guybrush> To: =?windows-1252?Q?Johannes_Schl=FCter?= X-Mailer: Apple Mail (2.1878.2) Subject: Re: [PHP-DEV] Embedding PHP, few additional questions. From: ingwie2000@googlemail.com (Ingwie Phoenix) Am 27.06.2014 um 11:18 schrieb Johannes Schl=FCter = : > On Fri, 2014-06-27 at 07:57 +0200, Ingwie Phoenix wrote: >> I also did some research, and learned that OPCaches are stored in >> shared memory. Wouldn=92t shared memory get lost when the interpreter = is >> shut down, or how is this working? Is shared memory actually =84fully >> associated=93 to a program? Excuse me for the dumb question, It is = just >> my first direct confrontation with shared memory, ever. >=20 > In general "shared memory" might mean many things. In this opcache = case > you can assume that when PHP is shutdown (not only the request) the > shared memory is freed. Ohh. So the interpreter needs to stay =84online=93 in order to also keep = the cache up. Thanks, that made things clearer for me. :) >> In your pconn SAPI, you are telling PHP that you are not going to use >> headers=85 but, in my case, I have an incomming HTTP request and = should >> very much forward those headers. What is the function that I must = look >> at, to copy my headers? >=20 > php-src/sapi/ has quite a few examples and php-src/main/SAPI.c and > related files show implementation of details. If you're referring to = the > no_headers flag this is about setting headers from PHP which would > otherwise be sent to the SAPI's header hooks =85 So there is two methods of supplying headers? O.o oha. Well I will go = and check the files out and see what it helps me. >=20 >> As this is going to be a nodejs module (v8php), I will link most of >> these functions into JS scope by supplying wrappers and the like. >> Going to be pretty interesting to see this in actual work, and >> comparign the speed to just using child_process.spawn. >=20 > It will be worse - without really looking into child_process.spawn I > assume that is non-blocking. I assume you're PHP implementation will = be > blocking and therefore hold all other things in nodejs. For making it > non-blocking you'd have to play a bit with threads and send PHP of to > worker threads and ensure it's compiled in TSRM mode which costs extra > time while executing. The better approach would be to use FastCGI / = FPM > as communication with PHP. While I'd question the architecture of such > an system ... >=20 > johannes Yes. child_process.spawn is non-blocking - it just returns an Event = Emitter and the stdin/stdout/stderr stream resources respectively. In = fact, I want to model my PHP binding in such fashion too. Currently, I = am firstly wanting to understand the API and create a good base for the = module. Then extend it to be async/non-blocking. So, I will be replacing = output and error output functions with respective callbacks. However, I = am not planning to add any functionality to create userland functions = from JS. I only want to be able to prepare a bunch of information - the = file to be executed, the in-/output methods, etc - then give it to a = function, which will create a new thread (in libuv, uv_async_t, or = soemthing) and execute the given PHP file with the engine. The handle = returned will contain the running PHP instance - or at least, i need to = find a way to run PHP and then keep it up, so that my OPCaches wouldnt = get lost. But this brings me to another question. When I look into pconnect SAPI, I can see that you start PHP=85but = actually, I can see no real reference to a =84PHP interpreter object=93. = In a third-party implementation of PHP, called PH7, one has to create a = ph7_engine_t first - which corresponds to the actual engine instance. If I want to keep PHP running - and even multiple instances - how would = I do that? If I have no handle to differenciate between PHP instances, = then I have a small problem=85and I would have to actually fall back to = using PHP-CGI/-FPM, which I wanted to avoid, as I was hoping for a speed = improvement if everything happened in-process/per thread. Kind regards, Ingwie.=