-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
fix #1063: poor memory performance when dup
ing DocumentFragment
#1834
Merged
flavorjones
merged 5 commits into
master
from
1063-flavorjones-dup-document-fragment-attempt-2
Dec 10, 2018
Merged
fix #1063: poor memory performance when dup
ing DocumentFragment
#1834
flavorjones
merged 5 commits into
master
from
1063-flavorjones-dup-document-fragment-attempt-2
Dec 10, 2018
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
because I'm about to add some behavior
This is an optimization of what's usually done, which is to make a document-local duplicate via `#dup` followed by an `#add_child` or similar. The drawback in that scheme, of course, is that unparented nodes cannot be GCed and so occupy memory while the document is still accessible. Using this new variation of `#dup` we can create a duplicate in the other document directly, without a direct clone.
because I don't have good evidence of high memory usage in the JRuby implementation.
[skip ci]
flavorjones
deleted the
1063-flavorjones-dup-document-fragment-attempt-2
branch
December 10, 2018 05:37
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again.
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again. (cherry picked from commit dda0be2)
flavorjones
added a commit
that referenced
this pull request
Dec 12, 2024
**What problem is this PR intended to solve?** Back in b92660e (#1834 fixing #1063) I omitted support in JRuby for the "new_parent_document" argument to `Node#dup` because there was no performance reason to implement it. So the test was skipped. However, in 1e7d38a and other commits in #3117 (fixing #316), I introduced a call to `initialize_copy_with_args` that passes the new parent document as an argument on both CRuby and JRuby implementations. Because the test was skipped, I didn't catch that this broke on JRuby. In particular this was a problem for Loofah which relies on decorators, and even more particularly this broke the `Loofah::TextBehavior` formatting concern for `Loofah::*::DocumentFragment` objects. **Have you included adequate test coverage?** The skipped test is no longer skipped! Maybe we should be running downstream tests with JRuby, too? But that feels like a big investment right now so I'll avoid scarring on the first cut, and wait to see if it happens again. **Does this change affect the behavior of either the C or the Java implementations?** Brings the Java impl into agreement with the C impl.
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.
See #1063 for background and why this is implemented for MRI and not JRuby. See related #1832 which is a placeholder for the JRuby work should we decide to do it.