Overview
Features
Download
Documentation
Community
Add-Ons & Services

WinCE HTTPServerParams thread priority

A general discussion forum.

WinCE HTTPServerParams thread priority

Postby mbue » 23 Oct 2013, 11:24

Hello,

I wrote a WEC7 console application hosting a POCO HTTPServer instance which serves some HTTP requests.
As the initial application has run very slow, I set the priority of the main thread to 97, which lead to fast responses upon the first HTTP request.
However, subsequent HTTP requests are still served pretty slow (upon five seconds delay between serving pretty trivial requests). I guess that's because of the thread priority of the worker threads the HTTP server is instancing (i set the maxThread-value to 2).

Thus, I've called setThreadPriority of HTTPServerParams with PRIO_HIGHEST. However, that didn't improve the performance. When I'm calling CeGetThreadPriority on the current thread within my Request Handlers, the priority is always set to 249, which is a rather low priority.
HTTPServerParams does not have an option like setOSThreadPriority to take finer control about what's configured within the threads.

Long story short: how can I further increase the thread priority of the HTTP Server worker threads?

Thank you in advance.

Best regards
mbue
mbue
 
Posts: 10
Joined: 07 Jun 2013, 11:34

Re: WinCE HTTPServerParams thread priority

Postby guenter » 23 Oct 2013, 12:44

This may provide more background on the issue:
http://msdn.microsoft.com/en-us/library/ee488350.aspx
and
http://msdn.microsoft.com/en-us/library/ee488350.aspx

So, apparently, only thread priorities from 248 to 255 are possible if the provided constants are used.
As a temporary workaround, you could try to pass a lower priority to HTTPServerParams, by casting an integer value with the desired priority to Thread::Priority. Not sure if these will work with SetThreadPriority, though (the MSDN documentation is not clear on this, especially pre WinCE 7).
Alternatively, you could redefine the thread priorities in Thread_WinCE.h to those for CeSetThreadPriority (see http://msdn.microsoft.com/en-us/library/ee488041.aspx) and replace calls to SetThreadPriority with CeSetThreadPriority. The latter may be a good longterm solution, if it works.
guenter
 
Posts: 1166
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: WinCE HTTPServerParams thread priority

Postby mbue » 23 Oct 2013, 13:27

Hello guenter,

thank you for your fast response.
The proposed cast did not work (the worker threads don't seem to be executed at all), however I've used CeSetThreadPriority to adjust the priority for both request handlers and the request handler factory. However, still no luck.

It now seems like the processing of each request is pretty fast, however during each call of the request handler (I logged each handleRequest-method), the server seems to process no requests for approx. 3 to 5 seconds. Are there any other threading issues involved which could slow down the HTTP server?

Thank you in advance.
mbue
 
Posts: 10
Joined: 07 Jun 2013, 11:34

Re: WinCE HTTPServerParams thread priority

Postby guenter » 24 Oct 2013, 09:13

Since I don't see your code it's a bit hard to diagnose, but if you have keep-alive enabled, you should increase the maximum number of threads to at least 4. Request handler threads will be blocked during the keep-alive period. Alternatively, disable keep-alive if you want to keep the number of threads low.
Since I currently don't have access to a WinCE 7 environment, have you tried the Thread_WinCE modification (redefine thread priorities and use CeSetThreadPriority)?
guenter
 
Posts: 1166
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: WinCE HTTPServerParams thread priority

Postby mbue » 25 Oct 2013, 15:38

Hello guenter,

thank you for your fast response. Increasing the thread count to 4 did the job for me, I didn't think about the keep alive issue. Now the HTTP server runs pretty fast.
Thank you for your help.
mbue
 
Posts: 10
Joined: 07 Jun 2013, 11:34


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron