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
First poster: bot
The Complete AWS Lambda Handbook for Beginners (Part 1). In the first part of our Complete AWS Lambda Handbook for Beginners, we explain...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
Jsdr3398
I really need developers to help create my messaging platform but I’m not sure how much they want etc. I’ve never hired anyone before :s...
New
jaeyson
Hi all!, anybody tried this Elixir quiz from @Tetiana? She’s the one who made Elixircards.
New
lucasvegi
Hello guys! Perhaps some of you have already seen this invitation on other channels in the Elixir community or even responded to our surv...
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
mafinar
December is only a few weeks away. I have been detached from programming puzzles for a while now so thought I would give myself some warm...
New
lucasvegi
Hello guys! Perhaps some of you have already seen this invitation on other channels in the Elixir community or even responded to our sur...
New

Other popular topics Top

Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
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
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New