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.
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
Reduce peer message traffic for ledger data #5126
base: develop
Are you sure you want to change the base?
Reduce peer message traffic for ledger data #5126
Changes from 20 commits
f0cf1fd
756cad9
8a17f16
226cb56
d5ec2d3
ecfa396
e490e57
30eee9b
978fecd
b8b7b31
43b6e3e
813ef05
89f5a67
d7e2d70
29de22e
e250086
da4a30c
eee8184
85dcf70
e23be8e
75fcca5
20ad383
f372585
d670c79
35acb44
1dcc061
6d3dc8e
cb6daa2
7894d8f
9293950
2090083
248b34f
79f9bb8
fd94b55
7e52abd
829e4f1
ca07176
39fe006
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 about replacing the (likely)
O(log N)
element lookup withO(1)
erase of an iterator ? The iterator which is returned frominsert
to be specific, and currently ignored. In this case theItem
wouldn't have to be stored insideCanProcess
object, so that's also one less template parameter and probably also smaller object size (hashes are larger than iterators I guess).Could even go one step further and replace all data members with
std::function<void()> cleanup_
which would capture all that it needs ifinsert
succeeded, or is empty ifinsert
failed. In this case no template parameters would be needed 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.
I didn't really consider using an iterator because I didn't want to consider the risks of it getting invalidated for any valid
Collection
type. For example, it looks likeunordered_map
would fit the template, but can invalidate iterators. One option is to force the collection to bestd::set
, which the current callers use.So only the ctor and
insert
would have template parameters? That could work.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 was incorrect in that last comment.
unordered_map
doesn't fit the template, butunordered_set
does, and it also says it can potentially invalidate operators. So, I wrote a genericinsert()
that doesn't use iterators, and a specialized one that does, and wrote tests for both. It may be overkill....Check warning on line 81 in include/xrpl/basics/CanProcess.h
include/xrpl/basics/CanProcess.h#L81
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 it is not covered by tests, perhaps we do not need this function ?
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's used in the call path for network traffic, most of which is not covered by tests. But I changed that call to use the boolean conversion, and everything seems fine.
Check warning on line 83 in include/xrpl/basics/CanProcess.h
include/xrpl/basics/CanProcess.h#L83
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 use
explicit
here; it would be consistent withstd::optional
and most otheroperator bool
inside the project.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.
Fixed
Check warning on line 1064 in src/xrpld/app/consensus/RCLConsensus.cpp
src/xrpld/app/consensus/RCLConsensus.cpp#L1064
Check warning on line 205 in src/xrpld/app/ledger/InboundLedger.h
src/xrpld/app/ledger/InboundLedger.h#L205
Check warning on line 212 in src/xrpld/app/ledger/InboundLedger.h
src/xrpld/app/ledger/InboundLedger.h#L211-L212
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 replace with
UNREACHABLE
and a nice & short description why (seeCONTRIBUTING.md
, section " Contracts and instrumentation" for naming guideline)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 replace with
XRPL_ASSERT
and a short description why; seeCONTRIBUTING.md
for contracts and instrumentation naming guidelinesCheck warning on line 399 in src/xrpld/app/ledger/detail/InboundLedger.cpp
src/xrpld/app/ledger/detail/InboundLedger.cpp#L399