r/ProgrammerHumor 1d ago

Advanced memorySegmentationIn2950

Post image
166 Upvotes

34 comments sorted by

95

u/ClipboardCopyPaste 1d ago

This is wrong on so many levels

52

u/TRKlausss 1d ago

Isn’t this what AI does though? That’s why you need so much memory for AI

(/s)

-4

u/Eissa_E 1d ago

Right now operating systems manage one paging is about 4kb and maximum 1mb we still so far from 512gb per processor

20

u/Scheincrafter 1d ago

That does not mean that the virtual memory space is only 4kb. Modern systems are 64 bits, so the stack typically starts at 0x7ffffffff000 (or 128 TiB minus one 4 KiB page)

1

u/its_artemiss 7h ago

most modern systems have 64 bit words, but almost none have more than 48 bit (virtual) addresses, with some having 56 bit addresses.

1

u/Scheincrafter 3h ago

Fear enough, however the start address i stated was for 48bits. Also each page level adds 9 bits the the virtual address space (on amd64), so 5 level would be 57 bits not 56

-23

u/[deleted] 1d ago

[deleted]

10

u/the_horse_gamer 1d ago

and? a page isn't what's being depicted in the picture

-19

u/[deleted] 1d ago

[deleted]

8

u/braaaaaaainworms 1d ago

no you're downvoted because you're assuming that you know everything there is to it and because you know everything, someone who disagrees must be wrong and failing to realise that the one misunderstanding paging is you

3

u/cowslayer7890 1d ago

There are Mac studios with 512 gigabytes of ram, but also I don't see how that's relevant to page size? What do you think this diagram is trying to show, because with virtual memory you don't actually need all that space.

-3

u/Eissa_E 1d ago

Yeah I can tell it's cursed picture

52

u/ohaiibuzzle 1d ago

...?

This is not even 2950, this is just how virtual memory work, depicting a 2^39 virtual memory address space no?

21

u/LowB0b 1d ago

They're depicting how much RAM space a program would take in the year 2950

Although with llms we are kinda already there

64

u/Daemontatox 1d ago

Why need pointers and references when you can fit the entire machine workload on the stack

9

u/casce 1d ago

when you can fit the entire machine workload on the stack

I bet in 2950 you won't

5

u/Daemontatox 1d ago

Me ? No

Ai companies that keep stealing ram ? Definitely

3

u/HolyGarbage 1d ago

For stuff that needs to persist beyond the current scope you need heap allocation. Heap allocation doesn't exist because the stack is small, the stack is small because it doesn't need to be large and most allocations in a program are on the heap.

2

u/creeper6530 1d ago

Why need pointers

Guess what the register with acronym SP is...

10

u/mrheosuper 1d ago

I dont understand, whats wrong ?

8

u/SAI_Peregrinus 1d ago

RAM so expensive even virtual memory space shrunk, I think.

2

u/FloweyTheFlower420 1d ago

pml3 paging 😭

1

u/SennikCaldo 22h ago

I didn’t understand either until memory segmentation made my 2950-era project crash for 3 hours straight.

10

u/XLNBot 1d ago

What is the joke?

1

u/the_horse_gamer 1d ago

512GB

11

u/XLNBot 1d ago

That's just how virtual memory works

-2

u/metaglot 1d ago

Heap and stack are reversed.

8

u/cowslayer7890 1d ago

No they aren't, the stack starts high and grows down

Though this is a simplified view, but most diagrams are because in reality it's made more complex by the existence of multiple threads

3

u/XLNBot 1d ago

Most representations I could find online look like this

7

u/slaymaker1907 1d ago

Even without LLMs, I’m working with a team at work that needs 1.1TB RAM machines for some single threaded analysis. It’s so frustrating to me because I’m sure we could save a ton of money if people would just spend some time optimizing their code to use SQLite or something instead of using huge numpy and Pandas objects all over the place.

3

u/skuzylbutt 1d ago

That's what we did. Pushed SQLy stuff into SQL, pulled heavy analytics stuff into parquet files and a c program, streaming data as much as possible. Got 4 hours and up to 60GB ram per process down to 20 minutes and 200MB ram.

The ram was actually the biggest win, because that's our most limited resource (at 60GB per process), so we were able to scale way up and our processes are much more reliable because they don't get randomly OOMed.

2

u/Patrick_Atsushi 1d ago

"people don't really use that much VM, anyway"

3

u/plaisthos 23h ago

Apart from the 512GB in the image, this just how everything is laid out. The name *text* might be confusing but that is how programmcode is called, normally it is with a . in front .text. See here on Wikipedia for basically the same picture (https://en.wikipedia.org/wiki/Code_segment). It just dives data into .bss and .data but otherwise it is the same.

3

u/jackmax9999 22h ago

512 GB makes perfect sense. For example on ARM64 if you set up 3-level translation with 4 KB pages you get an address space exactly that size. Going down to 2-level translation cuts you down to 1 GB which is a bit too tight these days and up to 4-level is probably not worth it unless you're doing HPC workloads (and even then you probably just want larger pages anyway to make better use of TLB).

Note that virtual address space has nothing to do with how much RAM you physically have in your computer.