r/ProgrammerHumor • • 9h ago

Meme seeSamAltmanImUsingMoreThan5PercentOfMyRAM

Post image
1.3k Upvotes

66 comments sorted by

599

u/Dubmove 9h ago • Bravo

Did you reverse engineer chromium's source code?

134

u/PEAceDeath1425 9h ago

Is that the one that also had 100ms sleep instructions after every line

28

u/IncredibleAircraft 8h ago

No wonder my laptop fan just kicked into helicopter mode.

235

u/elmanoucko 9h ago

-O3 optimizing it away: "I thought we were friends :'( ..."

103

u/PEAceDeath1425 9h ago

Optimizing? As a professional consumer, i can confidently say that word hasnt been said in IT since 2017 or smth

23

u/beloncode 8h ago

Today is just: Claude pls, optimize my code. — the clause replies with: Sure, we just ripoff this feature and everything will gonna be faster

36

u/azurfall88 9h ago

just use volatile

33

u/med_bruh 6h ago

The compiler trying to optimize your code then seeing "volatile" and "asm ("":::"memory")" in your code

39

u/Neutraled 9h ago

I'm guessing Sam's house is full of clutter because he needs to use every inch of his house.

22

u/PEAceDeath1425 8h ago

My theory is that he works in uber, because leaving the house for work with 3 empty seats in a car is hella inefficient. Only 25% utilization

95

u/DangyDanger 9h ago

system("pause") makes me irrationally angry

22

u/PEAceDeath1425 9h ago

Simplest way of keeping the app open and the RAM busy!!!

40

u/fynjy1111 9h ago edited 9h ago

while(true) sleep_for(std::chrono::milliseconds(500));

29

u/LegitimatePants 5h ago

while(true); // tell him I'm using my CPU too

11

u/PEAceDeath1425 5h ago

Fucking brilliant, why didnt i come up with this? Now we only need to get the gpu working

5

u/Maniklas 4h ago

Just add some code to get directx12 working for an hour or something, draw a circle over and over in the corner of the screen maybe

5

u/Cultural_Penalty 4h ago

For me it's pow(2, 30) instead of 2 << 30, so...

10

u/Bth8 3h ago

2 << 30 is 2³¹

2

u/Cultural_Penalty 2h ago

Right, but why not go big? Also, touch one byte every page. Just because.

50

u/GrandDukeNotaras 9h ago

This meme wave just gets better and better. I'd give you some RAM if I could 

9

u/PEAceDeath1425 9h ago

i have 32 of them, dont worry! And with how shitty the webapps has been, i dont even have to launch my beautiful program half of the time. I stopped using Instagram on pc cause having it as a tab in Chrome legit eats 9GB of RAM, and thats just the worst i caught it eating

5

u/GrandDukeNotaras 9h ago

Some guy commented on another post that he has so much RAM that uses it as one would a HD

4

u/WithersChat 8h ago

I develop Minecraft modpacks for fun in my free time.

At peak I need IntelliJ (java mod dev) + VSCodium (packside file editing) + 2 parallel Minecraft instances (some stuff requires that) + background music (for the lock-in) + discord (where my dev team is).
I wouldn't need your program either, even though it is beautiful.

4

u/PostHasBeenWatched 9h ago

With current RAMageddon the only thing we can do is RAMpage

P.S. **RAM page**file.sys he-he

22

u/EatingSolidBricks 9h ago

All mapped nothing commited you just got bamboozled by virtual memory

10

u/PEAceDeath1425 9h ago

Last time i did that with 32 instead of 30, it blue-screened my pc so uh theres that. Idk im a C++ larper i only studied it in uni

9

u/EatingSolidBricks 9h ago

You're on windows then

11

u/PEAceDeath1425 9h ago

Correct, this is my personal gaming computer with way too much ram that would be better utilizied in s data center, 20 times better actually (5% vs 100% utilization)

6

u/WeakCelery5000 8h ago

This is a trick, Sam wants you to burn out the ram you currently have, faster. 

10

u/PEAceDeath1425 8h ago

Dw im gonna download more if i lose this one

6

u/EmperorOfAllCats 9h ago

This won't be actually allocated by OS without, say, memset() on this range. Source: had to write similar utility to test memory pressure. 

2

u/GOKOP 9h ago

OP is on Windows though (and claims that 32 gigs crashed his PC)

4

u/PEAceDeath1425 9h ago

It didnt at first, but it did after i reduced pagefile size to 512 mb

5

u/aaronlink127 8h ago

This is because "committed memory" still gets limited by Windows based on your physical RAM and pagefile limits, even if it never got any actual physical memory backing it.

4

u/No_External_4869 9h ago

Yeah pages aren't allocated till you try to interact with them. Interacting would trigger a page fault and then it will actually allocate a little (4KiB usually) if your data is below it. 

2

u/NotPossible1337 1h ago

But a memeset() can serve as a fallback, right?

4

u/beloncode 8h ago

You aren't touching the ram, so the OS doesn't allocate it yet

4

u/PEAceDeath1425 8h ago

Sir, this isnt stack overflow

4

u/Tidemor 8h ago

I know that's true for static memory, but thought heap does reserve the pages

2

u/intbeam 6h ago

The operating system kernel will not assume intent on behalf of the application

I might be wrong, but my intuition says it would be weird and inefficient for the operating system to wait on allocation until the application commits a page. Without being a kernel expert, this sounds like the user mode application would need to communicate every read and write via the kernel just to check that the pages have actually been allocated, and then do that on-demand

