-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
More optimizations to package load #14762
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
{ | ||
// TODO: Can this lock ever block execution? | ||
// TODO: Why do we need a RwLock anyway??? | ||
self.runtime_packages_loaded_from_db |
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 lock is for interior mutability since we only take self as read ref
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.
Great catch! Honestly I'm in favor of rethinking/replacing this logic altogether.
We put it together as a quick response for fork analysis, so I'm in support better solutions sooner than later if possible
0fbf864
to
1c039d3
Compare
@@ -54,7 +54,7 @@ pub struct TemporaryStore<'backing> { | |||
|
|||
/// Every package that was loaded from DB store during execution. | |||
/// These packages were not previously loaded into the temporary store. | |||
runtime_packages_loaded_from_db: RwLock<BTreeMap<ObjectID, Object>>, | |||
runtime_packages_loaded_from_db: RwLock<BTreeMap<ObjectID, PackageObjectArc>>, |
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.
we should consider just switching to DashMap
@@ -63,7 +63,7 @@ pub struct TemporaryStore<'backing> { | |||
|
|||
/// Every package that was loaded from DB store during execution. | |||
/// These packages were not previously loaded into the temporary store. | |||
runtime_packages_loaded_from_db: RwLock<BTreeMap<ObjectID, Object>>, | |||
runtime_packages_loaded_from_db: RwLock<BTreeMap<ObjectID, PackageObjectArc>>, |
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.
ditto DashMap
Description
I noticed that we still spend a non-trivial amount of time loading packages in execution. After digging in, I realized that this is mostly due to us trying to save all runtime loaded packages.
This PR minimizes that overhead by:
This fix is sufficient to make the package load disappear in a local benchmark, and we are seeing about 10% improvements in throughout in the baseline mode. So this is good enough for now.
However as a long term fix, I think a proper solution is that we should introduce a verbose flag to execution. Normally the verbose flag is off. When we detect a fork, we rerun the execution with the verbose flag on so that we could collect more information for the debug state dump.
Also fixed the execution-only mode in the local benchmark to use the package cache, otherwise we would see a ton of unnecessary clones there.
Test Plan
CI
If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.
Type of Change (Check all that apply)
Release notes