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

[CAS] Don't create the same CAS multiple times from the same Oracle #1511

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

cachemeifyoucan
Copy link
Contributor

If the oracle has been used to create a CAS for the path, reuse the CAS if it is asked to create the same CAS again. This not only save the work of creating the CAS, but also avoid a potential problem that the CAS closing synchronization doesn't work across threads in the same process due to its uses of file lock.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

createdCASMap[path] = CASConfig(onDiskPath: onDiskPath, pluginPath: pluginPath, pluginOptions: pluginOptions, cas: cas)
return cas
}
// If onDiskPath is nil, just create a new CAS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the client will end up depending on getOrCreateCAS to avoid creating separate CAS instances for every Swift invocation, could you also share CAS instances even if onDiskPath is nil (in case passing nil onDiskPath becomes important in the future), using pluginPath+pluginOptions as key in a separate dictionary?

If the oracle has been used to create a CAS for the path, reuse the CAS
if it is asked to create the same CAS again. This not only save the work
of creating the CAS, but also avoid a potential problem that the CAS
closing synchronization doesn't work across threads in the same process
due to its uses of file lock.
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@cachemeifyoucan
Copy link
Contributor Author

@swift-ci please test

@cachemeifyoucan cachemeifyoucan merged commit 73f788d into swiftlang:main Jan 2, 2024
3 checks passed
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.

3 participants