-
Notifications
You must be signed in to change notification settings - Fork 227
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
Hold LOCKs only as long as necessary #85
Comments
I'm not sure if this is possible mate - how would you go about it? Let's say we do a I'm of course open to any ideas you have here mate, but I didn't think we could optimize any more until we changed architecture for data storage. |
Very good point about not knowing how wallet transactions are really relevant. Let's look at it this way: we do a lot of things, like querying the database, parsing transactions, converting some data into JSON objects, and all this has basically nothing to do with the wallet, so the lock is "unused" (or unjustified) during that time. I haven't really thought about specifics yet. A probably straight forward approach could be to lock the wallet, fetch the wallet transactions, and release the lock. If, for some reason, this isn't safe, because the wallet may interfere with the pointers to these wallet transactions, we could create copies of them before going on. |
That's the issue - you don't want to be creating say 10,000 copies of wallet transactions (you never know if you'll need them)... I have another approach in mind, bear with me for a few hours and I'll push up an update to |
Haha, this is slowly getting out of hands: we have a transaction history cache, one for trades, probably soon another one for the overview transactions (they could share the other cache actually), I have a coins view cache pending, and you one for wallet balances. Oh well.. :) Jokes aside: all this provided very, very significant speed boosts, so it's a good thing. :) However, I suggest to hold back (non trivial) structural updates of the RPC stuff until your RPC branch is in. |
Indeed hehe - FYI the idea is to provide a data source via Let me see what I come up with, I'm on a roll here I think hehe ;) |
Might be easier to cache |
That's probably a little more in depth than I was going for, but we could do I guess? FYI I was simply going to add a vector of uint256 that gets updated via the transaction handler when processed if it was in the wallet. What do you propose? Perhaps a map of uint256 & CMPTransaction that cached each transaction object? |
Ah, this sounds pretty straight forward approach.
Keep in mind: there are also STO transactions. Maybe we should get something like
I'm not really sure, and this was just an idea, but I initially assumed you wanted to cache |
Ahh, for the initial I figured we'd get away with just the hashes. If I exaggerate a scenario hopefully it'll help explain:
The code as present will need to loop through all 10K transactions from 2) and still hasn't found any recent Omni transactions. After going through those 10K transactions it'll then find those 10 Omni transactions I sent first. It'll do this every time I make the A list of hashes is sufficient to avoid that I believe :) |
Sounds good! :) |
Speaking of locks.. currently all Omni RPC commands are tagged as non-threadsafe, and as result, every call auto-locks We should ultimately lock on a case-by-case basis, and only for as long as necessary, so multiple RPC threads have an effect. |
Oh, look at this, when fetching simple send wallet transactions on mainnet, then around 99 % of the time is spent to populate the transaction object, and:
|
Yeah that call is horribly inefficient (see the comment hehe) - there is a large amount of work that is done to essentially "find" any crowdsales that the simple send could have been involved in because we don't currently store a list of atomic actions per message. This would be one of those things that comes in with the discussion on restructuring the stored data, where we have direct access to xyz rather than reconstructing it from the blockchain. |
Note, I can cache this too (using a map holding a matching between simple send txids & property ids their respective crowdsale purchase) which drastically would cut down on the amount of iterating SP databases and make the call much faster. |
I pushed up a couple of commits by the way, one with |
I digged deeper, and it's pretty surprising, but not unexpected: Most of the time goes into 205 To drill it further down, and locate the actual source:
|
As outlined in #84,
gettransactions_MP
and other parts currently lock certain sections longer than necessary.In case of
gettransactions_MP
an additional improvement could be to restructure the command, such that we lock the wallet, collect the wallet transactions, release the lock, and then process the transactions, instead of holding the lock for the whole time.I'm going to tackle it, once the RPC branch is in.
The text was updated successfully, but these errors were encountered: