Bug 280144
| Summary: | Deleting existing entry from Map/Set followed by re-adding is 30x slower than in v8 | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Dylan Conway <dylan.conway567> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Local Build | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 14 | ||
Dylan Conway
Example minified from https://github.com/oven-sh/bun/issues/14063
```
var map = new Set();
for (var i = 0; i < 1000; i++) {
for (var j = 0; j < 1000; j++) {
map.delete(j);
map.add(j);
}
}
```
Running this on an m1 max takes about 1 second with JSC. With v8 it takes about 100 milliseconds.
Switching the order of `delete` and `add`, or combining the loops into a single loop to 1000000 does not seem to repro this behavior.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Dylan Conway
I suspect this is a bug causing the table to resize too frequently. Removing `shrinkIfNeeded` in `OrderedHashTableHelper::removeImpl` almost brings performance back to normal
Radar WebKit Bug Importer
<rdar://problem/136912759>
Yusuke Suzuki
Thanks. Oops, I accidentally opened a new bugzilla for patch upload. Merging it to that as it already has GitHub link.
*** This bug has been marked as a duplicate of bug 280600 ***