Analizzare le performance di avvio su Linux con Systemd
systemd, gestore dei servizi ormai uffficiale su molte distro Linux, ha alcuni strumenti utili per analizzare le performance.
Oggi vediamo systemd-analyze, che ci permette di analizzare il tempo di avvio.
Dovreste averlo già installato.
Nell'esempio più basico:
$ systemd-analyze
Startup finished in 1.886s (kernel) + 1.926s (userspace) = 3.812s
Che equivale a questo:
$ systemd-analyze time
Startup finished in 1.886s (kernel) + 1.926s (userspace) = 3.812s
Questo comando misura il tempo che ci vuole al sistema per avviare tutti i servizi, ma non tiene conto di quanto ci mettono ad essere completamente inizializzati.
Mostra, comunque, con buona approssimazione il tempo di avvio per arrivare al desktop (o alla schermata di login).
Se vogliamo andare più nel dettaglio:
$ systemd-analyze blame
4.424s updatedb.service
1.559s man-db.service
499ms NetworkManager.service
441ms lightdm.service
310ms logrotate.service
294ms dev-sda2.device
232ms run-media-matte-DATI.mount
195ms systemd-hwdb-update.service
158ms udisks2.service
123ms org.cups.cupsd.service
103ms systemd-journal-flush.service
...........................................
...........................................
...........................................
Come vedete qui abbiamo la lista (non completa per questione di spazio) di tutte le units ordinate per il tempo che ci è volute per inizializzarle.
Possiamo anche mostrare le units critiche:
$ systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
graphical.target @1.905s
└─lightdm.service @1.434s +441ms
└─systemd-user-sessions.service @1.427s +3ms
└─nss-user-lookup.target @1.886s
Come ultimo esempio, vediamo come esportarlo in SVG, in modo da vedere il tutto in formaot grafico:
$ systemd-analyze plot > report.svg
Potete poi elaborare il file con diversi programmi.
Enjoy!
linux systemd systemd-analyze svg
Commentami!