Exploring Linux command-line space time
fabiensanglard.net
fabiensanglard.net
- There is user code that needs to run before main. With C/C++ allowing separate compilation, the compiler invocation that creates the entrypoint doesn't know about all of these static constructors.
- Therefore Collect2 pretends to be ld; when invoked, it tries to call the real ld and examines its output
- It creates a c file with a table containing any constructor symbols it finds, then compiles that
- Finally it links the program again, together with the new object file
Yes, `collect2` exists, but with the existence of all the modern linker sections and scripts, it simply forwards everything to `ld` unchanged. There's no sneaky inspection, C code generation, or second linking pass.
FYI, you can also get a lot from the `time` command right now in your shell:
/usr/bin/time -v ls
Command being timed: "ls"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 100%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 2304
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 117
Voluntary context switches: 1
Involuntary context switches: 0
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0- Clear and concise code.
- Clear communication: writing, technical explanations, and conveyance of thought process.
- Thorough and systematic.
Major kudos to the author. It was a fantastic refresher on the mechanics of fork() for me!
This kind of article is the reason I troll HN so much. Occasionally gems pop up.
Perhaps we need some better vocabulary to separate these ideas, but the world of unix includes "shell" ideas, and their interplay with cli, there's ascii text ttys, there's ansi tty control and TUIs, and what this article is about, traditional unix userspace process-space, system calls, C-libs, compilers vs interpreters got skipped, but C-vs-Rust, just all without the overhead of GUI frameworks which brings a bit more clarity to timings but they don't absolutely, to do timings could be better to write a program to launch all these things and make sure that program is "sticky" in unix space-time.
This is a good article, but because I like to search for things again later, just as a headline I wouldn't really call this exploring Linux command-line space or time
That seems unnecessary. Even a layman knows that in the context of a computer, space != physical space. Most people think of disk space, but it can also refer to memory usage [0]. The meaning of the name was obvious to me after reading the first half of the first sentence of the article. I thought it was clever :)
FWIW, all these things date back to the ancient Usenet "RTFM" (where M = manual) which would undermine an expansion of "featured" in my view (since manuals are not "featured", like links in news aggregators). The other alternative Fs still work, though.
st SCSI Tape device
st simple terminal
Just wondering how others handle conflicts like this too...shouldn't ptrace with PTRACE_O_TRACEFORK (etc.) be enough (and much easier)?
the high overhead of strace the author notes is due to it doing PTRACE_SYSCALL, which is not needed here.
While it does RSS not Proportional Set Size (PSS) { arguably parsing /proc/PID/smaps_rollup should be added } and does not integrate program launch with tracking or use netlink to track making kids, an alternative that might interest some is a scrolling terminal kind of log report out of the Nim https://github.com/c-blake/procs .
pd -pBHd1 -f "%N %R %< %> %J %a" $(pf firefox)
or launch the program with `prog &` and use the shell `$!` to specify the PID or add -D'R<>J' to get differential reports (or many other things). On the plus side, this can track many other things besides just memory & kids { like IO in the above example, assuming your Linux has /proc/PID/io support compiled in }.You could always capture the output and feed it to some plotting program.
Does anyone have a single CSS sheet with a similar style, instead of individual elements/lines all being spans with inline css?
Sorry what are you asking?
It looks like he made the change to this theme in 2018:
"First allocate 1GiB, free it, then spawn a process which does the same but with 2GiB."
In the code it seems it is the parent process that does the second call too.
if (pid != 0) {
malloc_and_fill(1L << 31);
}
The result is not affected but the wording is not very clear I think.