by seanwilson · 9y ago · 0 comments
A few 100MB of RAM or disk space extra is a nonexistent issue as well to typical users. I know some developers get very offended at a program using a bit more RAM or CPU than it should be but developer efficiency is more important most of the time so it's a completely rational trade-off. Some of these apps wouldn't exist at all if everyone insisted on native everywhere.
It's all just my opinion as well, but approaches like Electron are very efficient at creating good cross platform apps. Developing and maintaining several native apps is a huge resource drain when most users aren't going to care.
In fact, every time you hear a non-programmer complain about their computer it's usually not a hardware, but a software like electron that's ruining their experience.
OSes have started to add application profiling recently, so once every mainstream OS starts loudly pointing a finger at offensive applications (like "uninstall Spotify/Slack and you'll get 4 more hours of battery life"), you'll start hearing complaints from non-programmers.
Actually, Task Manager showed 90% of my 8Gb ram being utilized and caching to disk constantly with most of the ram and CPU being hogged by eight(!) Slack threads. This is with Slack minimized and sitting idle.
The fix was to replace the Slack/Electron app and use the browser version instead. That solved it.
Electron is a super cool piece of tech that could enable all kinds of great app development but needs to go on a serious diet first.
I can get literally double the battery life on my Thinkpad if I close Slack, Messenger for Desktop, Atom/VSCode. Chrome uses multiple extra watts of juice in powertop than Firefox, and every Electron.JS application is really just a Chrome instance.
Slack uses 400-500MB of memory. That's 15% of my RAM. For a chat application. Every Electron app is in this range. None share a runtime or memory footprint.
Believe it or not, not everyone has 16GB of RAM. This level of inefficiency is utterly inexcusable.
Code Helper is from VSCode. VSCode, Evernote and Slack are all completely idle right now. I don't think they should be using any memory at all. Especially not over 700 MB. I don't even understand how they could possibly be using that much memory.
Is it just memory leaks?
Fact is if the ram it available, an app should cache as much as possible. It has no idea what you'll need next, so better it use a free resource to reduce latency.
You cannot think of an app in just terms of the text it handles but also window pixmap data.
There's a problem, though: it doesn't work that way.
The size reported by Windows is (if I'm not mistaken) the committed heap size of the program. Unless the application actively surrenders allocated pages back to the OS (and hint: no application does that), that memory is committed.
Edit: to add some color: when a program calls malloc, memory is allocated from pools inside the process itself. If no memory is available in the internal pool the allocator will call out to the OS for additional pages (in the Unix world this is a call to sbrk). When free is called, memory is returned to the internal pool but is not surrendered back to the OS and thus remains committed to the process. Actually reducing the committed heap size once again requires an explicit call to the OS (e.g sbrk).
Of course it may be swapped out by the OS, but that just means slow disk I/O when that application comes to the foreground or accesses those swapped pages (which presumably contains the precious cached data you refer to).
Should the OS use memory to cache transient data? Certainly. OSes typically contain logic to throw away those caches if memory is needed.
But applications that do this without intelligently surrendering cached pages back to the OS when memory is low (as an OS does with its own caches) just put that much more memory pressure on the overall system itself. And I've never heard of an application that does this. Certainly I've seen no evidence that Electron is that sophisticated in its memory management, though I'm happy to be proven wrong.
If you "Ask HN" for opinions how can you take those opinions with a grain of salt?
Surely if you can't trust HN commenters then Ask HN is a waste of time.
Spotify is also a bit slow and clunky, but it's not too bad. There's no reason why they couldn't aggressively pre-fetch a lot of pages to make the UI feel snappy. E.g. "Browse", "Radio", and all the tabs under "Your Music". And if you're playing a track, just pre-fetch the artist and album pages. If I can click something in the UI, it should already be loaded.
But even when stuff is already cached, the UI takes about 500ms to render the new page. Sometimes it's only a few hundred ms, but there's a nasty black flash before it renders. the new page. There's really no reason for that either. There are so many ways you could speed that up to make it instant. For example, just render everything above the fold, then add the rest of the content later.
Spotify's internet connection detection drives me crazy sometimes. Sometimes it takes 20-30 seconds to get back online, but I don't think that's related to JS. Their polling interval is just too long. There's no reason why they couldn't poll once per second and come back online immediately.
I can't help but be reminded of the "VS Code uses 13% CPU when idle due to blinking cursor rendering" post that was on HN earlier last week, referring to the following issue:
Well there isn't exactly a choice of what spotify client to compare it to is there - so users have to use it by default rather than be 'happy' about it.