Skip to content

serialize/unserialize 3-6x slower than php (per-element temporaries); needs a native codec #280

Closed

Description

@blacktrs

Problem

serialize / unserialize of a list of 2 000 strings runs at about 2.3 ns/B and 6.8 ns/B natively against php's 0.7 and 1.1 (3x and 6x slower, linear). Profiles show the time in per-element string temporaries, memmove and the boxed mixed walker in prelude/serialize.php / prelude/unserialize.php. Tried and not worth it: an inline string leaf (~10%, within noise), in-place number parsing, substr_compare.

Proposal

A native IR serializer and parser for the common shapes (null, bool, int, float, string, array of those), falling back to the PHP walker for objects / references / Serializable. Same approach as __mc_json_escape.

Found by the sweep in #278.

Activity

  1. added
    enhancement
    on Oct 16, 2026
  2. blacktrs commented on Nov 9, 2026

    @blacktrs
    ContributorAuthor

    Fixed by #274. Measured on the 0.18.0 branch (#605), the issue's shape (2 000 strings, 2 000 rounds, macOS arm64): serialize 0.47 ns/B vs php 0.39; unserialize 0.70 ns/B vs php 0.84 (was 2.3 and 6.8 ns/B).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions