-
Notifications
You must be signed in to change notification settings - Fork 413
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
OAK-10803 - Fix memory consumption of uncompress properties #1619
Conversation
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 saves space, but instead will make every read access slower, right?
Done. Refactored it to make read access faster. |
I don't see the value in this. This will restrict usability of compression to the time between creation and first access of the value. Thereafter it uses more space. |
Revert it to first commit. Yes, the read access is slower. |
|
Done. |
…ate DocumentPropertyState from CompressedDocumentPropertyState
IIUC this PR has now addressed the suggestion on OAK-10803. That I think we should follow-up with indeed. What about doing it in 2 steps though:
Currently this PR seems to mix both concerns, which makes review discussion a bit more complex. Having said that, reg the performance improvements: I still think we need to address the performance aspect differently. As it stands now, the first call to |
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.
Is the plan to re-purpose this PR to now address OAK-10803? Then we might want to change the subject of the PR (that usually also becomes the commit message later).
...t/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyStateFactory.java
Show resolved
Hide resolved
...t/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyStateFactory.java
Show resolved
Hide resolved
...rc/main/java/org/apache/jackrabbit/oak/plugins/document/CompressedDocumentPropertyState.java
Outdated
Show resolved
Hide resolved
I separated construction of DocumentPropertyState from CompressedDocumentPropertyState through a factory method for step 1: first address those suggestions (bring memory consumption back to pre-compression) |
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.
What's missing is the wiring. With this change, the compression code is actually never triggered since it doesn't go through the factory yet.
Done. Call DocumentPropertyState through factory method. |
|
||
public static PropertyState createPropertyState(DocumentNodeStore store, String name, String value, Compression compression) { | ||
|
||
if (compression != null && !compression.equals(Compression.NONE) && value.length() > CompressedDocumentPropertyState.getCompressionThreshold()) { |
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.
the length check here would result to true for -1
- shouldn't there be a test for that, did that not fail for some reason?
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.
The tests are checking default threshold exceeded or not, it didnt failed because of passing Compression.NONE as argument
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.
There should be a test that should fail now though. The condition is currently wrong.
Probably we should also use GZIP by default, otherwise the feature cannot be enabled at all?
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.
Done. We can enable the feature by calling differently factory method.
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.
We can enable the feature by calling differently factory method.
But that would require a code change. What I was referring to is enabling the feature by configuration - eg via the system property. We should have that - otherwise the code is not useable and disable in a hard-coded way. I do think we should use GZIP in the default, not NONE.
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.
Done.
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.
The test still doesn't fail consistently. I'm referring to DocumentPropertyStateFactoryTest.createPropertyStateWithDefaultCompression
. That is one test at least that should fail with the current code. The reason it doesn't fail is that it depends on test execution order. Some other test method in that class is executed first (eg createPropertyStateWithCompressionThresholdNotExceeded
) and that sets the threshold, so that createPropertyStateWithDefaultCompression
then runs on false assumptions.
Things that require fixing:
- createPropertyStateWithDefaultCompression should check that it actually uses the default - i.e. it should have an assertEquals before even executing the actual property creation (and that would currently fail, depending on test execution order)
- in addition to such asserts in each method, there must also be a
@After
and a@Before
that resets the threshold - plus the actual code fix
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.
Done
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.
Haven't yet fully checked but it looks like some tests got lost in translation? eg multiValuedAboveThresholdSize. Also, compressValueThrowsException : now expects an exception while previously it didn't?
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* PropertyState implementation with lazy parsing of the JSOP encoded value. |
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.
Would suggest to add some short mention of the fact that this class uses compression.
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.
Done
...rc/main/java/org/apache/jackrabbit/oak/plugins/document/CompressedDocumentPropertyState.java
Outdated
Show resolved
Hide resolved
this(store, name, value, Compression.GZIP); | ||
} | ||
|
||
DocumentPropertyState(DocumentNodeStore store, String name, String value, Compression compression) { |
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.
Presumably this class should be reverted to the state before compression? In doing that it looks like it missed a commit that came in between : b04de7e
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.
Manually added that commit
@Rule | ||
public DocumentMKBuilderProvider builderProvider = new DocumentMKBuilderProvider(); | ||
|
||
private Set<String> reads = newHashSet(); |
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.
please now new use of Guava.
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.
Done
What question or comment does this refer to? |
This question |
(Adding a general comment here in the main discussion as it otherwise might be getting a bit complicated by now) What I was trying to say: the fact that the
Plus what is also a regression vs the previous state is what I mentioned previously:
Previously the constructor was swallowing those exceptions, which I think is a good thing. Now that has been changed. Why? |
… to CompressedDocumentPropertyStateTest
Moved broken surrogate tests on CompressedDocumentPropertyStateTest(before and after are in place here). |
That's a change to the previous behavior though. We previously discussed that it shouldn't throw an exception for compressing a property but just fall back to uncompressed. What is the reason for this change? |
...ment/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyStateTest.java
Show resolved
Hide resolved
(Moving this back to main thread) Could the test ( |
On the test methods that seem to have gotten lost, here's a list of them - those existed prior to this PR and now seem gone (unless renamed) :
Also noticed that Also, as a general comment : I think it would be useful to go via the factory method whenever possible. That would extend the test coverage of the factory method - which is a very key element. (I think this would be the lost prio comment though) |
...document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentPropertyState.java
Outdated
Show resolved
Hide resolved
All the tests mention above were refactored to use new context. The test suite created covered all scenarios previous done. |
...rc/main/java/org/apache/jackrabbit/oak/plugins/document/CompressedDocumentPropertyState.java
Show resolved
Hide resolved
where is uncompressValueThrowsException covered? where testInterestingStringsWithoutCompression ? edit: plus where is testOneCompressOtherUncompressInEquals covered? |
Added required test methods in CompressedDocumentPropertyStateTest |
...rc/main/java/org/apache/jackrabbit/oak/plugins/document/CompressedDocumentPropertyState.java
Outdated
Show resolved
Hide resolved
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.
+1, looks good now. Will let the test run finish (but I think 2 tests also fail in trunk, so those should anyway be ignored), and then (squash) merge depending on results.
ok, test failed, but the failures looks like unrelated flaky ones. going to merge anyway. |
In OAK-10803 we introduce the possibility of compressing property values. During its development we encountered performance issues, namely with repeated decompression calls, even just during getNodeAtRevision. Before we can confidentially enable and use compression, we need to revisit performance first. Likely we'll have to make further tweaks before we can use it.