Send a blank email to [email protected] to get a copy of this message
On Thu, Mar 13, 2014 at 8:48 PM, Jakub Zelenka <[email protected]> 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... :)>
This sounds great! We solve the licensing issue *and* get a performance
benefit at the same time :)
One quick note, while looking over the code: FLOAT = INT "." UINT should be
FLOAT = INT "." DIGIT+ otherwise you'll disallow numbers with leading
zeros, e.g. 1.001. Same applies to ( INT | FLOAT ) [eE] [+-]? UINT, where
the exponent should also allow leading zeros ;)
Nikita