facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.41k stars 596 forks source link

Use SegmentedArray for OrderedHashMap #1343

Closed ftanuma closed 1 month ago

ftanuma commented 2 months ago

Summary: Currently OrderedHashMap is using ArrayStorageSmall for the backing storage. ArrayStorageSmall has max element limit at around 500,000. When we try to insert more then 500K elements, all the insertion will become hash collision and will start linked list in each bucket. This is the measure reason why Set construction from large Array is slow.

By using SegmentedArray instead, the backing storage can grow more than 500K, thus it will not have as much collision as with ArrayStorageSmall, which result to much faster Set construction.

Reviewed By: neildhar

Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194

facebook-github-bot commented 2 months ago

This pull request was exported from Phabricator. Differential Revision: D53062194