views:

81

answers:

2

This query is related with the packet processing in multicore processors. Packet processing can be either in Linux or pure datapath. Is it true that if the packet processing application is on Linux, then it must be interrupt based processing of packets for high performance, but if the packet processing is in pure datapath (without linux), then polling should be used to obtain higher performance ? If yes, Why/How?

+1  A: 
  • Polling
    Are we there yet? Are we there yet? Are we there yet? Are we there yet? Are we there yet? ...

  • Interrupts
    Ping me when it's done.

So, interrupts allow the CPU to do other work, while polling avoids the overhead of interrupts (significant if you are getting interrupted tens of thousands of times a second). Different kinds of high performance.

Note there are hybrid aproaches, i.e: polling after interrupts for a few ms, before reverting to interrupts.

ninjalj
+1  A: 

If you're using a multitasking operating system then polling will come with a latency penalty (if the packet arrives while another task is executing). Therefore you can get better throughput by using an interrupt-based approach on such systems. This is because the interrupt mechanism can elevate the priority of the data path above other processes without blocking them (as polling in a higher-priority task would block all the lower priority tasks).

If you're running on a bare-metal embedded system without an OS you should be able to get the best throughput using polling since the CPU can spend all its time checking for new packets or do processing as a result of receieved packets. This minimizes the latency and allocates a maximum of cycles to the packet processing. Calling an interrupt handler wastes cycles and introduces extra complexity in this case; since nothing else is running on the CPU any cycle you take is a cycle not used tending to the data path.

Note that this does not mean that total application performance is better or that any particular implementation is faster with polling. It only means that the max throughput possible is achieved through polling. For example, if your application needs to do lots of processing you might get better performance using DMA with interrupts. To know if polling is faster in any particular case depends heavily on the application characteristics of that case.

I'm not sure what the "multicore" aspect of this question is, but it can make sense to dedicate a CPU to I/O polling to get mimimum latency in an embedded multicore system although this too would be highly application specific.

As ninjalj notes, hybrid approaches can be used to optimize total performance in more complex scenarios. The above only holds for the simple case.

Per Ekman