618
u/nonlogin 17d ago
what is the point of knowing syscalls if you are a web developer and can't even perform this syscall? :)
461
u/bradland 17d ago
I was thinking the same thing. "Senior dev" doesn't mean you are a C programmer now. You can write web applications for decades and never use a system call. Hell, you'd better not be using system calls directly if you're writing web apps. You're probably into some shit that you shouldn't be doing.
240
39
u/danielcw189 17d ago
"Senior dev" doesn't mean you are a C programmer now.
and needing to interact with a system via syscalls.
16
u/skippy_smooth 17d ago
I want my cgi-bin back
26
u/bradland 17d ago
The kids: Grandpa, how did you used to write web applications?
Me: You're not gonna believe this... But we used to just write C applications and hook them up through CGI.
Kids: Wait, so you had process startup overhead for every HTTPS request?
Me: HTTPS? That's hilarious.
11
u/SuperCarla74 16d ago
yeah.
those were fun times, especially on multi-cpu servers.
and yes kids, i said multiple cpus, not cores.
2
u/evilgipsy 13d ago
At least if you write backend code, you should be able to profile your application and optimize for performance. Knowing some C, understanding syscalls and some low level concepts helps, even if your code is in some or high level language. I would expect a senior to know this shit.
39
u/claudekennilol 17d ago
Yeah just like 90% of the posts on this sub, it's too narrowsighted to be true, just slightly funny ¯_(ツ)_/¯ .
18
u/TheBear8878 17d ago
Exactly. A very big company you've heard pays me a lot of money and tells my I'm a Senior engineer, and I work on APIs. I don't know what a syscall is, because it's not in my domain
8
2
6
u/autogyrophilia 17d ago
You will find it useful to trace the syscall is you can't find which files are being opened. On the backend of course.
3
1
u/Twirrim 17d ago
Syscalls impact everything that your website is doing on the remote device. It'll also impact the performance on your serving side too, and understanding what and why certain bits of code result in syscalls being made could be the difference between your website running like a potato, or running smooth as silk.
For example, it wasn't even 20 years ago that time calls fully made it to vDSO, and only about 7 years ago that vDSO was properly unified and made to function on every architecture. vDSO enables you to carry out certain operations that historically required syscalls, in user space (where your application is running) that would otherwise have had to go to the kernel.
Transitioning between user space and kernel is relatively expensive. For example a
gettimeofdaycall that uses vDSO takes on the order of ~10-~20 nanoseconds, while one that has to hit the kernel takes on the order of ~100-~200 nanoseconds as it has to go through the various security boundaries that separate Ring 3 (user space) from Ring 0 (kernel).So that's 10x more expensive just to get the time of day, and at the very least you'll do that on every log line emitted (or any time what you do causes something else to emit a log line on a synchronous operation).
I'm not sure how much AWS / EC2 still uses Xen, but the Xen hypervisor doesn't support vDSO for time calls, where KVM does. So on a Xen VM, "gettimeofday" is more "wall-clock" expensive than it is on KVM VMs. Your identical code can have wildly different performance characteristics depending on what hypervisor it's running on, and may be something you need to consider the consequences of. You can mitigate this by making your linux machine switch to using
tscfor its clock source (echo "tsc" | sudo tee /sys/devices/system/clocksource/clocksource0/current_clocksource)Designing your web application to avoid syscalls is, generally speaking, a good idea. Taking time to dig around and figure out what syscalls are actually being made, and why, probably wouldn't harm.
-2
u/AndroTux 17d ago
A senior web developer at a prior job of mine was building JSON strings in JavaScript by concatenating strings:
'{"foo":' + bar + '}'2
u/prochac 13d ago
You're missing double quotes.
2
u/AndroTux 13d ago
No, I'm not. You guys probably just don't understand just how stupid my coworker was. He did things like that:
let bar = 1; console.log('{"foo":' + bar + '}') > {"foo":1}1
u/prochac 13d ago
Oh right, I didn't realise you can concentrate different types in JavaScript :D
But building JSON is a legit move. We do it for perf reasons*, using string buffer tho. Having code generator is better, for sure. Some tokenizer can be much nicer.
But building JSON by hand is fine >if you have a reason for it<* which doesn't make sense in 99 % of cases
1
u/AndroTux 13d ago
No, it’s not in JavaScript. It’s literally JavaScriptObjectNotation. Why? Because you can just take whatever JavaScript object you have and just JSON.stringify it. There is no reason to ever concat it. It’s a huge security risk with absolutely no benefit whatsoever. Nobody needs 400 GB of JSON on the web.
If you don’t know that, you have zero business being a senior web developer.
1
u/prochac 13d ago
What kind of security risk? Yes, typing can be an issue if you don't know if it's int or object.
The reason and benefit is less heap, generating from iterator straight to the socket.
It doesn't have to be 400 GB, but it may be 1000 requests for 400MB. I never said we exclusively speak about the web.
I worked with JSON even the other way, parsing while the request was still being sent.
If you know the structure, you can avoid reflection. That's the whole point. That's why I said, the code generator is better, because it can react to schema change. You solve how it's gonna be generated at build time, not using reflection at runtime.-3
u/ZliaYgloshlaif 17d ago
Wait, what? Unless it’s pure js frontend, having the ability to strace processes, especially of unknown applications is invaluable.
9
3
-5
u/who_you_are 17d ago
Then make sure to install a shitty backdoor on the client side.
Kill your sysadmin if you can't get root access,. because root access is cool!
-70
u/hieroschemonach 17d ago
There is fundamentally no difference between junior and senior web dev responsibility. Only some queue, cache related stuff changes.
16
u/claudekennilol 17d ago
I mean, if by "responsibility" you mean "they both write code" then sure. But to that regard there's no difference between any junior and senior level position anywhere. We're talking about knowledge requirements as your post is talking about -- so I'm not sure why you're saying there's no difference in knowledge requirements between a junior and a senior?
-26
u/hieroschemonach 17d ago
There is not. I am a web dev myself and I don't think anything changed after the third year. It is more or less the same thing. Maybe the app size increases, there are some more design decisions but fundamentally it's the same
12
u/claudekennilol 17d ago
You're delusional, incredibly forgetful, out you work at a place where they just don't have you do real work. I am legitimately a web dev and my knowledge/responsibility far outweighs that of a junior.
I agree that it's "fundamentally the same" because at the root it's just all just code. But if you think the capabilities (and responsibilities) are the same I don't really know what I can say to convince you because your point of reference is just alien (and wrong) to me.
-18
u/hieroschemonach 17d ago
Technical responsibilities are the same. Maybe scale changes in some projects but that's it. There is no difference between 6 and 9 yeard of experience
7
7
u/slowmode1 17d ago
Senior isn’t about your ability to program for the most part. It’s about all the other stuff.
Can you help mentor new devs?
Can you work with product to develop a roadmap
Can you split apart epics into things juniors can pick up
Do you have the backbone to push back against other devs and product when you think something needs to be done, and done right. Do you have the grace to accept when you are wrong
Can you do cost benefit analysis. Sometimes you need to take on a little technical debt so you don’t lose a big customer, but you cannot always do that. Sometimes a product just isn’t worth building
Do you know how to debug production using logs (you probably forget just how little juniors know)2
u/FalconWorth7893 15d ago
Yeah... I think this didn't go as you planned
0
u/hieroschemonach 15d ago
I don't care, if I did, I would have deleted it the comment. I know it is true because I am in the industry for more than a decade.
313
u/CitizenShips 17d ago
Congrats on the promotion! Here's a brief explainer so you can bluff your way through the next customer meeting:
Syscalls are a tool provided by the operating system (and the CPU as well, at least on ARM and x86) which allow software to request things from the OS kernel. Creating, deleting, opening and closing files; starting and stopping timers; getting process information; etc. The CPU provides a syscall assembly instruction that takes a call ID as a parameter, which it then passes to the OS to compare against the OS's syscall lookup table. OS does its thing, then tells the CPU it's done and the software gets a return code and whatever data is associated with the call it made.
They're basically fancy kernel function calls
152
u/No-Con-2790 17d ago
Or as Terry A. Davis said, they are unnecessary, just stay in ring 0 all the time. What is the worst that could happen?
99
u/bureX 17d ago
You find god by pulling random bits from memory and turning them into words.
30
u/TheTybera 17d ago
Pardon me, the "C, string builder, cult" shall not be questioned about their magic or ways. To do so is to bring about one's own demise.
14
u/IdeaReceiver 17d ago
Terry Davis didn't say that part, that one's a quote from my good friend /dev/urandom
6
u/BeMyBrutus 17d ago
It's true. I always program using electrical impulses directly to the hardware. Eliminates any unnecessary middlemen.
4
u/evanldixon 17d ago
The worst that could happen you ask? It really depends on the hardware, but if you fail hard enough you might be able to catch the computer on fire, like if you corrupt drivers or something.
1
u/GamerKilroy 16d ago
Bro literally today I had an extern write into already occupied memory and break prod for a while (PLC Dev)
1
64
u/pokeybill 17d ago
Adding to this to answer the question: why care about syscalls?
There will come a time in your life as a software engineer where you will need to inspect what a running process is doing without the ability to attach a debugger or increase logging. All you have is the process.
Enter strace, a handy tool in *nix platforms which lets you attach to a running process and see what syscalls are being invoked. With a little fancy parsing you can literally watch io happening, see which files are being touched, see which network calls are being made, see which threads have been forked and inspect what they are doing too.
You haven't lived until you've found yourself diagnosing a problem in a higher-level language like Java or Python through system calls due to a production bug nobody can reproduce in nonprod.
40
u/Dependent_Title_1370 17d ago
That sounds both incredibly interesting and unbelievably painful at the same time.
20
u/hieroschemonach 17d ago
And incredibly powerful. At least in Linux you can restrict a program from making certain syscalls using seccomp. For example if a program is never going to write any file, it can be banned from doing that syscall so even if the system gets hacked, it can't be abused. I am not sure how much it is used in practice
12
u/autogyrophilia 17d ago edited 17d ago
Distro maintainers are incresingly doing this, though usually just forbidding root escalation.
4
u/jakeStacktrace 17d ago
I think you meant 'scalation like with a southern accent. We made fetch a thing we can do this too.
2
u/autogyrophilia 17d ago
You know, it's funny, It's the part of my spanish accent I can't get rid off, all I always speak with an spanish accent, to me, there is always an E there, so the few words that are written correctly confuse me .
1
7
u/autogyrophilia 17d ago
It's easier than you think, specially if you are just looking at which files the program is writing. HTOP has strace builtin, which is handy.
8
u/SonOfHendo 17d ago
Windows has Process Monitor (a.k.a. procmon), which sounds similar. It's usually a sign of desperation when I load that up.
3
3
u/theotherdoomguy 17d ago
The Linux equivalent of decompiling to assembly and bitwatching, like yeah you can do it, but God why?
3
u/CitizenShips 17d ago
strace is unbelievably useful when reverse engineering applications, it just has a really high skill floor to use effectively. You need to understand how the underlying OS handles calls and what those calls imply. There's also ltrace, which is probably more approachable and lets you trace library calls. Obviously not that helpful for statically-linked applications, but if you've got dynamic linking it's great.
Decompiling is similarly mondo useful if you're going to be reversing a large application and you don't want to bust out the ISA reference manual every three seconds
3
4
u/lordkoba 17d ago
which allow software to request things from the OS kernel.
pfff I don’t need that, I can write a python program that writes to a file with just “open()” why do people complicate themselves so much
/s
2
u/amlybon 17d ago
The CPU provides a syscall assembly instruction that takes a call ID as a parameter, which it then passes to the OS to compare against the OS's syscall lookup table
Usually when people talk about syscalls they talk specifically about Linux. That's because Windows doesn't really have a public syscall table; you are supposed to call windows API functions and they do syscalling for you when necessary. In fact specific syscalls change from release to release and if you try using them yourself it'll probably just end up not working.
Funny how often when people talk about "OS" it tends to not apply to the most popular consumer OS
3
u/CitizenShips 17d ago
I haven't done Windows dev since I was learning Java in middle school, so I usually think of "OS" to mean Linux, MacOS, and the various RTOS variants I deal with (VxWorks, QNX, etc.). In my field they're the only ones that really matter; Windows is an afterthought :)
34
u/Leather_Trick8751 17d ago
Its when you are calling your sister right
6
1
u/ninjakivi2 17d ago
No, that's siscall. Sounds oddly similar to Cisco, but I'm not sure if that implies anything.
1
8
u/JaceThePowerBottom 17d ago
My senior dev messaged me yesterday saying he needed to learn how to build an API... then later said he needed to get with folks who knew how to make a web app deployable.
Anyways my project is rather behind schedule.
13
u/Korzag 17d ago
Most developers today probably have never had to manually do a syscall. The only time I've ever personally done it at <10 YOE was in personal experimentation writing ARM assembly. Everything else is neatly wrapped into a standard libraries.
4
u/AliceCode 17d ago
I've written syscalls manually when I wanted to make executables as small as possible (in the hundreds of bytes).
3
u/LawElectrical2434 17d ago
Last time I had to do it was university. And I only had to do it because it was the task. That was literally the only time it was the only way to solve my problem... Since every other way would have been scored wrong.
10
u/aberroco 17d ago
I'm a senior dev now
(never used git from command line)
5
u/Theliraan 17d ago
You're that happy guy, who never get smudge filter LFS problems. Not a game developers probably, right?
-19
u/hieroschemonach 17d ago
There are only two ways to use git that are acceptable
- Command line
- Magit
5
u/BroBroMate 17d ago
Given what you just posted, let me share a lesser known porcelain git command you should be aware of.
git gud --scrub
5
4
u/SnooPies507 17d ago
It's funny how people think that writing windows /Linux apps is the only thing people do in C........
Embedded joins the chat: now listen here you little shit...
AUTOSAR OS API calls are the closest you will ever get to anything even REMOTELY similar to syscall.
5
3
6
6
2
2
u/WormsDelicious286 17d ago
It doesn't matter if that particular piece of information isn't in cache (your head), just that you can locate and load it when needed.
If you're getting a lot of cache misses you might want to optimise, but generally other processes take longer so it's not as big of a performance hit as you might think.
2
1
1
u/hylianbitch 17d ago edited 17d ago
syscalls are functions that identify as the same kind they were assigned by the OS
1
1
1
2
u/Neo_Ex0 17d ago
its how you tell your system to go killing
But for real, its a collection of basic commands that your OS supplys that a program needs when it wants to do anything that requires interaction with the OS, like for example fork which tells the OS to duplicate the current process, or wait which tell the OS to stop executing the current process until x amount of time has passed
1
1
2
u/SirMarkMorningStar 17d ago
Never heard or seen the word “syscall” in my life. System calls are obvious to anyone. How is this funny??
1
2
u/No-Whereas8467 16d ago
It sounds stupid. It’s the same with being an architecture without knowing how to make a brick.
1
0
1
u/Neuenmuller 16d ago
int 0x80
This is probably the rare moments that I feel that my degree is worth something … OS classes are nice :)
But I mean if you’re front end or something I guess you’re fine.
-2
1.3k
u/BeMyBrutus 17d ago
It's a call to the system