Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c74b5b63f801e54fe07c3f95be71f3e57d7d8127
      
https://github.com/WebKit/WebKit/commit/c74b5b63f801e54fe07c3f95be71f3e57d7d8127
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-06-17 (Wed, 17 Jun 2026)

  Changed paths:
    A JSTests/microbenchmarks/map-set-delete-churn-large.js
    A JSTests/microbenchmarks/map-set-delete-churn.js
    A JSTests/microbenchmarks/set-add-delete-churn.js
    M Source/JavaScriptCore/runtime/JSOrderedHashTableHelper.h

  Log Message:
  -----------
  [JSC] Map/Set `set` + `delete` churn always expands then immediately shrinks
https://bugs.webkit.org/show_bug.cgi?id=317199

Reviewed by Yusuke Suzuki.

expandIfNeeded intends to rehash at the same capacity when tombstones
dominate, but compares deletedEntryCount against capacity / 2 while the
rehash fires at usedCapacity == dataCapacity == capacity / 2 for small
tables, so the branch is unreachable whenever any entry is alive. A Map
kept at constant size by repeated set+delete therefore always expands
x4 only to immediately shrink back, repeating this on every fill while
find() walks an ever-growing tombstone chain.

Compare against dataCapacity / 2 instead (matching V8's policy). After
the same-capacity rehash alive <= capacity / 4 stays above the
capacity / 8 shrink threshold, so this introduces no new grow/shrink
cycle.

                                  baseline                  patched
map-set-delete-churn-large  2381.5707+-218.4677   ^  522.1759+-9.4359   ^ 
definitely 4.5609x faster
map-set-delete-churn          86.2613+-3.8686     ^   37.2290+-1.5133   ^ 
definitely 2.3170x faster
set-add-delete-churn          80.6294+-4.6888     ^   35.3066+-2.2222   ^ 
definitely 2.2837x faster
set-delete-add                20.3424+-0.2986     ^   15.7992+-0.2317   ^ 
definitely 1.2876x faster
map-rehash                    18.9758+-0.8362     ?   18.9775+-0.5948   ?

Tests: JSTests/microbenchmarks/map-set-delete-churn-large.js
       JSTests/microbenchmarks/map-set-delete-churn.js
       JSTests/microbenchmarks/set-add-delete-churn.js

* JSTests/microbenchmarks/map-set-delete-churn-large.js: Added.
* JSTests/microbenchmarks/map-set-delete-churn.js: Added.
* JSTests/microbenchmarks/set-add-delete-churn.js: Added.
* Source/JavaScriptCore/runtime/JSOrderedHashTableHelper.h:
(JSC::JSOrderedHashTableHelper::expandIfNeeded):

Canonical link: https://commits.webkit.org/315431@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to