Skip to content

docs: update the objectMechanism section - #939

Merged
Tony133 merged 1 commit into
mainfrom
docs/readme-native
Nov 23, 2026
Merged

Tony133 merged 1 commit into
mainfrom
docs/readme-native

Conversation

@Tony133

@Tony133 Tony133 commented Nov 22, 2026

Copy link
Copy Markdown
Member

Proposal:

  • Fix the advice on Date values in the objectMechanism section, which is wrong since v7.3.9.
  • Update the numbers of the section to v7.3.10.
  • Documentation only.

Problem:

The README still says to keep the default mechanism when the objects have Date values in format: date-time properties, because there the default mechanism is 1.2-1.7x faster. That was true until v7.3.8. Since #935 it is the opposite, so today the README advises against the option exactly where it gains the most.

The other numbers of the section were measured on v7.3.5 and do not cover $ref.

Change:

  • "When to use it": Date values are now a reason to enable the option. The projection writes them 1.8-2.1x faster than the default mechanism and 4-5x faster than JSON.stringify.
  • List of 50 objects: 1.6-1.7x faster than the default mechanism, also when the objects are described through a $ref; about 4x faster than JSON.stringify when each object has three undeclared properties.
  • Distance from a bare JSON.stringify on plain data: 5-16% in the section, 2-16% in the introduction. The 2-6% of the fixtures in benchmark/ is unchanged.

Benchmark:

Node v26.13.0, Apple Silicon, fast-json-stringify v7.3.10, ops/sec.

Case JSON.stringify fast-json-stringify v7.3.10 (default mechanism) fast-json-stringify v7.3.10 (objectMechanism native)
50 rows x 8 columns (5 strings) 97.0k 54.2k 89.8k
50 rows x 8 columns, class instances 97.2k 53.9k 91.1k
50 rows x 8 columns, 3 undeclared columns 22.9k 54.7k 90.2k
50 rows x 8 columns, items is a $ref to a shared schema 97.7k 55.2k 92.5k
object, 2 strings and 1 date-time 1.25M 3.66M 6.52M

The 2.1x on Date values comes from the table in #935 (list of 50 rows with one date-time: 111.8k against 52.1k, and 26.6k for JSON.stringify).

Note:

  • No code change, no release needed.
  • The two benchmark outputs at the top of the README are still the ones of v7.3.5, as written above them. They can be refreshed in a separate PR.
  • The sentence about Node.js 24 ("the option is a no-op") stays until perf: enable objectMechanism 'native' on Node 22 and 24 #938 is decided.

@Tony133
Tony133 marked this pull request as ready for review November 22, 2026 15:24
@Tony133
Tony133 merged commit 192949a into main Nov 23, 2026
5 checks passed
@Tony133
Tony133 deleted the docs/readme-native branch November 23, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants