Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Optimize ArrayType<T> Read & Write #22

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

MierenManz
Copy link
Collaborator

Performance gains compared to #21 branch

Function Gain
ReadPacked +21%
Read +18%
WritePacked +5%
Write +6%

image

Improved performance is due to the following

  1. Read: Allocating result array upfront
  2. Read & Write: Using result.length as max length for the iterator means that v8 may skip bound checks (Just a assumption)
  3. Read & Write: Destructuring means that we can cache the reference to type rather than to this and lookup type on it

These optimizations are most notable in smaller arrays like n < 100

@load1n9 load1n9 requested a review from eliassjogreen January 10, 2024 07:34
@MierenManz MierenManz merged commit c6906d7 into denosaurs:main Jan 10, 2024
2 checks passed
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