>
I thought that ‘use JSON’ would detect the availability of the XS module and use it if possible, is that correct?
I believe you're thinking of JSON::MaybeXS.
This module first checks to see if either Cpanel::JSON::XS or JSON::XS (at at least version 3.0) is already loaded, in which case it uses that module. Otherwise it tries to load Cpanel::JSON::XS, then JSON::XS, then JSON::PP in order, and either uses the first module it finds or throws an error.
Also please post some representational code, if you're hitting a bottleneck it could be a million different things.