logoalt Hacker News

pjc50today at 10:34 AM4 repliesview on HN

>> Peak memory consumption is 1.3 MB. At this point you might want to stop reading and make a guess on how much memory a native code version of the same functionality would use.

At this point I'd make two observations:

- how big is the text file? I bet it's a megabyte, isn't it? Because the "naive" way to do it is to read the whole thing into memory.

- all these numbers are way too small to make meaningful distinctions. Come back when you have a gigabyte. It gets more interesting when the file doesn't fit into RAM at all.

The state of the art here is : https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times... , wherein our hero finds the terrible combination of putting the whole file in a single string and then running strlen() on it for every character.


Replies

dgb23today at 11:11 AM

> all these numbers are way too small to make meaningful distinctions. Come back when you have a gigabyte.

I have to disagree. Bad performance is often a result of a death of a thousands cuts. This function might be one among countless similarly inefficient library calls, programs and so on.

show 1 reply
klooptoday at 12:45 PM

> how big is the text file? I bet it's a megabyte, isn't it?

The edit in the article says ~1.5kb

show 1 reply
hrmtst93837today at 7:11 PM

[dead]