Hacker Newsnew | past | comments | ask | show | jobs | submit | 0xdead's commentslogin

Totally agree. SWE is the only field where people can call them "Engineers" without having an actual engineering degree.


That's not true. Operating systems don't know if a process is a browser.


OS > Hey I need RAM

Browser > OK we can purge these tabs first

is how it should work. If the first step doesnt happen, its not clear if the second one should execute by itself. Id be much more concerned about background CPU usage. Eats battery, and actually slows the computer down.

That all said, its pretty clear that browsers are leaking RAM sometimes. I remember bed bath and beyond using 9 or 12GB of ram the other month.


> is how it should work.

That's not how it works. Browser might monitor free system memory actively and release memory if the system runs low, but at least Firefox doesn't do that.

There is no mechanism (in Windows, Linux) that allows the OS to notify applications of memory pressure or that allows the application to tell the OS that some allocations can be thrown out if need be. (Windows has a mechanism - MEM_RESET - that only works with paged out allocations)

Edit: Windows 10 (8?) actually expands on MEM_RESET with Offer/ReclaimVirtualMemory, but I kinda doubt browsers use this, because these have similar semantics to MEM_RESET (except they seem to work without paging, which is good). For an application that wants to cache not-well-defined amounts of data itself these might be very useful though, because you can make the data structure simple enough that it works with these.


https://dblohm7.ca/blog/2015/07/28/interesting-win32-apis/ notes that Windows has the required APIs, and that Firefox already supports handling memory pressure notifications on non-Windows platforms. Not sure how up-to-date this information is.


> ...that allows the OS to notify applications of memory pressure or that allows the application to tell the OS that some allocations can be thrown out if need be.

There are mechanisms for both of these in up-to-date Linux - pressure stall information and volatile ranges, respectively.


MADV_FREE didn't work properly until fairly recently, though, because it behaved like Windows' MEM_RESET. AIUI MADV_FREE is not intended for ranges that you actually want to work with (i.e. you want to keep the data, not just the virtual addresses), but rather as an optimization for allocators.


Firefox does have a mechanism for reducing memory pressure, there's a button for it in about:memory. I can't guarantee that this flow actually happens upon low memory states on Windows etc but it wouldn't be hard to at least hack it together. Monitoring available memory (say, on a timer) is not a difficult thing to do on Windows - it would just be difficult to make it completely robust.


Well it definitely doesn't work on Linux, at least not automatically.


It's important to specify your test scenario here and the behavior you expect, as it's a known issue in general that Linux behaves poorly under OOM conditions. It's not necessarily Firefox specific.

If all of my memory is "in use" but half of it is cached file pages, should Firefox compact its heap and evict cached images? What if all of my memory is spoken for but a bunch of it isn't actually committed, due to overcommit?


Those aren't interesting questions tbh. Obviously most of the time the page cache grows to use all memory, that's the whole point of having it (using all memory that is not committed to applications as a disk cache). Overcommit obviously doesn't create memory pressure because it only exhausts address space, not memory (physical memory + swap). The relevant question is how the system behaves if it needs to allocate pages but can't find any clean (just throw'em out) or unused pages. Linux, and to a lesser degree, Windows start to thrash heavily in these scenarios. I've never seen e.g. Firefox unload a tab when this happens, regardless of OS.


Another strategy is:

Browser> So this memory here, I don't really care if you swipe it in the future.

(later)

OS> Yum yum

(later)

Browser> Oh, that buffer is empty, let me fill it again.

Firefox uses it, IIRC, for decoded image buffers.

https://searchfox.org/mozilla-central/source/memory/volatile...


NOT washing hands is important too. Letting a little bit of bacteria into your body strengthens the immune system. It is important to sometimes let your kids pick up food from the floor and eat it.


If by "write kernel/bare-metal level code" you mean blinking an LED, sure. Writing low level doesn't have to do anything with C or any language for that matter. It requires a deep understanding of the architecture that you're writing code for. Junior JS devs don't have enough experience or the skills to do that.


I have an anecdote to share. I work in embedded space for a living. A web developer (which is quite funny) from another team somehow convinced our director to use Rust for a critical process that involved a lot of concurrent processing. Ok, I said, and began developing that process in Rust.

I estimated that it took me about 10x the time to implement something than it would have taken if I did that in C. The reason for that could definitely be because I'm not a Rust expert at all. That's fine though because I will happily invest more time in programming if it saves me hours of debugging later. Plus, the claim that "if it compiles, it works" was enough for me to fight the compiler for hours if it gives me no trouble during runtime.

Fast forward a week, we have that binary deployed to a non-critical set of our field devices. A few days later, we get reports of that particular binary crashing. I logged into one of those devices and fetched the logs. The binary was reporting a panic on an MPSC channel's tx send. There was nothing useful in that error message that would point me to the root cause. I had no tools to attach to a running process because I'm on a device with an ancient kernel.

To fix the situtation "temporarily", because the customer is getting infuriated, we redeploy our old C binary. It has been there since. I basically now say "fuck off" to anyone who tells me to use Rust because it doesn't work if it compiles.


"If it compiles it works" is just not true, just a very bad description for a true phenomenon. If there weren’t people repeating that seriously, you’d be attacking a strawman. People do say that, but that’s on those people, not Rust.


Why are you being downvoted?



Thank you for making this a productive space. You are getting paid for this right?


Yes. Actually that fact is more interesting than it looks.

It's all of our good fortune that it's in YC's interests to fund HN just as it is, with the moderators' primary job being to keep it interesting and hopefully keep the community happy. If HN were a startup, we would have to play the growth-hacking game. If it were the media property of some larger corporation, some manager would eventually put a monetization squeeze on it. Either of those tactics would ruin this place, whether or not they succeeded.

YC doesn't need us to do such things because a happy HN is the most valuable-to-YC HN. It's basically an accident—a dual accident of how YC's business works and how things historically developed—that we ended up in that spot. It's a special position to be in, and our first responsibility is to preserve it. Hence our motto, Move slowly and preserve things.


Perhaps because he's somewhat implying that other languages aren't doing this, but C# is actually kind of late to the game here.


It's not that late to the game, considering its paradigm. How many other large object-oriented imperative languages have it? Not C++ or Objective-C or Java. Kotlin has destructuring, but not full pattern matching.


Please stop spreading misinformation outside Twitter, where Indian media is basically rampant, to communities like HN.


Perfect usage of the title to get on HN frontpage.


I really expected this to be another aggressive Rust marketing peice at first


Well, thanks to Rust's more powerful macro system, I'm sure someone could butcher it even more than the C-PreProcessor lets me do to C, here.


The reasoning of the author is totally flawed. If you feel like a noob locally, there is no guarantee that you will not feel like a noob globally too. In other words, it's not always good to feel like a noob.


It's about time we had another fad.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: