Skip to content
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

Use parking lot mutex for maker orders #1163

Merged
merged 5 commits into from
Dec 13, 2021
Merged

Conversation

shamardy
Copy link
Collaborator

@shamardy shamardy commented Dec 8, 2021

fixes #1152

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! It's a first review iteration. Could you please also kickstart a testing session with @Milerius?

mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
mm2src/lp_ordermatch.rs Outdated Show resolved Hide resolved
@artemii235
Copy link
Member

@shamardy @Milerius Did you have a chance to test it together?

@shamardy
Copy link
Collaborator Author

shamardy commented Dec 9, 2021

@shamardy @Milerius Did you have a chance to test it together?

@Milerius is testing this with the market-making bot.

@Milerius
Copy link

@shamardy @Milerius Did you have a chance to test it together?

Running for almost 24 hours now, no problem so far and I even get a swap completed, locking time seems to be drastically less than before (0.8sec against 2-3 seconds before)

artemii235
artemii235 previously approved these changes Dec 10, 2021
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I had to puzzle a bit to imagine a case where a deadlock could occur.
Just one comment

.ok();
let maybe_order_mutex = ordermatch_ctx.my_maker_orders.lock().remove(&uuid);
if let Some(order_mutex) = maybe_order_mutex {
let order = order_mutex.lock().await;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong, but I think it's better to remove the order from OrdermatchContext::my_maker_orders in the loop above when the order AsyncMutex<MakerOrder> mutex is locked already, how you've done here.
It's not a recommendation, but a topic for discussion :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, I see now that the orders were canceled in another loop because we were iterating over the hashmap we needed to remove the order from but now since we iterate over a clone of the map it should be done in the above loop.

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 @sergeyboyko0791 Please check that your remarks are resolved. You can merge it afterward.

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sergeyboyko0791 sergeyboyko0791 merged commit 639bc59 into dev Dec 13, 2021
@sergeyboyko0791 sergeyboyko0791 deleted the parking-lot-maker-orders branch December 13, 2021 11:52
@sergeyboyko0791 sergeyboyko0791 linked an issue Dec 13, 2021 that may be closed by this pull request
@shamardy shamardy mentioned this pull request Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible deadlock on my_orders and discussion
4 participants