-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Refactor ElementListenerMap to use expando properties #18766
Merged
trueadm
merged 1 commit into
facebook:master
from
trueadm:refactor-element-listener-map
Apr 28, 2020
Merged
Refactor ElementListenerMap to use expando properties #18766
trueadm
merged 1 commit into
facebook:master
from
trueadm:refactor-element-listener-map
Apr 28, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
React Core Team
Opened by a member of the React Core Team
labels
Apr 28, 2020
trueadm
changed the title
Refactor ElementListenerMap
Refactor ElementListenerMap to use expando properties
Apr 28, 2020
trueadm
force-pushed
the
refactor-element-listener-map
branch
2 times, most recently
from
April 28, 2020 11:12
133a687
to
94232f5
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ad834b1:
|
Details of bundled changes.Comparing: 4b02b66...ad834b1 react-dom
ReactDOM: size: 0.0%, gzip: -0.0% Size changes (experimental) |
Details of bundled changes.Comparing: 4b02b66...ad834b1 react-dom
Size changes (stable) |
bvaughn
reviewed
Apr 28, 2020
bvaughn
approved these changes
Apr 28, 2020
packages/react-dom/src/events/plugins/ModernSelectEventPlugin.js
Outdated
Show resolved
Hide resolved
Cleanup Cleanup Address comments
trueadm
force-pushed
the
refactor-element-listener-map
branch
from
April 28, 2020 20:08
94232f5
to
ad834b1
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: Last year, I originally made the change that moved this code to use WeakMaps in #15036.
I recently did some profiling and noticed that we are spending quite a bit of time accessing and setting Maps on
DOMEventListenerMap
's WeakMap for each element when using the Modern Event System. The times weren't huge, they were just collectively many morems
than I would have liked. I profiled switching back to aMap
and the times do go down, but then we end up likely leaking by making that change. Why didn't we notice this before? Well I believe it has to do with the fact that we almost always were doing lookups on thedocument
as the WeakMap key, with very few other DOM nodes used as keys. Doing expando lookups ondocument
is about equivalent in performance to doing lookups with a WeakMap (document
has only a slow path?). Now that we've moved to roots, I'm now seeing a more noticeable perf difference.With all that in mind, I've moved us back to using internal expando properties on DOM nodes instead, which fixes the performance issue I was seeing. I also don't see any regressions with the legacy event system doing this.