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

rangeCheck internal method is slow #41

Open
MierenManz opened this issue Jul 17, 2024 · 1 comment
Open

rangeCheck internal method is slow #41

MierenManz opened this issue Jul 17, 2024 · 1 comment

Comments

@MierenManz
Copy link
Collaborator

MierenManz commented Jul 17, 2024

Currently super.rangeCheck is used a lot in the code to throw RangeError before writing into a buffer whenever a bound will be crossed (in comparison without this check we may have partial writes meaning that the buffer may contain invalid data).
This "correctness" comes with a small performance penalty for each class that inherits SizedType.
For single types the penalty is not much but for compound types like arrays, tuples and struct it can become quite a hassle.

With rangecheck
image
Without rangecheck
image

I think it may be a good idea to either remove the rangecheck entirely and just declare the written buffer as not good to read from.

Alternatively we can remove a bit of the penalty in compound types and only let the top level type do the range check (all types under the top level will do a bound check that is less than the total size of it's parent)

Some data: Time penalty is anywhere from 37% (cold start) to 12% (avg)

@MierenManz
Copy link
Collaborator Author

@eliassjogreen @load1n9 What do you two think about this?

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

No branches or pull requests

1 participant