Better HN
topnewbestaskshowjobs
Log inSign up

codedokode

9,867 karma · joined Aug 20, 2015 (11y ago) · 5,528 submissions

PHP developer from Russia.
Submissions

comment 13h ago · link · parent

Disgusting but this doesn't prove the wife was aware of anything. Also, note that article says that the daughter had cancelled her trip to Seoul - probably because Korean people take such issues more seriously unlike Americans who only care about dollars.

comment 1d ago · link · parent

A betrayed wife who have supported him for many years when he was not rich yet?

comment 1d ago · link · parent

You forgot about the victim. Cheaters should burn in hell, or at least get cancelled so that nobody wants to work with them and not be rewarded for cheating.

comment 1d ago · link · parent

Ridiculous. Cheaters should be punished, not rewarded by society. Think about the victim. What kind of future will there be with such incentive system?

comment 2d ago · link · parent

Why not use heat from datacenters to heat homes? Or to produce more electricity? Or to heat greenhouses in winter? Looks like free energy.

comment 2d ago · link · parent

Also Wikipedia claims that China plants lot of trees (reforestation project).

comment 2d ago · link · parent

I believe your calculations have errors.

First, the data is sent to the monitor from a framebuffer. With compositors like Wayland, every window has its own buffer, and when it is damaged (updated), the compositors copies (memcpy) the damaged part from window buffer into the framebuffer using CPU or GPU. As I understand, this part cannot be skipped and the application renders window content into a window buffer so there always will be a memcpy stage to have it actually displayed.

For example, if the button changed its color, the program updates button image in window buffer, reports the damaged rectangle and the compositor copies that change into the framebuffer to become visible.

Actually compositors use two buffers to prevent tearing, and switch between them on every update so the things might be more complicated.

So with this model in mind, updating one line of text in a window buffer is faster than updating the whole buffer.

Furthermore, to render the text you need to memcpy the glyphs from glyph cache into their locations. So rendering whole window of text boils down to lot of small memcpys.

Also, you mention AVX-512 but I don't think my CPU has it. And when doing lot of 256-bit SIMD the CPU starts throttling to 1GHz-level speed. Also, you mentioned display lists but that requires extra memory compared to my approach.

Also, I decided to try to actually benchmark rendering text from a glyph atlas. Luckily, LLMs can write such code in matter of minutes, so I wrote it: https://pastebin.com/7baP4tWv

Results in a VM without a GPU:

Buffer 3840 x 2160 px, grid 295 cols x 90 rows = 26550 letters/frame, 10 runs, avg per frame: 7.832 ms, time per letter: 295.0 ns, letters/second: 3390088, pixels/second: 1059.086 Mpx/s.

I also godbolt'ed the hot loop in case you are curious about the assembly - it seems to use 128-bit SIMD and unrolled the single glyph rendering loop: https://godbolt.org/z/1Gh1McKE8

comment 2d ago · link · parent

I agree we need to minimize programming errors - by designing a good reactive retained mode framework.

comment 2d ago · link · parent

Let's say you scroll text. I believe rendering one line of text (that became visible) on each frame, and reusing previously rendered lines is faster than rendering all text on every frame. Text rendering is not an easy task.

And as I have written above, you can offload compositing (memcpy) to any GPU from 90s while rendering letters is a harder task. Even with glyph cache you need to manage it, upload updates to GPU etc. So much easier to not use GPU for this.

comment 2d ago · link · parent

You should try running 5 instances of egui program in a VM without GPU before saying that it is "fast". I tried running PhotoCraft, and it is laggy.

comment 2d ago · link · parent

> you start needing to tell the GPU to composite things from a few different textures,

Yes, correct, you need to have two buffers - one for the document, another for the toolbar. In this case you need to do compositing. The good thing is that compositing here is just memcpy, and it can be done on CPU and almost on any GPU starting from 90s, no need for Vulkan support or NVIDIA proprietary driver. And compositing (memcpy) is faster than rendering complicated document from scratch. So instead of sending one large buffer to Wayland, you send two smaller buffers ("send" doesn't imply copying here as Wayland uses shared memory).

So in a perfect world, the application updates a small part of a buffer with a document in a shared memory, changes Y offset, and CPU or GPU rebulds the window that was scrolled by combining the document and toolbar buffers. Oh, even better, by copying only the document part into a framebuffer because toolbar did not change.

So for example, if you are scrolling a text document, with my approach you need to render only one line of text (that became visible) and you reuse previously drawn lines. But with "immediate mode" approach, all visible lines must be re-rendered every frame.

URL works now.

comment 2d ago · link · parent

> the error-prone cache-invalidation logic

Because writing good code is harder than bad code.

Let me give an example. I vide-coded a program that renders white and gray frames and it can do it faster than 60fps on one core in a VM with no GPU. However, VS Code in that VM feels like it is running at 5 fps. The scrolling is slow and laggy. Why is that so? Probably because writing good code is harder. And probably they were thinking like you, that redrawing the whole screen is fast enough except in fact it is not.

Every time someone says that their framework is fast, they should test it in a VM without a GPU.

comment 2d ago · link · parent

I do not see where I suggested to copy the pixels with CPU. With compositors like Wayland, you have a buffer in memory that stores content of a window. Obviously writing a 6-pixel stripe into that buffer (and updating starting Y offset) is faster than over-writing the whole buffer. Now, if that buffer is directly accessibly by GPU, you do not need to copy nothing. And I assume that even poor discrete GPUs can copy that 6 rows with pixels from system RAM to their memory for compositing.

Also your URL shows 404 for me.

To scroll the content you do not need to copy anything. You can just tell the compositor: "first render rows 6-1000 from this buffer and after that rows 0-5". That would look like the content has scrolled 6px up without a single copied byte. This trick was used by game consoles on 80s.

comment 2d ago · link · parent

> there are generally only a few dozen rectangles

Only in a hello world application. Every professional editor like GIMP has tons of tiny widgets. And redrawing one tiny widget on mouse over is faster than running the render function.

Also, you are assuming that running render function costs nothing while in real-world apps there will be layout calculations (because you don't want to position widgets manually), array iteration (for example, to display a sum and average of values from a 100K element array), text characters layout, calling helper functions, generating SVG for a 10K points graph, some genius might add reading from a file, etc.

Yes, writing good code is harder than bad code, especially for a LLM.

And if you are on the stage where you need widgets and layout calculation, why not add a dirty flag and damage rectangles as well, I cannot understand.

comment 2d ago · link · parent

Maybe 80 MB is only private pages and excludes memory-mapped files. Then the memory usage is calculated wrong. I wish people were using proper metrics and not random number Task Manager shows.

comment 2d ago · link · parent

I glanced though the docs; they seem to use proxies for dependency tracking (Vue-like rather than React-like) but for some reason they invented their own language instead of using Rust.

comment 2d ago · link · parent

When using Wayland, you have 2 buffers that you render your window into, and they already contain previous window content so why make a cache? Why not simply skip the parts that did not change?

The article you are referring to is interesting, but it looks like adding a hack instead of rewriting the code. They also did not make measurements for an older system without a working GPU.

> If rebuilding the UI takes a millisecond at most, how much should we care?

Because user runs multiple programs, and rendering UI doesn't always take milliseconds, and battery capacity is not infinite. Also programs using GPU typically use lot of extra memory, require slow shader compilation, GPUs often have buggy drivers.

Also it would be better if every program used same UI widgets (for example, GTK) rather than have their own set of widgets with missing features like IME support, different hot keys etc.

Also, what is the advantage of immediate mode UI over proper GUI reactive framework with convenient declarative syntax? I see no advantages.

comment 2d ago · link · parent

Scrolling should not take a full render - you ideally only need to render a small stripe that becomes visible. For example, if you scroll at 720px/sec, at 120 fps you need to render only 6 px of height per frame. Must not be hard.

For example, if you are scrolling a PDF you could theoretically "scroll" (change start y offset) of the window buffer, render a newly visible stripe (those 6px) and re-render the toolbar 6px lower which otherwise would scroll with the window.

It seems nobody can do this nowadays, so another option is to use two layers - a document and a toolbar and offload the compositing to window compositor which might as well use GPU for that. So you have one buffer with a toolbar (never changes), and another buffer with a document, and when scrolling, you only draw the changed part and instruct the compositor to draw the document with an offset.

comment 2d ago · link · parent

Electron binary itself weighs about 200MB so your number doesn't look realistic and probably you used some tool that shows wrong numbers (like Windows or Mac Task Manager).

comment 2d ago · link · parent

I think immediate-mode UI is awful (does lot of useless work, redraws whole window on every mouse move). Also I think GPU support is not that important:

- first, GPU requires shaders compilation which is slow so you need CPU renderer anyway

- second, not all GPUs are supported, not all have drivers, some are buggy and many machines, like VM, do not have a GPU

- third, it probably uses lot of memory

You don't need a GPU to add one letter to a text field.

I did some tests in a GPU-less VM, using one x86-64 core. The test simply rendered black and white 4K frames. Rendering to memory gave numbers like 360 fps (and ~8GiB/s of RAM writes). Rendering to X server via SHM produced something about 80 fps, the X server used 50% of the core and the program used other 50%. But many users have much smaller screens, and you typically do not need to redraw whole window every frame.

So you can render everything on a CPU and, if the user has a GPU, use it to accelerate drawing rounded rectangles which make probably 90% of GUI.

comment 2d ago · link · parent

This reminds again that all "promises" of companies are a lie and you better not trust their "privacy policies".

comment 2d ago · link · parent

Americans are a tiny part of world population though.

comment 4d ago · link · parent

Sorry for commenting without actually learning the subject but from your description it feels like you are just send the message into the void without even knowing if someone reads it? Maybe you should call your project "message in a bottle".

comment 5d ago · link · parent

By the way I do not really need the history and I believe it should be disabled by default - like in real life conversations where there is no history - so I do not understand why syncing needs to be slow. Cannot you just fetch last 10 messages when the user opens a room?

comment 5d ago · link · parent

Interesting that Zoom (sorry I did not use Teams) uses popups when you try to join from the browser so I have to manually open that popup blocked by my browser. While in a browser version of Element I can make calls without any stupid popups and having to reject suggestions to install an app.

comment 5d ago · link · parent

I didn't use Microsoft Teams, is it any good?
12345
185