Important: Please read the Qt Code of Conduct -

How to optimize Qt apps if RtlUserThreadStart is the bottleneck

  • Developing a computer vision app by Qt5.9.4, every computer vision operations, streaming encoding/decoding/fetching are done in another thread. The frame hang temporarily when I send the information to the server from times to times(all of the network operations are put in another thread, it need to encode image to jpg and generate json).

    Using Very Sleepy as profiler to find out the bottleneck(this app use a lot of gpu power, I only use sleepy to measure the cpu cost)

    screenshot of the results

    Note : Figure out the freezing issue is caused by the data insertion of sqlite(operate at main thread), but the most costly function call are related to multi-thread, although optimize sqlite data insert part should solve the issue, I would like to know how could I reduce time consuming by RtlUserThreadStart and another time consuming function calls, thanks

  • Lifetime Qt Champion

    Hi @tham,

    You will need to explain a bit more how your program works. Till then I can only guess:

    Do you start a lot of new threads? Do you start a new thread for every image that is to encode? Then you might be better of having one permanently running thread that gets a new picture e.g. by a signal and then does the processing.


  • @aha_1980

    Do you start a lot of new threads? Do you start a new thread for every image that is to encode

    Every thread only initialize once, they run as permanently thread until the app/camera closed.

    Edit : The computer vision part, do use a lot of sleep call, change it to wait condition may improve performance, but do it worth the trouble?

  • Lifetime Qt Champion

    hi @tham

    you should investigate a bit yourself why this API function sums up to 800 seconds and if that is critical.

    e.g. WaitForMultipleObjects is not as it suspends you thread waiting for data (which is perfectly Ok)

Log in to reply