Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
how to create a file with random data - use all cpu cores
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
SarahS93
l33t
l33t


Joined: 21 Nov 2013
Posts: 693

PostPosted: Thu Jan 11, 2024 2:42 pm    Post subject: how to create a file with random data - use all cpu cores Reply with quote

Code:
time -p dd if=/dev/urandom of=urandom1gbfile bs=1G count=10
10+0 Datensätze ein
10+0 Datensätze aus
10737418240 Bytes (11 GB, 10 GiB) kopiert, 23,3878 s, 459 MB/s
real 24,17
user 0,00
sys 24,08

25 seconds for a 10gb random file.
the system has 8 core cpu. dd only use 1 core, 7 cores are unused.
is there a way to create it faster with all 8 cores together?

:edit
for a 16gb file with data from urandom with all 8 cores in use i try
Code:
for i in $(seq 1 8); do (head -c 2G </dev/urandom >>urandom16gbfile&); done

it works

is there an other better way to do that?
Back to top
View user's profile Send private message
jpsollie
Apprentice
Apprentice


Joined: 17 Aug 2013
Posts: 291

PostPosted: Fri Jan 12, 2024 11:22 am    Post subject: Reply with quote

I'm not really sure why you'd want that, but something you may try is using fallocate file1 as a 16gb file, then run all threads in parralel using something like dd if=/dev/urandom of=filexx seek=(core_nr * 2gb) to write everything
_________________
The power of Gentoo optimization (not overclocked): [img]https://www.passmark.com/baselines/V10/images/503714802842.png[/img]
Back to top
View user's profile Send private message
mrbassie
l33t
l33t


Joined: 31 May 2013
Posts: 786
Location: over here

PostPosted: Mon Jan 15, 2024 6:25 pm    Post subject: Reply with quote

Is this not a job for taskset?
_________________
Bus conductors learned to code.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21750

PostPosted: Mon Jan 15, 2024 6:51 pm    Post subject: Reply with quote

If all the jobs are busy, the kernel should schedule them to otherwise-idle cores without user intervention to pick which core to use.

I concur with jpsollie that this does not seem useful, and I will add that this seems like another XY problem. An explanation of the true goal might let us offer a better solution.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum