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.

Popular Backend topics Top

AstonJ
Partly interested in this so we can set up tags, but also because I’m out of touch with which frameworks are hot right now and I’m curiou...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
New
New
Jsdr3398
I’ve recently become interested in Elixir and all it’s neat perks. And since I’m currently working on a messaging platform; elixir seems ...
New
First poster: bot
Welcome to RETRO, my personal take on the Forth language. This is a modern system primarily targetting desktop, mobile, and servers, th...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
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
mafinar
We always have fun in this forum around this time of the year, discussing the days’ (or yesterdays’) challenges and talking through solut...
New
KnowledgeIsPower
MongoDB, Cassandra, DynamoDB and etc. Also, do you use VM or container to run it?
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
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
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New