ablog

不器用で落着きのない技術者のメモ

メモ

テストコード

  • gettimeofday.c
#include <stdio.h>
#include <sys/time.h>

int main(void)
{
	struct timeval tv;
        while(1) {
                gettimeofday(&tv, NULL);
        }
	return 1;
}
$ gcc -o gettimeofday gettimeofday.c 
  • 実行する
for i in {1..6}
do
./gettimeofday &
done
  • /etc/default/grubGRUB_CMDLINE_LINUX_DEFAULT に vdso=0 追記
$ sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 nvme_core.io_timeout=4294967295 rd.emergency=poweroff rd.shell=0 vdso=0"
GRUB_TIMEOUT=0
GRUB_DISABLE_RECOVERY="true"
  • /boot/grub2/grub.cfg を生成
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
$ vi ~/.pgpass
#hostname:port:database:username:password
localhost:5432:postgres:postgres:postgres
$ chmod 600 ~/.pgpass
$ pgbench -i -s 10 -U postgres -h localhost -d postgres

モニタリング

$ vmstat -w 5
$ dstat 5
$ top -c
f P と WCHAN に移動して d, esc
$ sudo csysdig
$ sudo psn -G syscall,filename,kstack
$ xcapture -o .
$ vd 2020-12-15.15.csv