DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] Random numbers at line-rate
@ 2014-07-21 19:24 Chris Pappas
  2014-07-21 19:54 ` Neil Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Chris Pappas @ 2014-07-21 19:24 UTC (permalink / raw)
  To: dev

Hi,

I need to generate a random number per packet and I used the rte_fast_rand
function to do so. When I run the code for one port-core I get almost
line-rate performance. However, running simultaneously on multiple cores
degrades performance significantly. (in all cases I uses minimum-sized
packets).

Shouldn't the implementation scale for multicore and not degrade
performance or am I missing anything? Also, is there another recommendation
for generating randomness at line-rate? (the cpu does not support rdrand).

Best regards,
Chris

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] Random numbers at line-rate
  2014-07-21 19:24 [dpdk-dev] Random numbers at line-rate Chris Pappas
@ 2014-07-21 19:54 ` Neil Horman
  2014-07-21 20:43   ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Horman @ 2014-07-21 19:54 UTC (permalink / raw)
  To: Chris Pappas; +Cc: dev

On Mon, Jul 21, 2014 at 09:24:36PM +0200, Chris Pappas wrote:
> Hi,
> 
> I need to generate a random number per packet and I used the rte_fast_rand
> function to do so. When I run the code for one port-core I get almost
> line-rate performance. However, running simultaneously on multiple cores
> degrades performance significantly. (in all cases I uses minimum-sized
> packets).
> 
> Shouldn't the implementation scale for multicore and not degrade
> performance or am I missing anything? Also, is there another recommendation
> for generating randomness at line-rate? (the cpu does not support rdrand).
> 
> Best regards,
> Chris
> 

thats an odd random number generator.  I think, without locking, its likely on a
multicore system to produce identical values on multiple cores operating in
parallel (since multiple cores can read rte_red_rand_seed at the same time).
That may well lead to multiple packets having the same nonce, which might cause
odd behavior.

If your cpu supports it, I'd suggest writing some inline assembly to use the
rdrand instruction instead.  I'm not sure about its performance relative to the
current implementation, but IIRC the instruction is handled internal to the
core, so it should scale with any number of cpus.

neil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] Random numbers at line-rate
  2014-07-21 19:54 ` Neil Horman
@ 2014-07-21 20:43   ` Stephen Hemminger
  2014-07-22  1:24     ` Neil Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2014-07-21 20:43 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev

On Mon, 21 Jul 2014 15:54:15 -0400
Neil Horman <nhorman@tuxdriver.com> wrote:

> On Mon, Jul 21, 2014 at 09:24:36PM +0200, Chris Pappas wrote:
> > Hi,
> > 
> > I need to generate a random number per packet and I used the rte_fast_rand
> > function to do so. When I run the code for one port-core I get almost
> > line-rate performance. However, running simultaneously on multiple cores
> > degrades performance significantly. (in all cases I uses minimum-sized
> > packets).
> > 
> > Shouldn't the implementation scale for multicore and not degrade
> > performance or am I missing anything? Also, is there another recommendation
> > for generating randomness at line-rate? (the cpu does not support rdrand).
> > 
> > Best regards,
> > Chris
> > 
> 
> thats an odd random number generator.  I think, without locking, its likely on a
> multicore system to produce identical values on multiple cores operating in
> parallel (since multiple cores can read rte_red_rand_seed at the same time).
> That may well lead to multiple packets having the same nonce, which might cause
> odd behavior.
> 
> If your cpu supports it, I'd suggest writing some inline assembly to use the
> rdrand instruction instead.  I'm not sure about its performance relative to the
> current implementation, but IIRC the instruction is handled internal to the
> core, so it should scale with any number of cpus.
> 
> neil
> 

Or  just do per-core seed value (and use RTE_PER_LCORE)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] Random numbers at line-rate
  2014-07-21 20:43   ` Stephen Hemminger
@ 2014-07-22  1:24     ` Neil Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Neil Horman @ 2014-07-22  1:24 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Mon, Jul 21, 2014 at 01:43:50PM -0700, Stephen Hemminger wrote:
> On Mon, 21 Jul 2014 15:54:15 -0400
> Neil Horman <nhorman@tuxdriver.com> wrote:
> 
> > On Mon, Jul 21, 2014 at 09:24:36PM +0200, Chris Pappas wrote:
> > > Hi,
> > > 
> > > I need to generate a random number per packet and I used the rte_fast_rand
> > > function to do so. When I run the code for one port-core I get almost
> > > line-rate performance. However, running simultaneously on multiple cores
> > > degrades performance significantly. (in all cases I uses minimum-sized
> > > packets).
> > > 
> > > Shouldn't the implementation scale for multicore and not degrade
> > > performance or am I missing anything? Also, is there another recommendation
> > > for generating randomness at line-rate? (the cpu does not support rdrand).
> > > 
> > > Best regards,
> > > Chris
> > > 
> > 
> > thats an odd random number generator.  I think, without locking, its likely on a
> > multicore system to produce identical values on multiple cores operating in
> > parallel (since multiple cores can read rte_red_rand_seed at the same time).
> > That may well lead to multiple packets having the same nonce, which might cause
> > odd behavior.
> > 
> > If your cpu supports it, I'd suggest writing some inline assembly to use the
> > rdrand instruction instead.  I'm not sure about its performance relative to the
> > current implementation, but IIRC the instruction is handled internal to the
> > core, so it should scale with any number of cpus.
> > 
> > neil
> > 
> 
> Or  just do per-core seed value (and use RTE_PER_LCORE)
rte_fast_rand doesn't seem like it can take advantage of per lcore variables.
Generally speaking its not multi-threaded at all from what I can see.
neil

> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-22  1:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 19:24 [dpdk-dev] Random numbers at line-rate Chris Pappas
2014-07-21 19:54 ` Neil Horman
2014-07-21 20:43   ` Stephen Hemminger
2014-07-22  1:24     ` Neil Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).