News for hackers. Stuff that matters.
Re:Tinyssh by onlydnaq on Thursday December 23, 2021 @11:16AM (#29663264)
Without having looked into it too deeply I feel that they are somewhat “cheating” by using a superserver to launch a new process for each connection, thus letting the OS handle the dynamic allocation needed for each connection.

Still pretty impressive project. Would be fun to take a deeper look at it at some point.

Re:Tinyssh by throw0101a on Thursday December 23, 2021 @01:53PM (#29665103)
> […] thus letting the OS handle the dynamic allocation needed for each connection.

This is what PHK did when designing Varnish (IIRC): instead of dealing with lots of files on its own (like Squid), just create some files and do a malloc() on them and let the OS do the work:

* https://varnish-cache.org/docs/trunk/phk/notes.html

One discussion (many others):

* https://news.ycombinator.com/item?id=4874304

Re:Tinyssh by mrich on Thursday December 23, 2021 @04:49PM (#29666902)
It's not malloc() but mmap() if I understand correctly.

It's a beautifully powerful function :)

https://man7.org/linux/man-pages/man2/mmap.2.html

Re:Tinyssh by richardwhiuk on Thursday December 23, 2021 @05:21PM (#29667170)
It kind of undercuts the argument, because the dynamic allocator basically just uses mmap as well.

(Some allocators, like glibc may also use brk, but it's possible to write a fully functional allocator with only mmap).

Re:Tinyssh by mrich on Thursday December 23, 2021 @05:32PM (#29667251)
I think the original point still stands. When the application tries to handle memory pressure itself by writing data structures to disk, it will hit the case where the kernel has already paged that memory out, has to reload it, only to write it to disk and free the memory afterwards.
Re:Tinyssh by hkt on Thursday December 23, 2021 @11:38AM (#29663509)
It makes sense though - no memory management simplifies the codebase. Letting the host deal with it instead means you get the niceties of process level isolation and less complexity. More eyes are on the OS level code than would be on this project. It seems very clever to me.
Re:Tinyssh by zamadatix on Thursday December 23, 2021 @12:09PM (#29663822)
The OS is already handling dynamic memory allocation on each connection. This provides a nice split where you don't need to do it in 2 places.