DPDK patches and discussions
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: Chris Pappas <chrispappas12@gmail.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] Random numbers at line-rate
Date: Mon, 21 Jul 2014 15:54:15 -0400	[thread overview]
Message-ID: <20140721195415.GA25740@hmsreliant.think-freely.org> (raw)
In-Reply-To: <CAE4G5iryAeKytnVLvpFoL7CmrnXxo_Gw0cmwOaAzNvvagr3QEg@mail.gmail.com>

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

  reply	other threads:[~2014-07-21 19:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 19:24 Chris Pappas
2014-07-21 19:54 ` Neil Horman [this message]
2014-07-21 20:43   ` Stephen Hemminger
2014-07-22  1:24     ` Neil Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140721195415.GA25740@hmsreliant.think-freely.org \
    --to=nhorman@tuxdriver.com \
    --cc=chrispappas12@gmail.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).