Adriksh

2.7K posts

Adriksh banner
Adriksh

Adriksh

@Adriksh

I work with hardware & build cool stuff.

Katılım Eylül 2021
28 Takip Edilen7.5K Takipçiler
Adriksh
Adriksh@Adriksh·
the linux kernel has a per-process limit on open files. hit it and syscalls start failing with “too many open files” no matter how much ram you have, the soft limit is often 1024 by default. the hard limit can be much higher (like hundreds of thousands). every backend service that scales eventually runs into this.
Adriksh tweet media
English
13
7
184
25.2K
Adriksh
Adriksh@Adriksh·
on linux, you can run a program in an isolated environment its own process tree, mount view, hostname, network, and more without docker or any container runtime. the kernel does it directly. it’s called unshare. only a few processes visible. the rest of the system is hidden.
Adriksh tweet media
English
11
108
1.2K
60K
Adriksh
Adriksh@Adriksh·
processes on linux can map the same memory and share data directly no sockets or pipes. it’s called shared memory. the kernel maps the same physical pages into each process. fast, but without synchronization, concurrent writes race results are unpredictable.
Adriksh tweet media
English
3
13
120
4.5K
Adriksh
Adriksh@Adriksh·
write() doesn’t mean written to disk. it usually copies data into the page cache and returns. the kernel marks it dirty and flushes it later. your program thinks it’s done but the data may still only exist in memory.
Adriksh tweet media
English
7
5
83
3.4K
Adriksh
Adriksh@Adriksh·
this works because of linux namespaces. docker, podman, lxc use these primitives directly. kubernetes builds on top of those runtimes.
English
1
1
75
4.5K
Adriksh
Adriksh@Adriksh·
linux lets you switch a process to real-time scheduling with one syscall. it will run ahead of normal tasks and is used in audio and other low-latency systems. if you spin in a while(1) without yielding, you can starve other processes and make the system feel frozen. requires CAP_SYS_NICE (or root).
Adriksh tweet media
English
0
7
89
5.7K
Adriksh
Adriksh@Adriksh·
strcpy, strcat, sprintf, gets these functions have caused a lot of real production bugs. they’re still in libc and still being taught. they don’t check buffer size and they fail. using them with untrusted input is unsafe.
Adriksh tweet media
English
10
5
85
4.6K
Adriksh
Adriksh@Adriksh·
printf("%s", user_input) is safe, printf(user_input) is a vulnerability. printf interprets the first argument as a format string every % makes it read arguments that weren’t passed user-controlled format string = arbitrary memory reads (and with %n, writes) this class of bugs is old, and it still shows up
Adriksh tweet media
English
10
6
74
3.8K
Adriksh
Adriksh@Adriksh·
on linux, you can take a snapshot of a running process its memory, its open files, its registers write it to disk, kill it, and restore it later (even on another machine, if the environments match). it's called CRIU. docker’s checkpoint/restore uses this under the hood.
Adriksh tweet media
English
11
68
731
30.5K
Adriksh
Adriksh@Adriksh·
linux has a directory that contains your CPU's exact model, every flag it supports, the cache sizes, and the temperature. it's just a file: linux exposes your CPU info as a text file, a lot of tools are just parsing it
Adriksh tweet media
English
3
10
130
6K
Adriksh
Adriksh@Adriksh·
bro: v.clear(); 🤔
English
2
0
25
4K
Adriksh
Adriksh@Adriksh·
PR from a guy with 10 years of C++:
Adriksh tweet media
English
19
8
219
29.3K
Adriksh
Adriksh@Adriksh·
it’s surprisingly easy to get a server running what’s hard is everything after this
Adriksh tweet media
English
4
6
56
2.1K
Adriksh
Adriksh@Adriksh·
people use volatile for threading. it doesn’t do that. volatile is for memory that can change outside the program, like hardware registers. the compiler isn’t allowed to optimize these accesses away.
Adriksh tweet media
English
5
10
80
12.3K
Adriksh
Adriksh@Adriksh·
redis returns string pointers that point to the middle of malloc'd memory. the length is hidden behind the pointer. it's evil and beautiful.
Adriksh tweet media
English
11
9
73
5.6K
Adriksh
Adriksh@Adriksh·
I keep this in my dotfiles it prints how long any command takes in human-readable units.
Adriksh tweet media
English
5
8
67
2.7K
Adriksh
Adriksh@Adriksh·
still thinking about this how did <10 engineers pull this off
English
0
1
35
3.2K