Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74938 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79778 invoked from network); 17 Jun 2014 10:05:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2014 10:05:11 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.176 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.176 mail-vc0-f176.google.com Received: from [209.85.220.176] ([209.85.220.176:48407] helo=mail-vc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/E0-08302-2D210A35 for ; Tue, 17 Jun 2014 06:05:07 -0400 Received: by mail-vc0-f176.google.com with SMTP id ik5so6078478vcb.21 for ; Tue, 17 Jun 2014 03:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=5fY6MCtTbZJBuxuHORzNgaiHPlixvAXRk1OfVCTBN5I=; b=h2imKstSXwnKFIM7QWVonMyFpgAVPZpDzve2Aczs016x0906yL2FlVxilRq5N6JFqB TIX0o5xKrpdShf4lI1sEcv9kAPCGm5I44im0IjBTzhyasce4KUF2FHn7opFXqNQBEhls 9EN+CCNr7cMrIC8cKF4CGMhtxu5kNGIzF7xsPwTX6BuVTt5BdiCjUAZ2N+kLU1nEnu7Z 4UuxgQ1Ygjzi3f8zzv2hhQwXjtkgdl17D46H6Z3Or4QtR6yLinR/uqmPLkkgVekCISe8 xrCVth23MitWUNbuyZKAIswqkxBLwNLVGlqNqXWcvSumZA7DP62/EBPjkyBvRw1MLyeI A4Rg== X-Received: by 10.52.53.69 with SMTP id z5mr688610vdo.42.1402999503336; Tue, 17 Jun 2014 03:05:03 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.81.68 with HTTP; Tue, 17 Jun 2014 03:04:23 -0700 (PDT) Date: Tue, 17 Jun 2014 12:04:23 +0200 X-Google-Sender-Auth: nC0IMOURFbPaWOWkCRNxTkh5AK4 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Refactoring our IO multiplexing layer From: jpauli@php.net (Julien Pauli) Hey :-) I spent few hours analyzing PHP's IO multiplexing parts. IO multiplexing refers to calls to select() / poll() / epoll() or kqueue(). Simple notice : everything is sparse everywhere, we don't have an IOmux layer designed. I plan to write an RFC on the subject. The goal is to centralize IO mux calls in a layer to be used everywhere. My analyze leads to those points : - FPM has something, but not designed to be shared - User streams use hardcoded select() , with an ugly emulation for poll() - We have nothing about epoll() or kqueue(), except in FPM - curl_multi_select() uses hardcoded select() - php_cli_server uses hardcoded select() - mysqlnd uses hardcoded select() for its poll() mecanisms Python already have a layer, at http://hg.python.org/cpython/file/abcf17bc5eae/Modules/selectmodule.c Apache's APR has a nice layer with adapters, at https://github.com/apache/apr/blob/trunk/poll/unix/pollset.c Still, there exist the excellent libevent http://libevent.org/ So basically, the first question will be do we need it ? I would say yes. As we are talking about PHP6 and modernising our API, it is time I think to implement IO mux correctly and don't use the old select() everywhere where there is a better implementation (epoll and kqueue are both faster, and they dont suffer from any FD_SETSIZE limit) Also, we didnt talk about things as websockets etc... yet, for PHP6 , but it is sure that nowadays 2014, IO mux is a must-have. Second question will be : do we use, and then link against libevent (or any other lib that could fit the need) , or do we develop our own layer, based on the FPM layer which is pretty nicely done (just not shareable elsewhere at the moment). And then, will people be interested by the RFC ? Thx, Julien