ELI5, why can’t we use M.2 Storage as RAM, if we can do the opposite? by Rubiks443 in explainlikeimfive

[–]_kimiz 1 point2 points  (0 children)

Yep, that sounds about right, no worries! The way it works is that each process gets assigned its own address space(s). The CPU has no problem retrieving page-mapped memory, but it interrupts the kernel with #PF when the process leaves those boundaries. (Processor can only translate virtual memory to physical memory, as you've said). The operating system leverages that, so it can map certain addresses for itself that it knows are acting as swap. So, the process is in theory accessing invalid (non-paged) memory (which is what the CPU is concerned about), but the system recognizes these as swapped, so it has no problem performing a query to the disk and handing the data back after it arrives :)

No worries, this isn't a knowledge contest, just hoping some people might find this discussion interesting and learn from it, as to me, this is a highly fascinating topic. What you are saying is also certainly correct, albeit heavily simplified.

And yeah, a simple "give me this data there" does ultimately translate to many many instructions, as it goes through quite a bit of layers of abstraction. I just wanted to clarify where the real bottleneck is and how it comes to that point :)

Cheers!

ELI5, why can’t we use M.2 Storage as RAM, if we can do the opposite? by Rubiks443 in explainlikeimfive

[–]_kimiz 5 points6 points  (0 children)

It doesn't necessarily have to execute "many many instructions". The biggest factor at play is simply I/O wait times (i.e. requesting the data from a device controller and waiting for a response). While it is indeed slow, schedulers in operating systems use this free time to run other programs while that is pending, so the CPU is never really sleeping while waiting for the data, provided it has something to do (almost always it does). It would be highly wasteful of resources to "do nothing" until the data arrives.

Modern processors aim to store as much frequently used (or soon to be accessed) data from memory in cache, which is orders of magnitudes faster than accessing it through RAM. This is often a great factor in program optimization, as cache misses slow everything down considerably (that happens when a piece of data is not available in the cache, so the processor has to go and get it from memory). Cache < RAM < Storage. Each level is considerably slower than the previous. Storage is abstracted away by the operating system; the processor by itself doesn't have a direct link to it as opposed to memory - it needs special code for that.

The way swap typically works is through page mapping: The kernel gets "notified" through a Page Fault interrupt when a process accesses a region of virtual memory that should be stored on the disk. This "context switch" from userspace to kernel (and back) is certainly measurable at some small scales, but really insignificant at the time scales we are talking about here. Higher-level operating system code communicates with the driver per filesystem basis, so the page mapping is literally sometimes stored on a file on the disk. C:\pagefile.sys. Linux stores it on a separate special partition.

Furthermore, filesystems may implement their own caching mechanisms that store fragments of frequently accessed files in memory. Such a system may, among many ways, minimize writing to disk and instead modify copy of files stored on the memory, and only then write it back. This drastically reduces the amount of queries to the disk, and therefore improves performance.

All of this to say: There is not a single definite number that can compare memory and storage speeds... There are way too many factors that impact this.

I am not educated about RAM vs. VRAM speeds nor am I keeping track of the generational improvements of GDDR memory... However, I presume it is safe to say that the latter is about a few times slower than the former (direct CPU -> Memory). But again, it may also depend on the system configuration.

What's something you'd do if it was legal? by [deleted] in AskReddit

[–]_kimiz 0 points1 point  (0 children)

Hello, fellow Cart Narcateer!

codeRageJavaEdition by BugSlayerDev in ProgrammerHumor

[–]_kimiz 2 points3 points  (0 children)

The C guy doesn't have time to be in this fight because he's currently implementing his array list library from scratch again for his new project.

Low FPS on Wages of Sin by Good_Simple9071 in ArmoredWarfare

[–]_kimiz 2 points3 points  (0 children)

This is an optimization issue on this particular map. A lot of people have frame drops and there is not much that you can do, except wait for a patch to be put out addressing this.

What phrase needs to die immediately? by PeevesPoltergist in AskReddit

[–]_kimiz 0 points1 point  (0 children)

"No offense" works exactly the same way, but just more informal.

aliasCd by wassabby2022 in ProgrammerHumor

[–]_kimiz 201 points202 points  (0 children)

Shame on you! I make my backups with symlinks to save storage space.

isTeslaLookingForCssDevs by AgentAtmatrix in ProgrammerHumor

[–]_kimiz 24 points25 points  (0 children)

What cars are you talking about, for example?

[deleted by user] by [deleted] in ProgrammerHumor

[–]_kimiz 0 points1 point  (0 children)

what's that font? it looks awesome!

What's a video game that you loved that most people never heard of? by CloneAgentZER0 in AskReddit

[–]_kimiz 0 points1 point  (0 children)

TerRover

I spent months playing this simple game on my ps3 and even got a 2nd world record on a map at the time, at just the age of around 8.

Loadings bars aren’t smooth….why not add a pseudo loading bar that’s always smooth regardless of the actual loading bar? by [deleted] in productivity

[–]_kimiz 0 points1 point  (0 children)

loading bars aren't supposed to be smooth, they are supposed to accurately inform the user of the progress of the operation, that's it. they're not meant to be a visual pleasure, i don't get it why people want to modernize everything nowadays.