-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Thread Performance Checker: Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. #694
Comments
What QoS is calling code running at? |
On the main... |
Ok one possibility is a thread pool is being created every time you call that function and this is causing issues. Instead you could create a global NIOThreadPool and pass it to Recently swift-nio supplied a singleton version of the NIOThreadPool. I can change the default to use this singleton instead of creating a new one every time the function is called |
PR for using singleton instead #695 |
@adam-fowler new version release ? |
The PR needs approved first |
@adam-fowler can you solve today? |
While waiting for a new release you should be able to use |
Hmm, I tried but is not solving the issue:
|
Ok, It looks like a similar issue apple/swift-nio#2223 I've seen on the swift-nio repository. The suggested way to resolve this was initialise the singleton on a background thread. This is going to require a little more work to get rid of the warning. Does the upload still fail after seeing the warning above? |
Yes... I mean is not failing (calling the completion function with an error), it's just stuck... |
As a test can you stick the following lines somewhere in the initialisation for your application DispatchQueue.global(qos: .background).async {
_ = NIOThreadPool.singleton
} |
@adam-fowler tested... in the debugger there is no warning displayed, but the upload process is stuck.. |
Ok looks like we have two issues here. The warning about thread priorities and then the hang. For the hang can we clean the code up a little. And also add some logging to get a better idea what is going on
var logger = Logger(label: "s3hang")
logger.logLevel = .trace
// Your s3 multipart upload call
s3.multipartUpload(request, ..., logger: logger)
s3 = s3.with(middlewares: AWSLoggingMiddleware() |
@adam-fowler I sent you an email with the logs file. Also, regarding the first point "The AWSClient should be global. You shouldn't create one for each upload operation." I might have an issue. The app supports multiple accounts and it can happen to have a different configuration for each account. Even if I optimise for use a single instance for an user, if there 10 accounts connected on the same app, I want to use different instances because each user has his own configuration. |
Are you uploading all of these at the same time? You might want to queue them. You could be opening too many connections. |
Maximum 5 uploads. So the user can select 100 files, but I take care to have 5 uploads at the same time, when one is ended, then I start another one. Do you think 5 uploads at a time maybe be to much? It worked perfect for a long period of time... things are broken recenly |
Just looking through the logs you sent.
|
Yes, all the files goes to multipart upload. In previous versions we had made some "hard core tests" like uploading more than 100+ files... selecting like 5 big videos and images, after the batch is ready, start again with other images and so on. Something happen in the last Soto SDK updates... We released the app in 2021 and we didn't had any use in the previous releases. |
I only see 18 |
Check email, I sent you some screenshots as well and a new logs file, this time stopped sooner... |
Are you able to use a branch of Soto. If so could you use the |
Also if you aren't able to use one AWSClient could you at least use just the one HTTPClient instead of creating a new one with each AWSClient. import AsyncHTTPClient
let globalHTTPClient = HTTPClient(eventLoopGroupProvider: .singleton)
let awsClient = AWSClient(..., httpClientProvider: .shared(globalHTTPClient)) |
Tried both, using singleton for HTTPClient cause a crash, I sent you an email with more details & logs |
Sorry I wasn't clear enough |
I did as you said, tried 3 tests with 20 images each time, works like a charm. |
I think the issue you were seeing was related to the fact each HTTPClient you create, creates a new EventLoopGroup and a new connection pool. Your application was creating an HTTPClient for every request which could cause a thread explosion. |
Oh wow, hmmm, should I wait for the SDK update before doing a new release? Maybe a mechanism, by default, to prevent things like this to happen? |
6.8 has been released with the singleton stuff |
Full debug logs:
I'm using S3 to upload multipart content and sometimes happens to receive those logs and progress/completion closures are not called, resulting that the file is stuck on "uploading" state.
Setup (please complete the following information):
The text was updated successfully, but these errors were encountered: