Hacker News new | ask | show | jobs
by d3Xt3r 25 days ago
> In our Linux test it opens in under a second and uses about 200 MB of idle RAM

Is it just me or does anyone else feel that 200 MB is a lot for a native chat app written in Rust, that's essentially a remote interface for the WhatsApp on your phone?

I remember back in the day, apps like Miranda IM (and early versions of Trillian) used only digits of RAM, even when you had multiple plugins talking several protocols at the same time, whilst having a ton of advanced features not found in WhatsApp. Yes I get that times have changed and software has become bloated etc, but 200 MB still feels a bit too much.

8 comments

Almost all of those 200MB will be system libraries for rendering and GPU buffers.
200MB of GPU buffers? Even so would they show up in RAM?
> Is it just me or does anyone else feel that 200 MB is a lot for a native chat app written in Rust ...

That was my first thought. But considering it as a significant improvement from > 1 GB, I guess it is what it is.

> I remember back in the day, apps like Miranda IM (and early versions of Trillian) used only digits of RAM ...

Sadly this was true for many apps.

> Is it just me or does anyone else feel that 200 MB is a lot for a native chat app written in Rust, that's essentially a remote interface for the WhatsApp on your phone?

> I remember back in the day, apps like Miranda IM (and early versions of Trillian) used only digits of RAM, even when you had multiple plugins talking several protocols at the same time

I think what's happening in the second one is that because you're using the native OS toolkits a bunch of stuff is shared, whereas with these "self-contained" "native"-y apps you end up having to load up the whole world and aren't sharing things with everything else

I'd love to be proven wrong but I feel like if you use e.g. Qt you're gonna have to hold onto a bunch of stuff that you wouldn't if you were "just" using OS-native stuff (though maybe that gets shared if you're using the exact same version? Is there something that can be done in this space?)

As an additional data point, I recently vibed an egui wrapper around a library I wrote for mod management for a game, and testing it out now, it idles at 92 MB. This implies to me that at least half of the overhead is probably not from the gui framework, but I also don't know how much effort they spent trying to optimize it; I didn't try to optimize my vibed GUI app at all, but I did hand-write the library that it uses for file management, state tracking, etc., and I tend to go out of my way to try to avoid unnecessary allocation in my Rust code. I don't know how much of the memory usage is essentially required overhead or from other dependencies for non-GUI parts of the app, but my instinct is that there's probably a bit of optimization that can be done. I don't think it's crazy for them not to have spent the effort on trying to do that yet though (or potentially even at all, if it's efficient enough for their own personal use).
With Qt, on my KDE Linux, a simple app usually stays well below 60 to 100 MB.
Just tested, mine is 400MiB RSS. I was expecting less :-/
I just tested a simple Qt app on my Linux KDE Neon and it consumes just ~32.3 MB RSS. Simple Qml app memory consumption is ~120.4 MB RSS.

$ ps -o pid,rss,command -p $(pgrep -f SimpleQtApp)

PID RSS COMMAND

1471929 33052 ./SimpleQtApp

$ ps -o pid,rss,command -p $(pgrep -f SimpleQmlApp)

PID RSS COMMAND

1478335 123260 ./SimpleQmlApp

// Following is the simple Qt app code.

#include <QApplication>

#include <QWidget>

#include <QLabel>

#include <QPushButton>

#include <QVBoxLayout>

int main(int argc, char argv[]) {

    QApplication app(argc, argv);
    QWidget window;
    window.setWindowTitle("Qt Simple App (CMake)");
    window.resize(300, 150);

    QLabel *label = new QLabel("Hello, World!", &window);
    label->setAlignment(Qt::AlignCenter);

    QPushButton *button = new QPushButton("Click Me", &window);

    QVBoxLayout *layout = new QVBoxLayout(&window);
    layout->addWidget(label);
    layout->addWidget(button);

    QObject::connect(button, &QPushButton::clicked, [label]() {
        label->setText("You clicked the button!");
    });

    window.show();
    return app.exec();
}

// Following is the QML app code

#include <QGuiApplication>

#include <QQmlApplicationEngine>

int main(int argc, char *argv[]) {

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;

    const QUrl url(QStringLiteral("qrc:/Main.qml"));

    QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);

    engine.load(url);

    return app.exec();
}

// Main.qml

import QtQuick

import QtQuick.Controls

Window {

    width: 320
    height: 200
    visible: true
    title: "Simple QML Application"

    Column {
        anchors.centerIn: parent
        spacing: 20

        Label {
            id: statusLabel
            text: "Hello, QML World!"
            font.pointSize: 16
            anchors.horizontalCenter: parent.horizontalCenter
        }

        Button {
            text: "Click Me"
            anchors.horizontalCenter: parent.horizontalCenter
            
            // Handle click event inline
            onClicked: {
                statusLabel.text = "You clicked the QML button!"
            }
        }
    }
}
Sure. Sorry it wasn't clear; I meant I just tested the Telegram desktop app for Linux.
Looking forward to the 2030s when we get a wave of lightweight actually native software as an alternative to the bloated Rust rewrites ;)
How would you you do that—chucking libc out the window? A monokernel?
"Claude, write me a client for WhatsApp in raw assembly"
I just checked with the native WhatsApp client on Windows 11: 650 MB of RAM as it is running, across all its processes. Thus, taking ≈⅓ of RAM is nothing to brag about for a reimplementation that focuses on being lean and fast. Also, "opens in under a second" – back in the days when SSDs where new, programs opened instantaneously (<60 ms)!

Lastly, I still have to be convinced that Rust is a good choice for GUI programs, considering their messy mutable state and ownership.

Hello world in Rust is huge, and every actual program I've looked at installed dozens of packages for basic functionality.

Turns out all those zero cost abstractions add up to a lot!

The number of packages doesn't have anything to do with this
It does with the compile times lol

Is there actually a way to see a breakdown of memory usage for a program? If you want to see where all the memory is going?

The topic was ram usage during runtime.
What causes that?
> Is there actually a way to see a breakdown of memory usage for a program? If you want to see where all the memory is going?

Flame graphs are a pretty common tool for this (maybe slightly less common than using them for seeing the breakdown of the time spent when running).

You're welcome to demonstrate otherwise
yeah 200MB is nothing to boast about