6 ms·
No no no. Garbage collection has some mandatory overhead. Sure you can do an amortised analysis. Just like pushing into the back of a C++ vector is O(1) amortis
by Kenji 10y ago
No no no. Garbage collection has some mandatory overhead. Sure you can do an amortised analysis. Just like pushing into the back of a C++ vector is O(1) amortised... except that every once in a while, the entire vector has to be copied over into a larger block of memory, costing O(n) for that particular operation. You can mislead people, but you cannot trick the computer and hard realtime constraints.
- rwmj 10y agoDo you think your malloc/free (or kmalloc) implementation has no non-deterministic delays? I hate to break it to you, but malloc/free is not magical and O(1). It's complex, even reaching into the cache and operating system, and non-deterministic.
- monocasa 10y agoYep, hard real time code tends not to malloc and free for that reason. Most hard real time systems only allow dynamic memory management at system initialization, not at normal runtime.
- Kenji 10y ago>I hate to break it to you, but malloc/free is not magical and O(1). Trust me, I know more about it than I'd like to. I work on embedded software with hard realtime constraints and we had to remove all malloc/free calls from the critical paths. What I don't like is people claiming garbage collection is free. It annoys me to no end. Garbage collection comes at a clear cost and you need to make a cost/benefit analysis. For your average chat application, this is okay. For video games, it might be, but it's probably already noticeable. For anything remotely realtime, forget garbage collection.
- nickpsecurity 10y ago"For anything remotely realtime, forget garbage collection." Or just use real-time, garbage collection if its costs are acceptable: https://news.ycombinator.com/item?id=14108543 https://news.ycombinator.com/item?id=14108543 At least one is deployed in DO-178B-certified systems in industry that require highest confidence and testing. That's as opposite of your implication as possible.
- wtetzner 10y ago> Garbage collection has some mandatory overhead. Yes, but perhaps it doesn't have to be an unpredictable amount of overhead.
- Kenji 10y agoEverything is predictable, given enough information. Except for Laplace's Demon, that's not possible. Aah, I love my daily fix of pedantry, which I reliably find on hackernews.
- gmfawcett 10y agoKnocking down strawman arguments isn't pedantry, and there's no need to be rude. You were replying to a comment that said GC could have deterministic overhead; and you replied that "no, GC has mandatory overhead" -- which is a different concern. Wtetzner just pointed out, rightly so, that mandatory doesn't mean non-deterministic.
- nickpsecurity 10y agoExactly. That commenter and some others in threads like these are going out of their way to ignore all evidence that deterministic GC's exist with costs that are acceptable for various types of applications. Their myth needs to disappear so real-time GC's get more attention by those who might use or improve on them.
- Kenji 10y agoI meant it had a mandatory nondeterministic overhead. I even made an example with the nondeterministic overhead of C++ vectors. Come on, now you're really putting effort into misunderstanding me.