5 ms·
Exploring Linux command-line space time
- chrsw 3y agoThe GitHub repo link is broken
- M95D 3y agohttps://github.com/fabiensanglard/st https://github.com/fabiensanglard/st
- bschup 3y agoWould be curious to see how a "Hello World!" in Zig compares.
- fabiensanglard 3y agoWhy not run `st` on it and post the result here?
- metadat 3y agoThis is excellent across a few key dimensions. - 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.
- fsckboy 3y agothis is a small personal nit complaint, but increasingly I see "Linux command-line" used to refer to things which have nothing to do with command-lines per se, which to me suggests some cli-fu with p|pes || other tricky \\&\\&& if-fi $(things). 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
- perrygeo 3y ago"Exploring a C program's memory use over time, on Linux" would be more accurate. Nothing in this article deals with our three spatial dimensions, the typical use of the word "space".
- robbintt 3y agoFor software contexts, we refer to space as memory or overall storage depending on the architecture.
- perrygeo 3y agoYet when refering to both space and time, you should consider explicating that space = memory, time = time.
- sweetgiorni 3y ago> you should consider explicating that space = memory, time = 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 :) [0] https://en.m.wikipedia.org/wiki/Space_complexity https://en.m.wikipedia.org/wiki/Space_complexity
- 5- 3y ago> Following process/thread creation is done via netlink(7). 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.
- skitter 3y agoWow, Collect2 sounds kinda hacky based on the linked documentation¹: - 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 ¹: https://gcc.gnu.org/onlinedocs/gccint/Collect2.html https://gcc.gnu.org/onlinedocs/gccint/Collect2.html
- fabiensanglard 3y agoThank you for the explanation I did not have the courage to gather.
- ryukoposting 3y agoThe words "undefined reference to '__main'" give me war flashbacks.
- o11c 3y agoI'm pretty sure the documentation actually lies though. 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.
- skitter 3y agoThanks for the clarification. I was questioning my sanity, because collect2 as described in the doc sounds not just hacky, but also like a waste of compile time.
- throw16180339 3y agoIIRC collect2 is only required on a few weird platforms such as AIX.
- tripdout 3y agoCan you explain the AOSP compilation time? I don't understand how it can be 8 minutes - was that a clean build?
- mighmi 3y agoI like the blog style. Does anyone have a single CSS sheet with a similar style, instead of individual elements/lines all being spans with inline css?
- syndicatedjelly 3y ago> 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?
- mighmi 3y agoI've seen this design style before. I'm hoping there's an existing model to work from, e.g. how Tufte css spawned many individual layouts but instead inspired by a terminal.
- tetris11 3y agoHe talks about his theme here: https://fabiensanglard.net/html/index.html https://fabiensanglard.net/html/index.html
- tetris11 3y agoAbsolutely beautiful, sharp, expressive and minimal. Can be viewed on an e-reader. It looks like he made the change to this theme in 2018: https://fabiensanglard.net/bloated/index.html https://fabiensanglard.net/bloated/index.html
- skywal_l 3y agoGreat write up from Fabien as usual. 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
- imjonse 3y agoThe second example says "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.
- fabiensanglard 3y agoThank you for reporting this mistake. It is fixed now :) !
- cb321 3y agoSome terminals probably scroll sideways, but this `st` program seems to require running to completion. So, ^C does not give you any report at all. 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 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.
- readingnews 3y agoWhile I do like the idea, etc, and I know there are many examples of this, the actual name st is used by several other linux programs. Perhaps the author should consider calling it differently? For example (and I do have tape in most of my boxes, so st is installed on my main machine and my backup machine). st SCSI Tape device st simple terminal Just wondering how others handle conflicts like this too...