Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73122 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80286 invoked from network); 13 Mar 2014 19:48:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Mar 2014 19:48:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.169 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.216.169 mail-qc0-f169.google.com Received: from [209.85.216.169] ([209.85.216.169:46431] helo=mail-qc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/B5-47923-19B02235 for ; Thu, 13 Mar 2014 14:48:33 -0500 Received: by mail-qc0-f169.google.com with SMTP id i17so1791985qcy.14 for ; Thu, 13 Mar 2014 12:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=0NPV2ObCyDJzLciUGrpPrtJnmt70JMs88av/DtjfRng=; b=pX4i+ZkMESii91oi32tMDU9FzLUdMsaPIbvOF5G2xCXPmUyL0U2Nuf+dbtjiUjYKTh GyGE/w+xMUlT/3UMVzYLjpFCXg6vyHgL54kqMH0b9z5J9/3IXoKbDZSfmSei6IoPT91r 6Nwn4eDKEwnTt20kWxP/fBHRgnSKvW2wfu3m2D103ZDQf3pIux6JnM+EFseluIShcJI7 V3DBdA4++TasitwbhesdrrX+nh96NKZY9E1wJTtfH8FUvuLXVfflrFs5nOxTZyvQcbKq D7vC2RaxmdoCtq+Y8N/rG5g3jTYcUi4To6wSb0SaLxOHvqB0wjp7BfEVrbk9GZsNmlUi RHSg== MIME-Version: 1.0 X-Received: by 10.229.112.5 with SMTP id u5mr4928846qcp.3.1394740110035; Thu, 13 Mar 2014 12:48:30 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.224.126.72 with HTTP; Thu, 13 Mar 2014 12:48:29 -0700 (PDT) Date: Thu, 13 Mar 2014 19:48:29 +0000 X-Google-Sender-Auth: -zp-svhgs-WXvCV4EU275su84o0 Message-ID: To: PHP internals list Content-Type: multipart/alternative; boundary=001a11330a74d00e1404f4823c87 Subject: New JSON parser From: bukka@php.net (Jakub Zelenka) --001a11330a74d00e1404f4823c87 Content-Type: text/plain; charset=ISO-8859-1 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... :) Thanks Jakub --001a11330a74d00e1404f4823c87--