-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Replace serialization functions #8867
base: master
Are you sure you want to change the base?
Conversation
Oops, those performance numbers are from epee binary, the read for json should be less. |
I forgot to document a benefit of this new scheme - anything marked as a |
One thing I noticed during testing is that checking /get_info doesn't work anymore
Is this intentional? |
It is expected behavior given the code, but is probably not desireable. This endpoint should work with an empty JSON object in the body of the http message. I didn't think about these endpoints; JSON-RPC now requires a I'll work out some sort of fix for this. |
@selsta another update - assuming requiring a |
@selsta another update - I don't think this one is easily fixed, unless pay-for-RPC is removed. This endpoint has an optional field ( It's a shame that such a simple thing could hold up this PR, but this one is difficult to fix without a DOM. Maybe we re-enable DOM reading for requests but not for responses? It would be a shame to lose an ~81% improvement on these binary reads, but at least the requests are typically small anyway. |
We only removed it from the wallet side so far. |
Basically the "root" read-function has to do either: The latter is necessary currently because the template<typename T>
struct is_optional_root
: std::is_empty<T>
{}; with overloads for a couple of these RPC functions. |
9ad29e0
to
7327eae
Compare
@selsta force pushed the fix I mentioned earlier. I ran your test, and it appears to work. Not all endpoints can be empty, only ones where |
4feb4df
to
8eb225a
Compare
This could be fixed at the server mappers level: for all JSON requests, if the HTTP body is empty, just replace it with the string |
@vtnerd I don't know nearly enough about serialization to comment. |
@jeffro256 not a bad idea, but I prefer the current approach I just force pushed (but I might be persuaded otherwise). Making the string |
I might be misunderstanding here, but why would one want to put a minimum element size when deserializing |
If one was expecting to deserialize an array of large blobs (like tx blobs) from a untrusted counterparty I could definitely see the utility in this. |
This constraint might be confusing, particular since I haven't seen it used before. Perhaps I should change the name to The goal is to provide a cap on the compression ratio between the "on-the-wire" format and the C/C++ type. As example: I used this where
This is replacing p2p serialization, so it is doing exactly that. |
eff2620
to
9abfb43
Compare
Rebased after recent changes caused merge conflicts. EDIT: The |
5893932
to
8357858
Compare
Just did a rebase. |
e9edf20
to
d9a7b74
Compare
Another rebase, and updates based on @jeffro256 review (in the other PR #8970 ). |
0b0a3f5
to
c9df851
Compare
c9df851
to
7200698
Compare
Another rebase, and a change to c++17 |
7200698
to
0c848e9
Compare
Decided against |
* epee binary * epee JSON * ZeroMQ JSON
1c6e1c1
to
87db8c7
Compare
Just did a rebase, and changed around some of the array limits. See other review which was just updated too. |
This replaces all serialization functions (epee binary, epee json, and zmq json), except the custom binary formats for transaction and block. The design is a DOMless vtable interface for reading and writing (2 separate interfaces). The base vtable class can be used to support multiple formats with minimal executable size OR the derived class can be used directly for performance. The design re-uses existing macros, although the newer macros should be lighter on compiler resources.
Memory consumption issues are handled by having all arrays provide a constraint - either a max element count or a min size per element (i.e.
std::vector<std::string>
ideally has a min size ofsizeof(std::string)
per element to prevent memory issues on unpack).Most importantly, reading epee binary is ~81% faster and writing epee binary is ~56% faster (I re-used the benchmark by @jeffro256 on a ryzen 3 chip). This is primarily due to the removal of the DOM entirely - everything is done on the objects directly.
Unfortunately this diff is huge, and probably has no chance of ever being merged as-is. So I will try to break things into smaller chunks, with the caveat that if nobody wants the serialization to be replaced, its best to vote within this discussion thread here.