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 - "iff"
-
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 -
-- Best --
> Submitted my notice of termination for my current job
> Found a new job starting next year
> Can switch from Windows to Linux/MacOS in new job
> Got more time to work on personal projects due to the pandemic
-- Worst --
> Huge amount of software restrictions (current job) almost got several projects at work canceled. Maybe its important to say that the core business of my current workplace is auditing so there are a lot of law regulations which then apply in the softwaredevelopment process.
> New managers that do not have the slightest clue of what they're doing
> Online Teambuilding events
> Absurd amount of segmentation of tools and also different coding guidelines that are used at work. E.g. one team uses jira, another trello, another github issue tracker and so on. -
Whoever designed how audio metadata is stored in gamemaker archives is now on my hitlist.
I think my comments on my parser sums up my mental state pretty well.
https://gist.github.com/BenjaminUrq...4 -
Today is my last coursework submission. I've touched on a lot of topics I never thought I would be able to do/even thought about. I like data science, but I just don't feel so passionate about it now. I just want to ditch coursework and do cool shit, but I never find the time.
Anyone else get somewhat "fed up" of what they've studied? How did you get through it? Just do the "cool shit"?3 -
"Google Search Fixer" is a must on Firefox Android iff you use Google search.
Now I can finally start using Firefox again..
PS: I was using Edge till now
https://devrant.com/rants/1248199/...4 -
I feel it would be amusing if all the people trying to ruin sleep at night where I am were pushed out of their comfort to bug someone elsewhere
Iff they don't stop they will be
You know or they could just be human and prevent further unnecessary repeat hardship and annoyance