-
Notifications
You must be signed in to change notification settings - Fork 90
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
KBS: Optimize performance and memory usage #258
Conversation
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 think this is good but see one comment
kbs/src/api/src/http/config.rs
Outdated
@@ -25,9 +25,6 @@ pub(crate) async fn attestation_policy( | |||
} | |||
|
|||
attestation_service | |||
.0 | |||
.lock() | |||
.await |
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.
Any concerns about not locking here given that this will change the state of the AS?
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.
Thanks for pointing out this. IMO, the lock/synchronization mechanism should be token cared of on the server side, like in CoCo-AS we use a read-write lock to handle the requests.
The client side code just call the API and the server can response in some order. That means, if users want to use a new policy to do attestation. In their code should call set_policy
of KBS and wait for the successful return. Then call attestation API.
Among current three implementations of AS client, built-in-coco-as
seems to have some trouble for synchronization. This is because AS is just a lib and KBS is actually the server. Let me add aRwlock
on the client side as a workaround.
506a748
to
98e03cc
Compare
We are doing some tests together with @Lu-Biao to check if this works. |
With much help from @Lu-Biao , we found some bottle necks: Throughput
Memory usage
We did some optimizations
|
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.
This is great. I really like the new SessionStatus enum (even though the variants share some of the same fields) and the macro for its fields. Ofc the results are great too.
I have one minor comment but generally seems ready.
1378394
to
c6445c7
Compare
1. Add a more detailed error information for failures of attestation 2. remove unwrap and use an error handling Signed-off-by: Xynnn007 <[email protected]>
Before this commit, we never free the memory of the sessions that is expired, which will let the kbs process memory usage monotonically increase. Signed-off-by: Biao Lu <[email protected]> Signed-off-by: Xynnn007 <[email protected]>
Currently we are using a global Mutex to protect the only one attestation service client from unsafe thread sync & send. This brings performance bottle neck.
This commit will create a temporary client object to handle the current attestation request, which can break the mutex.
Fixes #256