Skip to content

Conversation

@zuston
Copy link
Member

@zuston zuston commented Sep 26, 2023

What changes were proposed in this pull request?

From the past experience, I found the sync lock performance is better than the tokio lock,
especially on the critical path.

And the flatten dashmap will be faster than the multiple level dashmap.

So this PR is to improve above performance point in app.rs

Why are the changes needed?

For better performance

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing UTs

@zuston zuston changed the title improvement(rust): use sync RWLock to replace tokio lock for better performance improvement(rust): use std RWLock to replace tokio lock for better performance Sep 26, 2023
@zuston zuston requested review from advancedxy and roryqi September 26, 2023 08:24
Copy link
Contributor

@advancedxy advancedxy left a comment

Choose a reason for hiding this comment

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

LGTM except one minor comment.

It would be great if there are some numbers about the performance improvement.

error!("Partial purge is not supported.");
} else {
self.store.purge(app_id).await?;
self.store.purge(app_id).await?
Copy link
Contributor

Choose a reason for hiding this comment

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

this line seems unrelated?

Is it necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

And the flatten dashmap will be faster than the multiple level dashmap.

This is included in description.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh... I mean why remove the ;. Is that related to the flatten dashmap?

Copy link
Member Author

Choose a reason for hiding this comment

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

my mistake, this is not necessary.

@zuston
Copy link
Member Author

zuston commented Sep 27, 2023

LGTM except one minor comment.

It would be great if there are some numbers about the performance improvement.

Oh, I dig it more to improve performance, the discussion is here https://users.rust-lang.org/t/tokio-await-mutex-too-slow/98278/8 .

From the maintainer of tokio mentioned, the sync lock is a good choice for us.

@zuston zuston marked this pull request as draft September 28, 2023 02:10
@zuston
Copy link
Member Author

zuston commented Sep 28, 2023

Switch to draft state. I'm evaluating to use parking_lot crate to replace std lock

@zuston zuston marked this pull request as ready for review November 3, 2023 07:19
@zuston
Copy link
Member Author

zuston commented Nov 3, 2023

cc @jerqi PTAL

@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2023

Codecov Report

Merging #1216 (f70d999) into master (adafac4) will increase coverage by 1.04%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #1216      +/-   ##
============================================
+ Coverage     53.67%   54.71%   +1.04%     
+ Complexity     2690     2689       -1     
============================================
  Files           403      383      -20     
  Lines         23456    21096    -2360     
  Branches       1992     1992              
============================================
- Hits          12589    11542    -1047     
+ Misses        10093     8851    -1242     
+ Partials        774      703      -71     

see 21 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@zuston zuston changed the title improvement(rust): use std RWLock to replace tokio lock for better performance [#1296] improvement(rust): use std RWLock to replace tokio lock for better performance Nov 3, 2023
@zuston zuston merged commit 14f16c5 into apache:master Nov 3, 2023
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.

4 participants