Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73182 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76975 invoked from network); 15 Mar 2014 20:08:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2014 20:08:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.178 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.216.178 mail-qc0-f178.google.com Received: from [209.85.216.178] ([209.85.216.178:37904] helo=mail-qc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/C2-53536-323B4235 for ; Sat, 15 Mar 2014 15:08:03 -0500 Received: by mail-qc0-f178.google.com with SMTP id i8so4367557qcq.37 for ; Sat, 15 Mar 2014 13:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=A7RZuZWDG52C3nySBoc+WQ7SKfRnQfR6MnhDSE/f/dc=; b=ZaYhIBfqg0NQe2m/FWidQMlxSNjaoin0E/ayt4Hae8x/UcJEyz15EqCCBLOOaY8LmR Rx6EhoYNP6Cj5/2euKRz5EM0QLZric+3pvw2ro8xo9ZUqk5Q2ayRovvC8Tfnqs7xlzxD ITiuPJSaf1yS4bX6iSE1Jhqr+UKQnqXieB4LnCYbGMrYJEO2ZSQfqXX+mzs/KGiuOVww ZE6c27YalPLDOWtJMqpasR76UMhEU9jmfSRIc6lzCj2qba1Mas05Dcn2MrgbbzcPvIwF +idhiVuJHqlrpH73fGEPTt4K0PgODfmMtvongVJkB66hsVYqm4a1GALIieVw/Zh5PVNa F68Q== MIME-Version: 1.0 X-Received: by 10.140.109.10 with SMTP id k10mr15582969qgf.6.1394914080044; Sat, 15 Mar 2014 13:08:00 -0700 (PDT) Received: by 10.140.49.14 with HTTP; Sat, 15 Mar 2014 13:07:59 -0700 (PDT) In-Reply-To: References: Date: Sat, 15 Mar 2014 21:07:59 +0100 Message-ID: To: Jakub Zelenka Cc: PHP internals list Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] New JSON parser From: pierre.php@gmail.com (Pierre Joye) hi Jakub, On Thu, Mar 13, 2014 at 8:48 PM, Jakub Zelenka wrote: > Hi, > > I have create a new JSON parser using conditional re2c and pure pull Bison > parser. It's a native UTF-8 parser licensed under PHP license (it can be > used for Evil though :) ). The extension is available at > > https://github.com/bukka/php-jsond > > The encoder is taken from the current ext/json but the decoder has been > completely rewritten. > > I have done some basic benchmarks (the results are on the README.md page). > For short strings the results are almost the same (the new parser is > usually slightly faster) but there is a big difference for longer strings. > For example for string with 800 characters the new parser is 4 times > faster. If the string is longer, the results are even better. It's also > much faster for big arrays. For example decoding json_encode($_SERVER) is > twice faster with the new parser. > > In addition to the speed improvements there also is a big memory saving. > The old parser converts every serialized string to UTF-16 which requires > additional memory. Although the memory is freed after the parsing, it can > be problematic if the memory_limit is set. The new parser parses supplied > string and no extra memory for conversion is allocated. > > I need to do more testing before creating RFC for replacing the current > parser. There is still space for further improvements. If anyone has any > ideas, please let me know. Or if you could test it, that would be great > too! ;) > > I haven't finished the build config (it's working but it's not auto rebuild > when you change *.y or *.re files). Need to figure out how to add > Makefile.frag for bison and re2c . It's not working when I add > PHP_ADD_MAKEFILE_FRAGMENT($abs_srcdir/Makefile.frag) > $ make > make: *** No rule to make target `jsond.lo', needed by `jsond.la'. Stop. > Has anyone got any idea? :) > Also there is no build for Win atm as I don't have Windows... :( Hopefully > someone will do it for me... :) Awesome job, thanks! We can provide windows builds (it builds fine as of now). As soon as you do pecl releases, build will be done automatically. Cheers, -- Pierre @pierrejoye | http://www.libgd.org