srandom | FASTEST /dev/urandom PRNG | Runtime Evironment library
kandi X-RAY | srandom Summary
kandi X-RAY | srandom Summary
srandom is a Linux kernel module that can be used to replace the built-in /dev/urandom & /dev/random device files. It is secure and VERY fast. My tests show it over 150x faster then /dev/urandom. It should compile and install on any Linux 3.10+ kernel. It passes all the randomness tests using the dieharder tests. srandom was created as an improvement to the built-in random number generators. I wanted a much faster random number generator to wipe ssd disks. Through many hours of testing and trial-and-error, I came up with an algorithm that is many times faster than urandom, but still produces excellent random numbers. You can wipe multiple SSDs at the same time. The built-in generators (/dev/random and /dev/urandom) are technically not flawed. /dev/random (the true random number generator) is BLOCKED most of the time waiting for more entropy. If you are running your Linux in a VM, /dev/random is basically unusable. /dev/urandom is unblocked, but still very slow.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of srandom
srandom Key Features
srandom Examples and Code Snippets
Community Discussions
Trending Discussions on srandom
QUESTION
I found a lot of questions/answers related to this issue but I failed to choose what exactly what I need.
How can I generate specified number of integers?
...ANSWER
Answered 2021-Oct-11 at 12:24I would use hexdump
and /dev/urandom
if they are available:
QUESTION
Sorry, I have never understood the rules here. I have deleted all the duplicate posts I have posted. This is the first related issue. Please do not mark this post as a duplicate of my other one(Reduce the number of executions by 3 times, but the execution efficiency is almost unchanged. In C), even if the code is somewhat similar, they raise very different questions.These are also two problems that I found on the same day. A similar post has been repeated by "misjudgment" and then closed. It may be that I did not clarify this issue. I really hope to get the answer, so I reposted it. I hope everyone can see the problem clearly, thank you very much!
In the following C code, I added an "if" statement to the loop of the first test time, and the execution times are exactly the same. In theory, it should be slower. Even though branch prediction can make their performance almost the same, it actually becomes a lot faster. What is the principle of this? I tried to use clang and gcc compilers to run in Mac and Linux environments respectively, and tried various optimization levels. In order to prevent the cache from being affected, I let the faster ones execute first, but the loops with redundant code execute faster.
If you think my description is not credible, please compile the following code into your computer and run it. Hope someone can answer this question for me,thanks.
C code:
...ANSWER
Answered 2021-Sep-17 at 07:32The key bottleneck is the load-use latency of cache misses while striding through tex[]
, as part of the dependency chain from old i
to new i
. Lookups from the small rand_array[]
will hit in cache and just add about 5 cycles of L1d load-use latency to the loop-carried dependency chain, making it even more unlikely for anything other than latency through i
to be relevant to the overall speed of the loop. (Jérôme Richard's answer on your previous question discusses that latency dep chain and the random stride increment.)
memcmp(tex+i, str, SLen)
might be acting as prefetching if tex+i
is near the end of a cache line. If you compiled with -O0
, you're calling glibc memcmp so the SSE 16-byte or AVX2 32-byte load done in glibc memcmp crosses a cache-line boundary and pulls in the next line. (IIRC, glibc memcmp checks and avoids page crossing, but not cache-line splits, because those are relatively cheap on modern CPUs. Single-step into it to see. Into the 2nd call to avoid lazy dynamic linking, or compile with -fno-plt
).
Possibly touching some cache lines that would have been skipped by the random stride helps HW prefetch be more aggressive and detect it as a sequential access pattern. A 32-byte AVX load is half a cache line, so it's fairly likely to cross into the next one.
So a more-predictable sequence of cache-line requests seen by the L2 cache is a plausible explanation for the memcmp version being faster. (Intel CPUs put the main prefetchers in the L2.)
If you compile with optimization, that 10-byte memcmp inlines and in the inner loop only touches 8 bytes. (If they match, then it jumps to another block where it checks the last 2. But it's exceedingly unlikely that ever happens).
This might be why -O0
is faster than -O3
on my system, with GCC11.1 on i7-6700k Skylake with DDR4-2666 DRAM, on Arch GNU/Linux. (Your question didn't bother to specify which compiler and options your numbers were from, or which hardware.)
QUESTION
In C, I reduced the total number of loop executions by nearly 3 times, but through testing the execution time, I found that there is almost no improvement in doing so. All optimization levels have been tested, and the results are basically the same(including O0, O1, O2 and O3). I guess it’s a problem with the compiler, but I want to know what causes this situation. And what to do to make the results meet expectations.
The code is as follow:
...ANSWER
Answered 2021-Sep-16 at 16:51There are a couple of things that could be causing this:
If you're timing your code, you should have:
QUESTION
The following is a code example of the question which numbers can be generated in an adjustable range. The range can be set so that only positive, only negative or positive and negative numbers can be output.
In the example, the output numbers are passed to an array and when the array is output, the number of times each number occurs is output.
In the example, the processing by the array only works for positive numbers, which is probably due to the fact that a bash array can only have a positive and no negative field index.
...ANSWER
Answered 2021-Jul-17 at 14:36Associative arrays allow arbitrary strings as indices.
Here, I also took the liberty to change your 2nd loop to (( i=ug; i<=og; i++ ))
, which seemed more reasonable.
QUESTION
I've (so far) failed to successfully cross compile mosquitto with TLS for an embedded armv7 device. Without TLS, cross compilation works fine.
Embedded Device Data:
...ANSWER
Answered 2021-Feb-19 at 16:14Your target may not have dedicated hardware for encryption, and you therefore may not have any openssl
crypto-engine implementation available on your platform, nor a version of openssl
compiled with support for crypto-engines.
You can check by executing ls: /usr/lib/engines-1.1
, since this is the location specified in the output for the openssl version -a
command you executed. If no dynamic libraries are present, or the directory does not exist, this is likely that you don't have any support for crypto-engines currently available on your system.
In this case, you will have to re-build mosquitto
with the CFLAGS=-DOPENSSL_NO_ENGINE
option, so that mosquitto
will not attempt to load any (non-existing) openssl
crypto-engine at startup.
QUESTION
Bash 5.1 introduces SRANDOM
variable, but does it make any difference when used like this?
ANSWER
Answered 2020-Dec-31 at 18:18RANDOM
(16-bit) vs SRANDOM
(32-bit); 32-bit => much bigger random numbers (ie, more random numbers).
As for the randomness of the 2x variables ...
Try running:
QUESTION
I need some help understanding this Linux programming assignment. I have to use this C program that will randomize a text file and here is the program:
...ANSWER
Answered 2020-Mar-05 at 01:11That block of script code sets the variable SHUF
to the program you should use to shuffle a file. Either it will be the system's shuf
program or your teacher's shuffle
program.
After the code is done, you can use $SHUF
to run whichever program was found.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install srandom
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page