Skip to content

Finish moving package collections to async/await #7746

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

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

AndrewHoos
Copy link
Contributor

Finish moving package collections to async/await

Motivation:

Finish the replacement of callback/result APIs with async/await

Modifications:

Move SQL queries off of the Swift concurrency queue
Move PackageCollectionsStorage protocol to async/await

Result:

No more callback based APIs in package collections

@AndrewHoos
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

IMO the use of DispatchQueue.sharedConcurrent in this context can lead to thread explosion, especially as we still have temp_await in different places in our codebase. Apparently, Dispatch will spawn more threads if any of the existing threads are stalled on a semaphore, which is what temp_await does.

@AndrewHoos AndrewHoos force-pushed the PackageCollectionsStorage branch from e8eb0a9 to 7c6dcfc Compare July 5, 2024 15:51
@AndrewHoos AndrewHoos requested a review from MaxDesiatov July 5, 2024 15:55
@AndrewHoos
Copy link
Contributor Author

@swift-ci test

@AndrewHoos AndrewHoos force-pushed the PackageCollectionsStorage branch 2 times, most recently from 45a01ed to 74afd50 Compare July 8, 2024 19:01
@AndrewHoos
Copy link
Contributor Author

@swift-ci test

@AndrewHoos
Copy link
Contributor Author

@swift-ci test windows

@AndrewHoos AndrewHoos force-pushed the PackageCollectionsStorage branch from 74afd50 to 1c5ae6b Compare August 6, 2024 17:20
@AndrewHoos
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@@ -48,63 +34,51 @@ struct FilePackageCollectionsSourcesStorage: PackageCollectionsSourcesStorage {
}

func list() async throws -> [PackageCollectionsModel.CollectionSource] {
Copy link
Contributor

@MaxDesiatov MaxDesiatov Aug 6, 2024

Choose a reason for hiding this comment

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

There are no async calls in this and other methods that would require await, maybe async effect and locking from it should be removed, while the type itself made an actor to synchronize access?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have two concerns with this.
1- It looks like motivating reason for the callbacks was parallel decoding of large collections. Maybe that is nontrivial necessary and was premature optimization.
2- This could be made an actor, but it does not solve synchronization between processes. If more than one process is accessing the same storage on disk then the synchronization needs to be done with file locks not swift concurrency isolation

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed those were file locks, thanks for the clarification

@MaxDesiatov MaxDesiatov merged commit 0aa21c4 into main Aug 7, 2024
5 checks passed
@MaxDesiatov MaxDesiatov deleted the PackageCollectionsStorage branch August 7, 2024 12:03
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