6 ms·
Pictures of a working garbage collector
- amayui 4y agoThis is very insightful! Good to see some low-level perf benchmarking as well.
- Gravityloss 4y agoI was expecting to see something like what you would see on windows when running defrag....
- dayjaby 4y agoI expected to see one of the big orange things you see on the street
- gus_massa 4y agoThere is another site with graphics linked at the bottom of the article https://spin.atomicobject.com/2014/09/03/visualizing-garbage-collection-algorithms/ https://spin.atomicobject.com/2014/09/03/visualizing-garbage...
- kaba0 4y agoWow, that’s a very cool post!
- deleted 4y ago[deleted]
- raverbashing 4y agoAt a given point it does look like ARC might be the easiest solution (sure it has problems, but they're a subset of GC's problems) Edit: this link posted by another commenter gives a nice overview of the tradeoffs between the methods and it has very nice graphs to boot https://spin.atomicobject.com/2014/09/03/visualizing-garbage-collection-algorithms/ https://spin.atomicobject.com/2014/09/03/visualizing-garbage...
- tsimionescu 4y agoARC's problems are orthogonal to tracing/copying GC's problems. They are fundamentally different paradigms, since ARC mostly pays a cost for memory which is no longer in use, while tracing/copying GC pay a cost for memory which is in use. That is, with ARC, the more garbage you generate, the more work will be spent on the GC vs normal program flow. In contrast, with tracing/copying, you can generate as much garbage as you want, without affecting GC time; but, the more memory you actually use, the more time you will spend in GC.
- kaba0 4y agoARC (if ‘A’ means atomic) is simply not a good fit for modern hardware. With traditional tracing GCs you get blazing fast allocation and get to amortize the cost of deallocation, while you pay a price for ref counting on every usage (or at best on almost every usage with a good compiler).
- magicalhippo 4y ago> ARC (if ‘A’ means atomic) A is for Automatic, as in the compiler adds the calls needed to manage the reference counting. If the language and compiler can guarantee a reference is strictly contained within a thread, it doesn't have to be atomic. Usually that is not the case, so atomic operations are used.
- rwmj 4y agoYou need more than that. Reference counting amplifies reads into writes. To ameliorate that (somewhat) you need to keep the references separate from the data (a particular problem with Rust). Otherwise you end up with lots of writes scattered all over memory, causing false sharing and lots of unnecessary communication over buses between your cores. One way to do this is to keep the references together in separate cache lines or pages, away from the data. And this only partly alleviates the problem.
- mark_undoio 4y agoGood to see GDB's watchpoints (https://sourceware.org/gdb/download/onlinedocs/gdb/Set-Watchpoints.html https://sourceware.org/gdb/download/onlinedocs/gdb/Set-Watch...) get a mention. Often called Data Breakpoints in IDEs (which then, confusingly, often also use "Watch" for a different concept - argh). Watchpoints, when they're suitable, are an incredibly powerful way to query your program's runtime behaviour (When does this happen? Why does this value end up here?) instead of stepping through and printing things / logging stuff. They also fast, provided you watch values suitable for the CPU's logic to handle them directly. They need to be small-ish and located in memory for hardware support to handle it, otherwise GDB needs to single step. (the `-l` flag is also important here and even less well known - it tells GDB you really care about the memory address the expression is stored in, not the expression itself)
- deleted 4y ago[deleted]
- acqbu 4y agoDid anyone else click on this expecting to see a photo documentary about the life of a bin/waste collector?
- jb1991 4y agoif you google image search "garbage collector" as I just did, you will in fact see photos of these actual, pivotal, working members of our society.
- hardware2win 4y agoI did, but domain made me think about oil spill
- aitchnyu 4y agoI expected to see a ship cleaning up a garbage island in the ocean.
- rightbyte 4y agoI was expecting to see some sort of heat map gif of a GC filling and trashing slots and was kinda disappointed.
- thinking001001 4y agoI was also expecting to see a physical machine in action and was disappointed
- uncletammy 4y agoI was expecting to see a man in a dirty boiler suit and was pleasantly surprised. A thousand years from now when they're digging up texts and artifacts from this period, there's likely going to be a lot of confused academics.
- drmeister 4y agoGet `udb` - the reversible/time-traveling debugger from Undo. I don't own any stock - I love their product. You can run your code within it, hit an error, set a watch-point, reverse-continue to where the watch-point memory was changed and then check the stack. udb will turn brain-melting, blood-freezing memory bugs into trivial problems that you can solve in a few minutes.
- wooosh 4y agoA similar project is rr[0], which is freely available. Like you said, I find that reversible debuggers are a huge improvement over regular debuggers because of the ability to record an execution and then effectively bisect the trace for issues. [0]: https://rr-project.org/ https://rr-project.org/
- dleslie 4y agogdb has had reversible debugging since release 7, in 2009. What does udb offer that it lacks?
- leni536 4y agoI'm not familiar with udb, only with rr. Compared to rr, gdb's recording for reversible debugging is tremendously slower. However rr has strict requirements for the CPU (didn't work on AMD, the last time I looked) and requires some permissive perf_event_paranoid setting to run. In my experience rr's recording is around x2 slower for single threaded programs than running the program on its own. I think featurewise they are in parity. I heard that udb is like rr, but better on some fronts (except price and software freedom).
- mark_undoio 4y ago(I work for Undo) > gdb has had reversible debugging since release 7, in 2009. What does udb offer that it lacks? GDB's built-in reversible debugging is cool (and it's helped raise awareness) but it doesn't scale well. We build on the same command set and serial protocol that GDB defined - UDB is GDB but with additional Python code hooking it up to our separate record/replay engine. For UDB, I'd say we offer: 1. Performance & efficiency (orders of magnitude faster at runtime and lower in memory requirements). 2. Recordings can be saved to portable files (share with colleagues, receive from customers, etc). 3. Library API so applications can self-record with control of when to capture and save. 4. Wider support of modern software (proactively tracking modern CPU features, shared memory and device maps, etc). 5. Correctness (in the past we've found the reverse operations in GDB don't have as strong semantics as we'd hoped, though I'd also be happy to be wrong here) FWIW, rr (https://rr-project.org/ https://rr-project.org/) also offers many similar benefits over GDB's built-in system (though not the library API in point 3) but with differences in what CPUs / systems are supported, ability to attach at runtime, etc. If you're looking for an open source solution, I'd choose rr over GDB's built-in approach.
- mark_undoio 4y ago@chubot (author) I'm curious what the debug experience is like. It looks like you're generating C++ code that maps pretty closely onto your statically typed Python code - is it straightforward to say "aha, it's that variable in C++ so it'll be the same name in Python"? I'm wondering if it's possible to put some directives into the generated C++ code that would map its debug info directly back to source lines in the Python - I can't find any docs to confirm my feeling this should be possible. Edit: Maybe this? https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html https://gcc.gnu.org/onlinedocs/cpp/Line-Control.html
- chubot 4y agoOh yes I've been wondering about that too. I think what tipped me off about the feature is that I debugged some code using yacc, and it jumped right to the .y file. So yacc does that pretty effectively. So I think that would be cool, but I don't usually use a debugger in Python (or even C++ -- I tend to write small programs using shell as the "REPL"). Oil is extremely test-driven and shell's stdin/stdout type interfaces means it's pretty easy to exhaustively test. Examples: https://www.oilshell.org/release/0.13.1/test/spec.wwz/survey/osh.html https://www.oilshell.org/release/0.13.1/test/spec.wwz/survey... The GC is the one case we have where that kind of testing/debugging doesn't suffice! So I started watching the CppCon videos on debuggers a couple years ago and found some good talks :)