Skip to content

0.11.0

Latest

Choose a tag to compare

@iliaal iliaal released this 20 Nov 16:43
· 3 commits to master since this release
0.11.0
e9eb4d8

Prebuilt binaries require PHP 8.4.27+ / 8.5.12+; build from source on older patches.

Performance

  • Strings with non-ASCII text are validated 16 bytes at a time with SSSE3 on x86-64 or NEON on ARM64: on Chinese or Russian text, fastjson_validate() runs about 1.8-2.2x faster, fastjson_decode() 1.2-1.4x, and fastjson_encode() with JSON_UNESCAPED_UNICODE about 2x; default encoding is 3-23% faster depending on how long the non-ASCII runs are. ASCII-only encoding is about 1.5% slower.
  • Reuse the verified ASCII prefix when measuring exact output sizes for large JSON strings, avoiding a redundant byte-by-byte scan before a late escape or UTF-8 character.
  • fastjson_pointer_set() no longer calls zend_strtod() on every untouched real to check for overflow. For plain decimal reals, it skips conversion when the integer-digit count (excluding leading zeros) is at most 308 and that count plus the signed exponent is at most 308. This sufficient condition does not cover every finite real: 0.01e309 still goes through zend_strtod(). The original float-heavy corpus measurements took 15–70% less time (canada.json 20.2 → 6.2 ms); output and errors are unchanged.

Changed

  • Bundled yyjson is now upstream master be9bd74, with local patches P-002 through P-010 re-applied.

  • Remove the unused internal unlimited JSON Pointer resolver and simplify the shared depth-check path. PHP APIs and pointer limits are unchanged.

  • Linux and macOS prebuilt binaries are built against PHP 8.4.27 and 8.5.12 instead of 8.4.1 and 8.5.0, so they include the memory-limit stop under Fixed, and require PHP 8.4.27+ or 8.5.12+ (8.6 binaries stay on 8.6.0). This reverses the 0.10.2 oldest-patch build. On an earlier patch the extension refuses to start with the warning below; PIE still selects the prebuilt binary there, so upgrade PHP or build from source on those patches.

  • On Linux and macOS with PHP 8.3+, the extension refuses to start when the running PHP is an older patch release than the one it was compiled against, with a startup warning naming both versions, instead of loading and later ending the process with an undefined-symbol error. PHP reports Unable to start fastjson module and exits; install a build for the running PHP version or build from source. Windows builds skip the check, since Windows resolves a missing import when the DLL loads.

  • fastjson_encode() and fastjson_file_encode() throw ValueError when $depth is outside the int range, on every supported PHP version, matching the json_encode() check added in php-src GH-23589. Previously such a depth made every container fail with a depth error while a scalar still encoded.

Fixed

  • fastjson_pointer_set() reports a number whose exponent has no digits, such as [1e], with the same message, position, and error code as fastjson_decode() (no digit after exponent sign at the exponent, or JSON_ERROR_UTF8 when the byte there is malformed UTF-8), including the JsonException code. Previously it reported a position one byte later, or unexpected end of data when only one byte followed the number, as in [1e].
  • On PHP 8.2.35+, 8.3.36+, 8.4.27+, 8.5.12+, and 8.6, which defer memory-limit errors until an internal call returns, decoding, encoding, fastjson_pointer_get(), fastjson_pointer_set(), and fastjson_merge_patch() no longer keep allocating after memory_limit is crossed. Previously a large or amplifying input ran to PHP's hard limit (by default twice memory_limit), which ends the process with exit status 137 without running shutdown functions; under FrankenPHP that kills the whole server. PHP now reports its usual memory-limit fatal error. The check is compiled in only when fastjson is built against those PHP versions' headers (they define ZEND_HAS_OOM); the prebuilt binaries are, see Changed. Peak memory can still exceed memory_limit by the allocation in flight, such as one output-buffer growth, and a single allocation larger than the room left below the hard limit, such as encoding one very large string, still ends the process.
  • A malformed escape in a JSON string (a backslash followed by anything other than "\/bfnrt or u plus four hex digits, such as "\x" or "\u12") now reports JSON_ERROR_SYNTAX, as json_decode() does, instead of JSON_ERROR_UTF8. This applies to fastjson_decode(), fastjson_validate(), fastjson_file_decode(), the pointer helpers and fastjson_merge_patch(), including the JsonException code. An unpaired surrogate escape still reports JSON_ERROR_UTF8.
  • fastjson_decode() no longer reads an uninitialized byte when JSON_INVALID_UTF8_IGNORE removes every byte of an object key. The key still decodes as "", matching json_decode().

Build

  • Prebuilt binaries for PHP 8.6: Linux glibc (x86_64, arm64) and macOS (arm64) .so files built against PHP 8.6.0, and Windows x64 TS/NTS DLLs.