You are not logged in.

#1 2021-12-22 14:10:55

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Slow systemd-random-seed and general entropy-handling

Hello!
I have standard Arch installation. Recently, I checked the start-up process with systemd-analyze blame and found that systemd-random-seed.service is at the top with 1.4 seconds winning with the 2nd place service whole second. Status of this systemd service has some "Kernel entropy pool is not initialized yet, waiting until it is." witch I can't interpret. But I can compare how other Arch-based systems perform on my PC, and they have random-seed to spend less than 100 ms during the boot. This made me anxious to find out why and how to reproduce this speed in my main pure Arch system. Unfortunately, I couldn't find some helpful information in the ArchWiki. To the info, I have a lot of entropy (but not the RDRAND, because I have old CPU, FX-6300):

cat /proc/sys/kernel/random/entropy_avail
3820

After spending some time in digging in, I found that probable main difference between my system and other Arch-based distros is Calamares installer. And voilà, it code has some tuning for random and entropy. But it is hardcoded in C, and I don't get how it manipulates with the system. What I find, is that at the end I have only /var/lib/systemd/random-seed and calamares-installed systems have also /var/lib/urandom/random-seed. And the result is fantastic.
So, I ask for help. How can I better my system and not to see this 1.4 seconds in blame's list?

Offline

#2 2021-12-22 14:31:19

Zod
Member
From: Hoosiertucky
Registered: 2019-03-10
Posts: 636

Re: Slow systemd-random-seed and general entropy-handling

Offline

#3 2021-12-22 14:50:55

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

Thank you for fast reply. I found that wiki page and it contains very little information for how to improve the pure performance I have. Plus, it has the disclaimer "This article or section is out of date." which encouraged me to post the question here.

Offline

#4 2021-12-22 15:03:25

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,299

Re: Slow systemd-random-seed and general entropy-handling

How relevant are these seconds in the grand scheme of things? What's your

systemd-analyze critical-chain

? Is this reproducible? Afaik it will take a while the first time and then the point of it is that it will load it from disk eventually. Also which boot-loader? Afaik systemd-boot is the only one that can make "proper" use of this early on, so if you using something else and these installers use systemd-boot then this might be the early delay you're seeing.

Offline

#5 2021-12-22 16:03:05

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

critical-chain is somewhat weird. Also in graphical mode (systemd-analyze plot > plot.svg) - https://postimg.cc/sBD7rRNG :

graphical.target @2.401s
└─lightdm.service @2.160s +240ms
  └─systemd-user-sessions.service @2.154s +4ms
    └─nss-user-lookup.target @2.188s

1. Yes, it is reproducible. I get this long time for the random-seed service every boot.
2. I use GRUB and then lightDM with autologin.

Offline

#6 2021-12-22 16:14:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,299

Re: Slow systemd-random-seed and general entropy-handling

run the critical chain command as root, since this appears to be user session only.

2. This could be the problem, did you also use grub for the "Arch-based" distro experiments?

Offline

#7 2021-12-22 16:20:09

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

Strange, but It's the output with root privileges (simply with sudo and inside sudo -s).
2. Yes, I tried Arco-linux and  EndeavourOS. Both of them use grub.

Offline

#8 2021-12-22 16:41:46

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,299

Re: Slow systemd-random-seed and general entropy-handling

That said this is really quick especially in the loader, do the other systems really significantly lower from the 5 seconds? This sounds to me like they probably loose time elsewhere that you then just don't visibly see as entropy could be gathered before being relevant for the random-seed.service. FWIW technically the random-seed service isn't critical, so you could also just disable it. But I'm assuming you are chasing something that doesn't have an actual real effect in the end.

Offline

#9 2021-12-22 16:59:50

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,169

Re: Slow systemd-random-seed and general entropy-handling

But I can compare how other Arch-based systems perform on my PC, and they have random-seed to spend less than 100 ms during the boot.

Post full system journals for both systems?

