Memory grows without bound in big meetings (close to 1 GiB) #227
Labels
No labels
area/ci
area/desktop
area/packaging
area/protocol
area/reading
area/ui
area/web
area/writing
kind/bug
kind/feature
kind/infra
kind/request
needs/user
parked
perf
security
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
littlefox/neokom#227
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported by the user (D-057): messages are never "unloaded". The list only grows, until NeoKOM holds almost 1 GiB just for the tree of messages in displayable form.
Likely contributors, to measure one by one:
channel_view.rs: pages of older posts are prepended and never dropped. Every post stays rendered in the DOM, including posts far off screen.openedand "Visa fler" only add. The previews map is cleared only when the root changes.kom-clientcaches (bodies,text_stats,marksinkom.rs) areHashMaps with no limit. They keep every text ever fetched.data:URLs, so each one is held several times: the decoded bytes, the string, the DOM attribute and the decoded image.Direction (to decide in DESIGN.md):
Done when: a long read through the big seeded meeting stays at a flat memory level, on desktop (RSS) and web (JS heap + DOM nodes).
More from the codebase review (#230):
ImageView(app/src/text_view.rs) callsdata_url(&img)on every render, base64-encoding the whole picture again. The string is used twice, as theimgsrcand as the "Spara bilden"href, so each picture sits in memory as raw bytes, plus about 1.33× that per string (two strings), plus the decoded bitmap. On desktop the strings also cross the webview IPC each time.blob:URL per picture (URL.createObjectURL), revoked when the post leaves.kom-client'sbodiescache keeps the raw bytes of every text, pictures included, for the whole session.Most of this would be fixed by #236 (draw only what is near, a bounded cache behind, refetch the rest), plus #235 and #237.
Done. The last piece, pictures, is merged in #275 (main #462 green); the rest came with #236 (windowed channel list, bounded caches), #239 (small avatars), #232 (search index) and #228/#226 (no thread reloads).
Web,
tools/perf.shon main (after #236 and #233) against main-1 from before 0.6, on the seeded big meeting:The channel scroll now sends one text stat and one text per post it loads, plus one lookup per page. A per-request count confirmed there's no refetching (850 + 850 + 43 for 850 posts).
Desktop,
tools/desktop-perf.sh: RSS 391.6 MB at start, 401.8 MB after login, 406.2–407.4 MB through the 300-post read, 405.9 MB at the end. That's flat, and nearly all of it is WebKitGTK's own at start. (The desktop script's login time, 66 s, counts its xdotool retries rather than the app's work, both before and after.)Pictures (#275): in the browser each picture is one
blob:URL, made when it's shown and revoked when it goes; the picture and "Spara bilden" share it. Previously each picture was base64-encoded again on every redraw and held twice as text. Desktop keeps adata:URL, now made once. Checked in images.spec.ts on all three profiles: the same URL survives a redraw, and once the post is gone the URL no longer loads.