-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(snapshot): avoid recreate element a
every time
#1387
perf(snapshot): avoid recreate element a
every time
#1387
Conversation
🦋 Changeset detectedLatest commit: d21a234 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
a
every time
f75e801
to
f41bf19
Compare
f41bf19
to
44db8d7
Compare
|
@eoghanmurray Sorry for taking so long to answer, I will run the benchmarks as soon I can and I will bring back the results |
(in case you miss the thread further up) Could you cherry-pick eoghanmurray@615e164 And also rebase or merge master |
44db8d7
to
e36bc9d
Compare
@eoghanmurray Done! |
I've added another review comment as I'd like to be able to recreate the SPA scenario via a test which necessitates the cache bust. I created a test case but was not able to recreate the scenario where the cache bust is needed. |
@eoghanmurray did you submit the review? |
This is what I was referring to: Here is the test I was talking about, which could be cherry-picked in here, but basically it doesn't demonstrate any need for the And here's a refactoring of how to 'clear the cache' so that it only does it if there is an old A element, and if it's value is different to the incoming value: |
I propose merging a version of my changes: but without the |
e36bc9d
to
20c9fe8
Compare
You are right, I don't know if it was a bug on Chrome when I tested but the behavior that I described in the comment is not true anymore. I have updated the code to reflect your changes and I also removed those comments/code about SPA. Thanks for the patience, I was very lazy on this PR. |
@@ -565,7 +587,7 @@ function serializeTextNode( | |||
n, | |||
); | |||
} | |||
textContent = absoluteToStylesheet(textContent, getHref()); | |||
textContent = absoluteToStylesheet(textContent, getHref(document)); |
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.
I'm assuming this is 'more correct' if the doc
parameter is passed down via serializeTextNode
; but I haven't checked the consequences of that.
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.
To be clear, I think we need to use options.doc
(and pass in doc
in the options).
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.
I've passed in via options.doc in #1434
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.
Given that #1434 is not a goer, could you cherry pick the following commit which improves the issue raised in this thread:
eoghanmurray@615e164
Would you be able to cherry pick eoghanmurray@4d52165 as I think it still has worth in the event of this implementation being changed in future. (Although 'Maintainers are allowed to edit this pull request' is checked, I'm unable to push to your H4ad origin due to other permissions issues) |
Actually I'll just create a new PR for that test case |
Sure, I will try to leave a review as soon as possible. |
Just to note, using
|
perf(snapshot): avoid costly generation of <a> element on each call to `getHref`, instead cache an anchor element and reuse it's href attributed --------- Co-authored-by: Eoghan Murray <[email protected]>
Merges the following commits: * [Ensure there is separation of timestamps](rrweb-io#1455) * [perf(snapshot): avoid recreate element a every time](rrweb-io#1387) * [Fix that blob urls persist on the shared anchor element and can't be later modified](rrweb-io#1467) * [yarn format - prettier improvements & add .editorconfig](rrweb-io#1471) * [Fixup for background-clip replacement](rrweb-io#1476) * [Fix and test for bug](rrweb-io#1481)
perf(snapshot): avoid costly generation of <a> element on each call to `getHref`, instead cache an anchor element and reuse it's href attributed --------- Co-authored-by: Eoghan Murray <[email protected]>
Avoid recreating the same element every time, instead, we cache and we just update the element.
Before: 779k ops/s
After: 860k ops/s
Benchmark: https://jsbench.me/ktlqztuf95/1
On Chrome:
On Firefox: