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 at 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
>