Calamares installer. And voilà, it code has some tuning for random and entropy. But it is hardcoded in C, and I don't get how it manipulates with the system.

Maybe reference the codepoint you suspect to be relevant?

Online

#10 2021-12-22 17:04:50

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

Oh, I'm not chasing anything. Just curious why there is such big difference. Also it's intriguing what is this "tuning" made by Calamares (for instance, I don't see a message "Kernel entropy pool is not initialized yet, waiting until it is." in the status of systemd-random-seed.service there). What I'm afraid of is that my old CPU would need some tuning (maybe Calamare's one) because new versions of kernel have in focus modern CPUs with their RDRAND capability. So I see /var/lib/urandom/random-seed anymore as example.

Offline

#11 2021-12-22 17:17:27

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

seth wrote:

Post full system journals for both systems?

My actual system — http://ix.io/3J9F
Arco-linux on my PC — http://ix.io/3J9H

Maybe reference the codepoint you suspect to be relevant?

I'm speaking about this config inside Calamares https://github.com/calamares/calamares/ … ineid.conf and its execution by Entropy.cpp and MachineIdJob.cpp

Offline

#12 2021-12-22 20:03:07

loqs
Member
Registered: 2014-03-06
Posts: 18,987

Re: Slow systemd-random-seed and general entropy-handling

What if you compare two VM based installs rather than bare metal vs VM?  Virtual machines have more issues with entropy due to lack hardware available to extract any entropy from.

Offline

#13 2021-12-22 20:10:46

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,169

Re: Slow systemd-random-seed and general entropy-handling

If copies the entropy pool from a host, but that looks installation specific (target root)


But is the calamaris system a virtual machine?
(You're starting one on arch and the calamaris hostname looks suspicious and you're loading virtio_blk…)

Edit: curses at the lack of F5

Last edited by seth (2021-12-22 20:11:52)

Online

#14 2021-12-22 20:21:15

loqs
Member
Registered: 2014-03-06
Posts: 18,987

Re: Slow systemd-random-seed and general entropy-handling

If the system supports EFI then you could use systemd-boot to seed the kernel RNG early.

Offline

#15 2021-12-22 20:42:01

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

loqs wrote:

What if you compare two VM based installs rather than bare metal vs VM?  Virtual machines have more issues with entropy due to lack hardware available to extract any entropy from.

I just don't have now second drive to try calamares-installed Arch-based OS on my machine. But I tested it few weeks ago and similar time as I have today in VM (less than 100 ms). I'll try simple Arch install in the VM tomorrow and post the result here.

seth wrote:

Edit: curses at the lack of F5

Excuse me, I don't understand this part "curses at the lack of F5"?

loqs wrote:

If the system supports EFI then you could use systemd-boot to seed the kernel RNG early.

As I can notice, the majority of distributions uses Grub and Arch recommends it so I'd rather won't change well-supported piece of software. But ad experimentum would try and see if there's some difference.

Offline

#16 2021-12-22 21:01:24

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,169

Re: Slow systemd-random-seed and general entropy-handling

Excuse me, I don't understand this part "curses at the lack of F5"?

I opened this thread, started to look at you journals, started to write a response, looked at the calamares source, added that segment and pushed the "submit" button. Meanwhile loqs had sneaked in and already pointed out the VM situation.
Had I pressed F5 before posting, I'd have seen that.

I'll try simple Arch install in the VM tomorrow and post the result here.

calamares on bare metal would probably be more interesting…
What's

cat /sys/devices/virtual/misc/hw_random/rng_current

on the virtual system?

Online

#17 2021-12-22 22:09:07

Svitozhar
Member
Registered: 2021-03-13
Posts: 19

Re: Slow systemd-random-seed and general entropy-handling

Well, now I understand problem with my data. QEMU gives random beforehand, so VM has it plentiful and seeds start quickly.
And:

cat /sys/devices/virtual/misc/hw_random/rng_current  gives virtio_rng.0

Offline

Board footer

Powered by FluxBB