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(web): optimize AbortController #12165
Conversation
- Use regular class constructor and symbol "private" attributes - Lazy init set of followee signals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
const illegalConstructorKey = Symbol("illegalConstructorKey"); | ||
|
||
class AbortSignal extends EventTarget { | ||
#aborted = false; | ||
#abortAlgorithms = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, it would be good to add comments about performance optimizations so someone doesn't accidentally do something to cause a regression. For example, stating here not to use private properties on this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will probably have a side effect of leaking these fields during object inspection - AFAIK private fields do not show up during inspection. I'm not sure though if it is against the spec or anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, stating here not to use private properties on this class.
Well for Web APIs we don't use private properties anywhere, but only symbols. so this was just old code that wasn't updated yet to how we do things.
- Use regular class constructor and symbol "private" attributes - Lazy init Set of follower signals
Some benchmark data on class init: