Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 253bd0c20582bdfa537c4056546c64785a1380dc
https://github.com/WebKit/WebKit/commit/253bd0c20582bdfa537c4056546c64785a1380dc
Author: Sosuke Suzuki <[email protected]>
Date: 2026-05-27 (Wed, 27 May 2026)
Changed paths:
A JSTests/microbenchmarks/map-clone-large.js
A JSTests/microbenchmarks/map-clone.js
A JSTests/microbenchmarks/set-clone-large.js
A JSTests/microbenchmarks/set-clone.js
A JSTests/stress/map-set-clone-large-table.js
M Source/JavaScriptCore/runtime/JSOrderedHashTableHelper.h
Log Message:
-----------
[JSC] Add a `gcSafeMemcpy` fast path for cloning large Maps and Sets
https://bugs.webkit.org/show_bug.cgi?id=315452
Reviewed by Yusuke Suzuki.
OrderedHashTableHelper::copy(), used by JSSet::clone() / JSMap::clone() (e.g.
`new Set(set)`,
`new Map(map)`, and the Set.prototype set methods), re-hashes and re-inserts
every alive entry
one by
one. For large tables this is slow because every insertion scatters writes
across the
whole table.
When the base table has no deleted entry, a copy with the same capacity is
bit-identical to
the base: every entry keeps its index, so the bucket chains stay valid. So this
change adds a
fast path which copies the table memory at once with gcSafeMemcpy() in that
case. The data
table slots after the used entries are empty in both tables, so it is enough to
copy the
header, the hash table, and the used part of the data table.
The fast path is taken only for tables with capacity >= 1024: empirically it
beats the
entry-by-entry copy there and the gap grows with the table size (about 2x for
1000 entries),
while for smaller tables both approaches are within a few percent of each other.
ToT Patched
set-clone-large 21.7035+-0.0747 ^ 10.3831+-0.1370 ^
definitely 2.0903x faster
map-clone-large
24.7747+-0.2633 ^ 12.4437+-0.1895 ^ definitely 1.9909x faster
set-clone 6.3262+-0.3274 6.3180+-0.2851
map-clone 7.3885+-0.1931 7.2759+-0.1067 might be
1.0155x faster
Tests: JSTests/microbenchmarks/map-clone-large.js
JSTests/microbenchmarks/map-clone.js
JSTests/microbenchmarks/set-clone-large.js
JSTests/microbenchmarks/set-clone.js
JSTests/stress/map-set-clone-large-table.js
* JSTests/microbenchmarks/map-clone-large.js: Added.
(test):
* JSTests/microbenchmarks/map-clone.js: Added.
(test):
* JSTests/microbenchmarks/set-clone-large.js: Added.
* JSTests/microbenchmarks/set-clone.js: Added.
* JSTests/stress/map-set-clone-large-table.js: Added.
(shouldBe):
(shouldBe.compacted.has):
* Source/JavaScriptCore/runtime/JSOrderedHashTableHelper.h:
(JSC::JSOrderedHashTableHelper::copy):
Canonical link:
https://flagged.apple.com:443/proxy?t2=Ds3i3i2te5&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzEzOTUyQG1haW4=&emid=cfbd594e-af5e-4426-a715-140829671208&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications