Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Let me describe our requirement in detail. We are doing some kind of assignment which requires capturing of IP data through NIC card and then processing the captured data in real time. The processing of captured data can be done partially or fully depending on CPU availability. But whatever can be done will be done in real time.

Our architecture is something like as follows. We use one thread to capture IP data from NIC card. And numbers of threads are created to process the captured data in real time and this number can go upto anything (say 500) which are CPU intrinsic threads.

Here is our observations: Please note that we have one thread for IP data capturing. When we create fewer processing threads (say 10) and consume CPU at around 95% in total, there is absolutely no problem in IP data capturing threads. But when we create huge number of processing threads (say 250) and consume CPU at around 80% in total, the capturing thread can't capture IP data properly. In later case, CPU availability is higher, but problem happens.

So we though the problem could be due the number of threads and their scheduling (also context switching). We thought the following kind of CPU distribution among the threads. Using affinity, we will set 25% of cores to capturing thread and 75% of cores to other processing threads.

To start with this, we wrote a simple program on a quad core i7 machine with HT ON. Suppose the logical cores are A1 A2 B1 B2 C1 C2 D1 D2 (A B C D being the real cores). Our sample thread is such that it consumes the all resources on a single HT core. So if I run 8 such threads on total 8 logical cores, CPU consumption shows 100%. Now we tried to assign affinity. If we create 2 cores and set affinity to A1 and B1 (It's not one thread to A1 and other thread to B1, it's combined affinity for two threads), then it works fine and CPU usage shows 25%. But if we set combined affinity to A1 and A2 for two threads, then only 12.5% is consumed (task manager shows only one core is used). But if we set affinity of 4 threads to A1, A2, B1, B2, then CPU usage shows 50%. So the question is why the second case (12.5%) is not working?

share|improve this question
    
There isn't a difference. Windows will treat a HT core exactly like how it will treat a physical store. Your question I will be honest is very confusing. Lots of information that really isn't required to ask the question you want to ask. –  Ramhound Apr 16 at 15:49
1  
If you give Windows fewer options, it will make worse choices. You almost definitely shouldn't be messing with CPU affinity at all. The scheduler can do a much better job than you can because it understands things such as clock boosting, core temperatures, demand from interrupts or hardware servicing, and so on. –  David Schwartz Apr 16 at 16:16
    
@Priyankar Ghosh: Why are you creating 250 processing threads? Your quad-core PC can't run more than 4 simultaneously. If your processing threads are using I/O that puts them in a waiting state then surely it would be better to find a way to reduce that bottleneck. –  James Apr 17 at 8:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.