-
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
feature(db): optimize properties query frequency #5378
feature(db): optimize properties query frequency #5378
Conversation
…into feature/optimize_properties_query_frequency_v6
isOptimized = snapshot.isOptimized(); | ||
if (isOptimized) { | ||
if (root == previous) { | ||
Streams.stream(root.iterator()).forEach( e -> put(e.getKey(),e.getValue())); |
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.
reformat the code style, put the white space
to the right place
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.
These two if statements can be combined
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 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.
Why reserve these if they are useless?
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 removed this part of the commented code
SnapshotImpl fromImpl = (SnapshotImpl) from; | ||
Streams.stream(fromImpl.db).forEach(e -> | ||
{ | ||
if (db.get(e.getKey()) == null && e.getValue() != null ) { |
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.
code format
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.
👌🏻
@@ -83,6 +99,20 @@ public void merge(Snapshot from) { | |||
Streams.stream(fromImpl.db).forEach(e -> db.put(e.getKey(), e.getValue())); | |||
} | |||
|
|||
public void mergeFullData(Snapshot from) { |
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.
As I see, the merge
method is used for merging the snapshotImpl
which is behind itself, this method mergeFullData
is used for merging the snapshotImpl
which is ahead, and only one snapshot
. it only can merge all data by another outside iteration.
So renaming the method name to mergeAhead
or mergeBefore
or mergeFront
may be better?
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.
OK, I renamed the mergeFullData function to mergeAhead
@@ -233,6 +233,12 @@ public synchronized void commit() { | |||
} | |||
|
|||
--activeSession; | |||
|
|||
dbs.forEach(db -> { |
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.
Why set the reload logic in commit()
, commit()
only invoked by the end of pushing a block, not a transaction.
Are there other reasons for doing this, can you explain?
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
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 is because if the transaction ends without a commit,
Revoke is needed at this time,
session.close is called,
Then call snapshotManager.revoke,
Then there is no need to perform reload logic.
So the reload logic is only executed when the transaction commits.
Any issue associated with this PR? So we can have a comprehensive background |
This Issue is associated with the current pr |
@CarlChaoCarl Please fix CI. |
…_properties_query_frequency_v6
OK, I have solved the CI problem |
} | ||
SnapshotImpl fromImpl = (SnapshotImpl) from; | ||
Streams.stream(fromImpl.db).forEach(e -> { | ||
if (db.get(e.getKey()) == null && e.getValue() != null) { |
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.
How would happen for e.getValue() == null
?
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.
It is necessary to count which keys are null and whether the access frequency is high
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.
db.get(e.getKey()) == null && e.getValue() != null
Passing these two judgments means:
- The current db does not have this key, that is, db.get(e.getKey()) is null,
- At the same time, the snapshotimpl from has this key and the value is not empty, that is, e.getValue() != null.
@wubin01 @halibobo1205
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.
How would happen for
e.getValue() == null
?
@halibobo1205 is it possible that key exists but value is null in the property database?
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.
@yuekun0707 , It shouldn't be null.
…query_frequency_v6
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more. @@ Coverage Diff @@
## develop #5378 +/- ##
==========================================
Coverage 61.35% 61.35%
- Complexity 9348 9352 +4
==========================================
Files 846 846
Lines 50211 50231 +20
Branches 5583 5584 +1
==========================================
+ Hits 30805 30818 +13
+ Misses 17002 17001 -1
- Partials 2404 2412 +8
... and 11 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
SnapshotImpl fromImpl = (SnapshotImpl) from; | ||
Streams.stream(fromImpl.db).forEach(e -> | ||
{ | ||
if (db.get(e.getKey()) == null && e.getValue() != null ) { |
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.
Will there be a frequently accessed key with a value of null?
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.
db.get(e.getKey()) == null && e.getValue() != null
Passing these two judgments means:
- The current db does not have this key, that is, db.get(e.getKey()) is null,
- At the same time, the snapshotimpl from has this key and the value is not empty, that is, e.getValue() != null.
@wubin01
isOptimized = snapshot.isOptimized(); | ||
if (isOptimized) { | ||
if (root == previous) { | ||
Streams.stream(root.iterator()).forEach( e -> put(e.getKey(),e.getValue())); |
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.
These two if statements can be combined
|
||
dbs.forEach(db -> { | ||
if (db.getHead().isOptimized()) { | ||
db.getHead().reloadToMem(); |
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.
isOptimized judged twice
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.
OK,I get it
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 have fixed this
} | ||
SnapshotImpl fromImpl = (SnapshotImpl) from; | ||
Streams.stream(fromImpl.db).forEach(e -> { | ||
if (db.get(e.getKey()) == null && e.getValue() != null) { |
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.
It is necessary to count which keys are null and whether the access frequency is high
Better to add the unit test for these changes |
…query_frequency_v6
…query_frequency_v6
…s://github.com/CarlChaoCarl/java-tron into feature/optimize_properties_query_frequency_v6
@tomatoishealthy Yeah, I have added unit tests. |
close #5375