Jsdr3398

Jsdr3398

Why do companies not use Assembly for their (web) server?

I just thought of this. Are there any disadvantages when making your server in Assembly (other than having to learn a bunch of stuff :rofl:)? Wouldn’t servers be much faster if they were made in Assembly? :thinking:

Most Liked

ohm

ohm

Chris Sawyer wrote 99% of the original RollerCoaster Tycoon in x86 assembly. RollerCoaster Tycoon (video game) - Wikipedia :crazy_face:

ohm

ohm

Maybe. But the cost is abstraction. Assembly is as close to bare metal you can get, without going into complete binary mode. :laughing:

The following examples are borrowed from https://courses.cs.washington.edu/courses/cse378/03wi/lectures/mips-asm-examples.html:

A simple program

i = N*N + 3*N

could in assembly be written as

lw     $t0, 4($gp)       # fetch N
mult   $t0, $t0, $t0     # N*N
lw     $t1, 4($gp)       # fetch N
ori    $t2, $zero, 3     # 3
mult   $t1, $t1, $t2     # 3*N
add    $t2, $t0, $t1     # N*N + 3*N
sw     $t2, 0($gp)       # i = ...

However, this isn’t an optimized solution.

lw     $t0, 4($gp)       # fetch N
add    $t1, $t0, $zero   # copy N to $t1
addi   $t1, $t1, 3       # N+3
mult   $t1, $t1, $t0     # N*(N+3)
sw     $t1, 0($gp)       # i = ...

See how complicated it gets real fast? Right here, we are only adding and multiplying numbers, nothing fancy at all. Your compiler would catch such an easy optimization, but you might have spend an hour to figure it out. That is what’s meant by abstraction. You sacrifice a bit of speed (sometimes it’s even negligible) in order to not have to write at such a low level.

mindriot

mindriot

Many web/network applications performance is dominated by IO concerns rather than raw number crunching. There are some unique cases where you can benefit from such optimisation, however they are usually quite rare and quite small in comparison to focusing on other areas like DB query optimisation, caching etc. Dropping down to assembly is a lot of pain and very expensive in terms of development/ maintenance for what is likely to be a tiny percentage of the possible benefits. At the very least it is worth testing and benchmarking to find out what is actually slow in your application design before working on optimising.

Where Next?

Popular Backend topics Top

New
New
DevotionGeo
Some time ago I read somewhere that Rocket will work with stable versions of Rust. The previous version’s changelog says, “Core: Removed...
New
New
bot
Add sound to your Python game. This is part 13 in an ongoing series about creating video games in Python 3 using the Pygame module. Prev...
New
Jsdr3398
I love how elixir works and some of its perks, but I’m still pretty uncomfortable, especially when mix/hex gets involved. Did anyone els...
New
mafinar
So I was thinking of trying out Crystal, I had tried it multiple times but left it midway. Now that there’s a book on it and it’s version...
New
mafinar
I did not add this to a “this weekend I’ll learn” like my few other journals as I am decided on using this in the long term. Last I work...
New
Cellane
I’ve been asked by my supervisors at work to finally give everyone in the team presentation about “that Elixir thing you can’t seem to sh...
New
DevotionGeo
What do you people do for reading Erlang docs? Is there something like Ruby’s ri? I installed manual pages for Erlang under /usr/local/...
New

Other popular topics Top

New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
New