-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not query CPU data when querying process data #845
Conversation
I just tested this and it made a different binary but same behavior as 0.11.2 of spending 0.6s waiting on my 32 thread CPU. How can I confirm with cargo that the correct version of the dependency is being pulled? (Edit: I
I tried spawning 10k I'm a bit confused because when I tested 100k |
Hm. Just to ask a silly question -- when you pipe to "delta" it's definitely picking up the intended executable? |
Yes confirmed. |
confirmed, here's the compare result (a delta version do
sleep 1
time /tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml.bak Cargo.toml > /dev/null
done
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.04s user 0.01s system 41% cpu 0.135 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.01s system 41% cpu 0.136 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.01s system 54% cpu 0.106 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.06s user 0.00s system 100% cpu 0.058 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.01s system 41% cpu 0.136 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.06s user 0.00s system 61% cpu 0.093 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.01s system 47% cpu 0.118 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.01s system 40% cpu 0.138 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.00s system 39% cpu 0.145 total
/tmp/delta-0.11.2-x86_64-unknown-linux-gnu/delta Cargo.toml 0.05s user 0.00s system 41% cpu 0.136 total release build from for (( c=1; c<=10; c++ ))
do
sleep 1
time /tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > /dev/null
done
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.04s user 0.02s system 42% cpu 0.140 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.01s system 42% cpu 0.138 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.00s system 40% cpu 0.142 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.01s system 45% cpu 0.125 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.00s system 50% cpu 0.112 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.00s system 101% cpu 0.056 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.06s user 0.00s system 57% cpu 0.107 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.00s system 41% cpu 0.136 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.04s user 0.02s system 63% cpu 0.089 total
/tmp/branch-sysinfo-processrefreshkind/delta Cargo.toml.bak Cargo.toml > 0.05s user 0.01s system 40% cpu 0.139 total as a compare, here is my patched version (binary here: https://github.com/ttys3/delta/releases/tag/0.11.2) time cost: result: the code: https://github.com/ttys3/delta/tree/sysinfo-v0.19.2-linux-perf ❯ for (( c=1; c<=10; c++ ))
do
sleep 1
time /tmp/delta Cargo.toml.bak Cargo.toml > /dev/null
done
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.02s system 77% cpu 0.085 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.06s user 0.01s system 80% cpu 0.078 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 82% cpu 0.075 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.06s user 0.00s system 81% cpu 0.077 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 101% cpu 0.061 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 80% cpu 0.079 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.06s user 0.01s system 81% cpu 0.076 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 73% cpu 0.085 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 82% cpu 0.076 total
/tmp/delta Cargo.toml.bak Cargo.toml > /dev/null 0.05s user 0.01s system 82% cpu 0.075 to |
with munmap(0x7f732f45f000, 36864) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(7) = 0
read(5, "diff --git a/Cargo.toml.bak b/Ca"..., 8192) = 827
write(6, "\n", 1) = 1
write(6, "\33[", 2�[) = 2
write(6, "34", 234) = 2
write(6, "m", 1m) = 1
write(6, "Cargo.toml.bak \342\237\266 Cargo.toml", 31Cargo.toml.bak ⟶ Cargo.toml) = 31
write(6, "\33[0m", 4�[0m) = 4
write(6, "\n", 1
) = 1
write(6, "\33[", 2�[) = 2
write(6, "34", 234) = 2
write(6, "m", 1m) = 1
write(6, "\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224\200\342\224"..., 240────────────────────────────────────────────────────────────────────────────────) = 240
write(6, "\33[0m", 4�[0m) = 4
write(6, "\n", 1
) = 1
mmap(NULL, 675840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f732e8ac000
openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = 7
read(7, "cpu 143738 231 45028 994317 107"..., 8192) = 3610
close(7) = 0
openat(AT_FDCWD, "/proc/stat", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY|O_CLOEXEC) = 8
statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "processor\t: 0\nvendor_id\t: Genuin", 32) = 32
read(8, "eIntel\ncpu family\t: 6\nmodel\t\t: 1", 32) = 32
read(8, "58\nmodel name\t: Intel(R) Core(TM"..., 64) = 64
read(8, "g\t: 10\nmicrocode\t: 0xea\ncpu MHz\t"..., 128) = 128
read(8, "\t: 0\ninitial apicid\t: 0\nfpu\t\t: y"..., 256) = 256
read(8, " arch_perfmon pebs bts rep_good "..., 512) = 512
read(8, " hwp_notify hwp_act_window hwp_e"..., 1024) = 1024
read(8, "cpuid aperfmperf pni pclmulqdq d"..., 2048) = 2048
read(8, "1gb flexpriority tsc_offset vtpr"..., 4096) = 3289
read(8, "processor\t: 5\nvendor_id\t: Genuin"..., 807) = 807
read(8, "i ssbd ibrs ibpb stibp tpr_shado"..., 8192) = 672
read(8, "", 7520) = 0
close(8) = 0
read(7, "cpu 143740 231 45028 994325 107"..., 8192) = 3610
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3900006\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3900000\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3893884\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu3/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3899665\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3899951\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/cpu5/cpufreq/scaling_cur_freq", O_RDONLY|O_CLOEXEC) = 8
statx(8, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=4096, ...}) = 0
lseek(8, 0, SEEK_CUR) = 0
read(8, "3900023\n", 4096) = 8
read(8, "", 4088) = 0
close(8) = 0
close(7) = 0
getpid() = 100005 |
Thanks! Hm. If anyone has time to help find what I've done wrong, the next step could be to add print statements to the 3rd party library and alter the entry in Cargo.toml to take the library from local disk. |
OK I think there was a mistake in the sysinfo PR that I missed when I reviewed it. I've updated this branch, although at this point we are pointing at a temporary branch of the upstream that isn't passing tests yet :) |
Hmm I tried pulling and building but
|
@unphased that may have been because the delta was pointing at a feature branch in the upstream repo. The sysinfo author is working on this issue and this branch is now pointing at his latest fix. |
Success:
git diff/log are finally snappy again! |
Great, thanks @unphased! |
the old commit hash is gone. now is this one( GuillaumeGomez/sysinfo@67a586c)
then compiled and tested. the speed comes back again! Cheers for (( c=1; c<=10; c++ ))
do
sleep 1
time ./target/release/delta Cargo.lock Cargo.toml > /dev/null
done
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.06s user 0.01s system 102% cpu 0.064 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.07s user 0.00s system 45% cpu 0.156 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.05s user 0.02s system 103% cpu 0.064 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.06s user 0.01s system 103% cpu 0.064 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.07s user 0.00s system 102% cpu 0.065 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.05s user 0.01s system 103% cpu 0.064 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.06s user 0.01s system 103% cpu 0.065 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.07s user 0.00s system 102% cpu 0.065 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.05s user 0.01s system 103% cpu 0.064 total
./target/release/delta Cargo.lock Cargo.toml > /dev/null 0.06s user 0.01s system 102% cpu 0.065 total |
Perfect, thanks for the confirmation. I'll merge the PR then. |
commit d647acfbf216848a8237e1f9251b2c48860a547f Merge: 989ac6c 67a586c Author: Guillaume Gomez <guillaume1.gomez@gmail.com> Date: 2 hours ago Merge pull request #636 from GuillaumeGomez/update-if-needed Only update processors if needed
395a85f
to
7be04e5
Compare
I'm merging this branch now. It currently has a Cargo.toml dependency pointed at an explicit commit SHA on Github rather than a released crates.io package version. Is it a sin to perform a delta release in that state? |
@th1000s @ttys3 This branch uses the (unmerged and unreleased) branch of sysinfo from GuillaumeGomez/sysinfo#634 to avoid querying for CPU data when we query for process data. The commit here is on top of @th1000s's PR #841 which reduces the number of processes queried.
Can either of you confirm that this commit fixes the CPU slowness problem, and indeed that there are no slowness problems at all on this branch? cc @unphased @infokiller
Fixes #839
Ref GuillaumeGomez/sysinfo#632