Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "234"
-
When you've been coding for what seems like an hour and when you finally look up it's dark outside 😛
-
So recently I did a lot of research into the internals of Computers and CPUs.
And i'd like to share a result of mine.
First of all, take some time to look at the code down below. You see two assembler codes and two command lines.
The Assembler code is designed to test how the instructions "enter" and "leave" compare to manually doing what they are shortened to.
Enter and leave create a new Stackframe: this means, that they create a new temporary stack. The stack is where local variables are put to by the compiler. On the right side, you can see how I create my own stack by using
push rbp
mov rbp, rsp
sub rsp, 0
(I won't get into details behind why that works).
Okay. Why is this even relevant?
Well: there is the assumption that enter and leave are very slow. This is due to raw numbers:
In some paper I saw ( I couldn't find the link, i'm sorry), enter was said to use up 12 CPU cycles, while the manual stacking would require 3 (push + mov + sub => 1 + 1 + 1).
When I compile an empty function, I get pretty much what you'd expect just from the raw numbers of CPU cycles.
HOWEVER, then I add the dummy code in the middle:
mov eax, 123
add eax, 123543
mov ebx, 234
div ebx
and magically - both sides have the same result.
Why????
For one thing, there is CPU prefetching. This is the CPU loading in ram before its done executing the current instruction (this is how anti-debugger code works, btw. Might make another rant on that). Then there is the fact that the CPU usually starts work on the next instruction while the current instruction is processing IFF the register currently involved isnt involved in the next instruction (that would cause a lot of synchronisation problems). Now notice, that the CPU can't do any of that when manually entering and leaving. It can only start doing the mov eax, 1234 while performing the sub rsp, 0.
----------------
NOW: notice that the code on the right didn't take any precautions like making sure that the stack is big enough. If you sub too much stack at once, the stack will be exhausted, thats what we call a stack overflow. enter implements checks for that, and emits an interrupt if there is a SO (take this with a grain of salt, I couldn't find a resource backing this up). There are another type of checks I don't fully get (stack level checks) so I'd rather not make a fool of myself by writing about them.
Because of all those reasons I think that compilers should start using enter and leave again.
========
This post showed very well that bare numbers can often mislead.
21 -
FFS stop squashing commits. If “updated comments” is what the commit was it should show it in git blame. If “fixed null check” is what the commit was it should show it in git blame.
There is no reason to have “ticket-234 service revision” beside 1000 lines of code. How does anyone justify this loss of git info for the sake of “clean history”? Nobody looks at your history and says, “That is bloody clean git history I should write home about it.” People do however look at the code and say, “I wish I knew WTF they were trying to do on that line.”12 -
My girl friend was complaining that I care more about programming than her.
I told her,
"Trust me baby, in the array of my interests you are [1]."
She was satisfied.2 -
Called to maintain a WordPress site. Site has 100 plugins, two to disable right click. Somebody kill me already 😂😂😂1
-
So I wanted to merge some variables that actually had the same roles.
So I did the Replace in all files (why I didn't refactor, I dunno).
Expected 10 changements, got 234.
Woops. -
I think the reason most people hate frontend these days can be summed up by the fact that the frontend of my fairly simple React webapp is about 850 loc while the entire Express and MongoDB server is a mere 234 loc
God damn frontend is a lot of work these days5 -
spend better part of my day processing about 400M rows of data with MySql, woo ain't no single line of code that can do that in 12hrs 😊
-
Going to design a contract for my services it's going to include additional costs for additional changes because with clients the job is never done 😉😉3
-
I finally attempted php, I wrote a bunch of scripts to fetch data... I feel like I have betrayed myself 😞😞😞
I should have just absorbed the cost of azure 😭😭😭 now am a php dev.... The things I'm about to do, the horrors I'm about to put out into the world.... Pulling your hair out will be the least of your worries, dear maintainer forgive us all, always and forever. 😳1 -
A toast to the perks of backend, to never being bothered again with every single ui change.... Just you and your code 😏😀2
-
instagrams "based on likes" is total bullshit, I don't like shit those suggestions like but if you scroll through your contacts you'll find those suggestions. Why not just say it like it is: "from your contacts or from your friends contacts"
3 -
By starting the company I think I just dissolved, perfect opportunity to start a new one... Software company name suggestions anyone3
-
and so today almost an hour ago I became the left one... I guess she went with the right one 😂😂😂... How many days have passed between my previous "relationship" post and this one ending... but in truth I was in the "babe" zone 😂😂😂
On to the next one, with the lessons from mistakes of the previous, hopefully she will last longer 🙏1 -
Project manager, knows nothing/little about the project... Always sends new features to be added only to be removed 1hr later 😣😣, you have experienced nothing until you work under 1
-
I once wrote a whole lot of classes with lots of functions and pushed them to the live server without testing... There were no errors 😎1
-
when you are using javascript frameworks and plugins in mvc and you have ReSharper, for your own safety and sanity exclude *.js
-
I was so lucky to win the $1 million prize in the lottery. I have been playing the powerball lottery for about 20 years, and i didn't win any big amount until Dr. Lucas helped me with his spiritual winning numbers, I thought it was all fake until he gave me the numbers and directed me on how to play. He gave me assurance that I was going to win and asked me to give him 48 hours to finish his work, which I did. The third day, he gave me the numbers and gave me instructions on how to play, and luckily, I won. I want to let everyone who is reading this to know that this spell really works and you can also be a winner if you give it a try to see for yourself. The moment you contact Dr Lucas for help is the end of suffering in your life, he has been helping people around the world and I'm happy that I'm among those who has benefited from his great work he's doing, you can reach him if you really want to win the lottery Email: Drlucasspelltemple@gmail. com Or WhatsApp +234 904 794 3567 Thank You2
-
There's a mystery behind every lottery winner's story that you don't know. I found a way to win after a long time of playing the lottery without winning any reasonable amount of money, i contacted Dr Lucas through Brad Duke's post saying how Dr Lucas helped him won the lottery with his spiritual powers, and i was very desperate to try him to see if it will work for me, i contacted him at once and he responded and asked what i want him to do for me, i told him i want to win big on the lottery and he replied by saying, that's what i know how to do best, he told me what i should do, i did them perfectly, he gave me a date that he will give me the numbers and he never failed, I'm ( Scott G ) the 55 million lottery winner, i was able to achieve this with the help of Dr Lucas spell, this is not a joke, my story is all over the Internet how i won 55 millions you can do your research, but i want everyone struggling to win the lottery to hit Dr Lucas up at once and your story will change at once just like every other people who have benefited from his good work, Dr Lucas is tested and trusted. Email Drlucasspelltemple@gmail. com || WhatsApp +234 904 794 35671



