Kernel::WebApp::Plugin::0000JSONHandler

NAME

Kernel::WebApp::Plugin::0000JSONHandler – Replace Mojo::JSON with a faster JSON library.

PUBLIC INTERFACE

register()

No-op, magic happens at compile time. Replaces internal pure-perl methods of Mojo::JSON with Kernel::System::JSON, which uses JSON::XS if available.

This is done for two reasons: JSON::XS is magnitudes faster than Mojo::JSON, and our wrapper Kernel::System::JSON has some specific tweaks/workarounds. Some benchmark results:

    Result of 'encode_json':

    Rate JSON::PP JSON::XS
    JSON::PP  1116/s       --     -91%
    JSON::XS 12658/s    1034%       --

    Result of 'decode_json':

    Rate JSON::PP JSON::XS
    JSON::PP   627/s       --     -98%
    JSON::XS 27397/s    4270%       --

All four public methods from Mojo::JSON are overridden, since they need to behave consistently. It just happens that Mojo::JSON does support fallback to non-Perl library Cpanel::JSON::XS internally, and will replace its methods early if it finds installed library in the system. Please see bug#14416 for more information.

Scroll to Top