What does “RL:” stand for? The program is called rusage so if there was going to be any prefix on these lines I would have expected “RU:” or maybe “rusage:”.
I tried to see if there were any hints in the git history. This prefix was added in https://github.com/jart/cosmopolitan/commit/cc1920749eb81f346badaf55fbf79620cb718a55. This commit touches over a thousand files. The description of this commit talks about TLS and makes no mention of rusage. It appears that a fairly large rewrite of rusage somehow sneaked its way into this otherwise unrelated commit. So that’s a dead end.
What size of buffer is std::ifstream using? Does increasing that make any difference at all? If the goal is to reduce system call overhead it would seem like an easy way to do that is to reduce the number of system calls by making each one read more data.
an i/o system call that happens magically as a page fault is still a system call.
Is it still a system call though? A “context switch”, sure. But I wouldn’t think of this as a system call myself.
Is it still a system call though? A “context switch”, sure. But I wouldn’t think of this as a system call myself.
It is not an explicit system call, but I would expect a fault to be as expensive as a system call: your CPU state has to be preserved, we have to go to another privilege level which means dumping out all the speculation stuff and doing all the other expensive mitigation for the sieve-like nature of modern CPUs, and you’re then in the kernel futzing with data structures and potentially arranging disk I/O and putting the thread to sleep until that comes back.
The only time mapping memory is cheaper is when there are enough spare resources (address space in the user process, physical RAM for the page cache in the kernel) to have already mapped the things you need – and the kernel has to have been smart enough to read it in the background on its own and arrange the mappings in advance. But then who gets billed for that background work is always an interesting (and frequently unanswered) question in models like prefetched mappings or even the newer completion ring style APIs.
It’s awesome that the binary can run on a whole bunch of platforms without changes but I’m still confused why it has .com in its name. If anything, it seem to be the opposite of .com format.
Author here. It’s because, in order to run on Windows, the file needs to end with either .exe or .com, and I chose the latter because I didn’t want UNIX users to think it’s a Windows-only program. Com binaries are basically flat executables from the DOS days, and rusage.com holds true to that tradition, because it’ll boot from BIOS, and furthermore if you load it into memory and jump the instruction pointer to the first byte of the executable (the MZ) then it’ll still run fine on many operating systems.
That is one of the things I intensely dislike in Linux (though edged out by the lack of SIGINFO): BSD time has supported rusage statistics since the early 90s and 4.3BSD-Reno
> /usr/bin/time -l /bin/echo "hi"
hi
0.00 real 0.00 user 0.00 sys
1441792 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
165 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
0 voluntary context switches
3 involuntary context switches
3127981 instructions retired
1878160 cycles elapsed
918144 peak memory footprint
Yet 30 years later GNU time still doesn’t support it.
ZSH time also supports rusage statistics, but that requires messing with TIMEFMT which is not a great UI.
What does “RL:” stand for? The program is called
rusage
so if there was going to be any prefix on these lines I would have expected “RU:” or maybe “rusage:”.I tried to see if there were any hints in the git history. This prefix was added in https://github.com/jart/cosmopolitan/commit/cc1920749eb81f346badaf55fbf79620cb718a55. This commit touches over a thousand files. The description of this commit talks about TLS and makes no mention of rusage. It appears that a fairly large rewrite of rusage somehow sneaked its way into this otherwise unrelated commit. So that’s a dead end.
What size of buffer is
std::ifstream
using? Does increasing that make any difference at all? If the goal is to reduce system call overhead it would seem like an easy way to do that is to reduce the number of system calls by making each one read more data.Is it still a system call though? A “context switch”, sure. But I wouldn’t think of this as a system call myself.
It is not an explicit system call, but I would expect a fault to be as expensive as a system call: your CPU state has to be preserved, we have to go to another privilege level which means dumping out all the speculation stuff and doing all the other expensive mitigation for the sieve-like nature of modern CPUs, and you’re then in the kernel futzing with data structures and potentially arranging disk I/O and putting the thread to sleep until that comes back.
The only time mapping memory is cheaper is when there are enough spare resources (address space in the user process, physical RAM for the page cache in the kernel) to have already mapped the things you need – and the kernel has to have been smart enough to read it in the background on its own and arrange the mappings in advance. But then who gets billed for that background work is always an interesting (and frequently unanswered) question in models like prefetched mappings or even the newer completion ring style APIs.
Lovely utility, thanks for sharing!
It’s awesome that the binary can run on a whole bunch of platforms without changes but I’m still confused why it has
.com
in its name. If anything, it seem to be the opposite of.com
format.Author here. It’s because, in order to run on Windows, the file needs to end with either .exe or .com, and I chose the latter because I didn’t want UNIX users to think it’s a Windows-only program. Com binaries are basically flat executables from the DOS days, and rusage.com holds true to that tradition, because it’ll boot from BIOS, and furthermore if you load it into memory and jump the instruction pointer to the first byte of the executable (the MZ) then it’ll still run fine on many operating systems.
That is a much more interesting explanation, that what I foolishly thought was some sort of internet domain reference! 🤦
That is one of the things I intensely dislike in Linux (though edged out by the lack of SIGINFO): BSD
time
has supported rusage statistics since the early 90s and 4.3BSD-RenoYet 30 years later GNU time still doesn’t support it.
ZSH time also supports rusage statistics, but that requires messing with
TIMEFMT
which is not a great UI.Has anyone tried to add the functionality to GNU time?
Why does it matter so much? Can’t you just provide your own implementation on whatever machines you use?
I’m getting a
SSL_ERROR_BAD_CERT_DOMAIN
error that’s causing Safari, Firefox, and Chrome to flag the page as unsafe.