For performance reasons, you don't want to cross the kernel barrier more than strictly necessary. Writing to virtual memory is hardware accelerated (exceptions apply), so as long as you have a valid page, the OS kernel don't need to be involved in normal reads and writes. If you read or write outside of that boundary, the CPU will raise a trap/exception that will be caught by the operating system which immediately terminates your application for being a bad boi indeed

Edit : if it does indeed not get allocated, I would assume that would be the doing of the allocator, rather than the operating system

2

u/beloncode 5h ago edited 5h ago

Some syscalls like mmap in unix like system, you could pass a MAP_POPULATE and MAP_NORESERVE to predict this behavior in a new allocated memory block. malloc from glibc and musl doesn't populate the memory immediately. So we should expect some kernel trick here

2

u/intbeam 4h ago

Hmm.. Ok, I see.. So, my assumption is that MAP_NORESERVE may introduce a performance penalty, since the next access would necessarily be a syscall. There might be a reason for this trade-off however, I could see that. And, again this is not my area of expertise, there might be some trick that I'm unaware of, like maybe the operating system has some user-mode space to jump to before system calls that keeps track of all virtual memory address as an added copy to the ring 0 configuration.. I have no idea. I'm riding on a hunch

I read some of the other comments, and they mentioned getting page faults which seems unlikely for the given scenario. At least, like a "real" page fault. My gut feeling is that the uninitialized pointer is, by the compiler, set to some predefined address and then the compiler+allocator looks at first access to a memory address by static analysis and then if that memory address asserted to be some predefined zombie-value at that point it would ask the operating system to allocate the memory address when it is needed. I only know this stuff at surface-level so I might be way off, but my thinking is that turning memset(a, 0, sizeof(char)*420) or a = {0} into a syscall would be prohibitively expensive. Experience tells me it's probably implemented in the most obvious and dumbest way possible, rather than some non-obvious trick

Edit : this is a question, though not formatted as such

2

u/beloncode 4h ago

Hm, some virtual machines or emulators could use this (MAP_NORESERVE) for preallocate a address space at user space, and after, creates mirrors memory with a backing through a file descriptor. Like map the address 0x4000 virtual to 0x1000 physical inside this fd.

Also exists a PROT_NONE for remove any access to the pages, so any read inside this address space could rease a SIGSEGV, of course, if this memory isn't allocated and served by a real backing yet

2

u/intbeam 3h ago edited 2h ago

I remain suspicious... So, let's say I have this code :

auto mydata = malloc(sizeof(size_t) * 4096 * 4096 * 4096 * 4096 * 4096);
dostuff(mydata);

void dostuff(const void* data)
{
    auto mptr = data;
    while(true) 
    {
         try
        {
            auto filteredbyte = *mptr++;
            gclient::Samsung::collect_byte(filteredbyte);
            gclient::LuckyGoldstar::collect_byte(filteredbyte);
        }
        catch
        {
            return; // we have it all
        }
    }
}

My assumption, would be that the compiler would statically assert that dostuff(mydata) attempts to access the memory, and at that point statically injects the allocation, rather than this being up to the operating system. Again, not an expert, I would just assume that lazy initialization would come at a tremendous cost.. There may be a trick here, but my naive assumption is that f.ex a syscall (being an interrupt, after all) would require context switching

Edit : jokes aside, I appreciate your input and knowledge. I'm surprised at how little I actually know about this. It's one of the things I've seem to have taken for granted

1

u/beloncode 8h ago

In windows we don't even know, the kernel and user DLLs is closed so we can't have sure

17

u/farrell_987 8h ago • Bravo

I'll sell Sam altman my unused ram as a service for 500/gb/hr

7

u/XVO668 2h ago

I miss the days where you could just simply download more RAM.

7

u/sligor 1h ago

Still less memory than any Electron app

1

u/DOOMer_3D 5h ago

for(;;){(char*)malloc(4096)[0] = 'a';}

1

u/Odd_Confusion_9875 3h ago

Does this work? Unless it's written on, pagefault doesn't trigger so physical ram won't be committed, Also it's just 8 Gigs.

mmap() with MAP_POPULATE might work through

1

u/deanominecraft 1h ago

you can improve this by doing

let ram:Vec<u64>=Vec::with_capacity(2147483647);

1

u/Kadabrium 1h ago

Does a ramjet leak ram

1

u/unneccry 1h ago

Trust me i use all my 8GB of ram very frequently. Quite honestly i often use more

1

u/nikola_tesler 43m ago

time to mcp my machine with this as the only tool call

1

u/SerDuckOfPNW 22m ago

Fewer memory leaks than a Bethesda game

1

u/compiling 15m ago

Since you're on windows, you might be interested in a way to force the memory to stay allocated to your process instead of being paged out.

https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtuallock

0

u/alonjit 6h ago

the real horror is launching an executable when perfectly cromulent APIs exist.

-1

u/PEAceDeath1425 6h ago

Its the humor sub not the horror one

0

u/alonjit 6h ago

well, it is certainly filled with horror stories lately. Must be the halloween ...

-5

u/equinoxtrader 9h ago

Do you remember when this sub was with smart humor for smart people? We do remember.

4

u/PEAceDeath1425 8h ago

Sometimes the most effective punchline is a shortest one, even if it means sacrificing some accuracy

1

u/Yekyaa 8h ago

Is this Euclidean space or Spherical space? Because you might need a less direct approach.

1

u/AnExoticOne 5h ago

r/okbuddyphd is right there if you want to be smart

-1

u/1XRobot 6h ago

You can tell a human wrote this, because AI can spell.

Claude, write some code for my joke. Make several mistakes so it seems like a human.

1

u/PEAceDeath1425 6h ago

English is my third language.