Hacker Newsnew | past | comments | ask | show | jobs | submit | coolThingsFirst's commentslogin

the bar is higher and higher for less and less. donezo as a career.

Giant of a man standing at 5'10, felt no need to ever lie about my height.

Overkill. React mogs.

Why doesn’t the machine fill up the other cache lines as well why is 64 bytes only and then a miss?

A cache line is simply the unit of data a CPU cache works with (generally 64 bytes, because someone somewhere has probably determined that that is the best line size for general use), much like there are units of data like bytes (8 bits nowadays, but there have been weird ones historically), pages (varies between hardware as well, and may be OS-configurable), etc.

As TFA mentions, a CPU does some predictions about what cache lines to prefetch, e.g. when you do sequential reads. Moreover, the x86_64 instruction set provides a prefetch instruction through which you are able to give the CPU a hint "hey, I'm gonna be using this soon, prepare accordingly, pretty please".

Still, the utility of prefetching is diminished if you only use a single byte from each cache line, because the mechanism generally depends on you doing other work while the next cache line is being fetched. So really the best case scenario is to take as much time as possible to work with what is already fetched, so that there is time for the next unit of data to be fetched in the meantime.


They will absolutely do that (prefetching, they can even eagerly load what’s on the other side of a pointer).

However it requires additional hardware to recognize patterns which benefit from prefetching, and every time the CPU prefetches data which ends up not being used it has both burned energy and memory bandwidth, and evicted data from the cache which might be needed (cache pollution).


It might sometimes prefetch the surrounding lines as well, but ultimately cache space is limited, so there is a trade-off. Every time you fill a line, you are throwing away something else that was cached there previously, which you may need again in the near future.

Beside the point, why is the US in decline?

C is pretty bizarre but I expect someone writing it professionally to know that even passing void compareStrings(char str1[], char str2[]) is equivalent to compareStrings(char * str1, char * str2) so no way to get the length of it with sizeof(str1) and strlen walks the string until it finds the null terminator.

No, it's not bizarre, it's standardized on what is and isn't UB based on history, and usually for performance.

NUL-terminated strings don't know their lengths and so, without an "n" variant function and running strlen() ahead-of-time, must iterate the entire thing. Pascal format strings (supported up to 255 byte lengths in the classic form) could find length as an O(1) operation because there was no terminator necessarily.


It is bizarre. C is bizarre, there is no string type and there should've been a string type. scanf is an invitation for buffer overflow attacks. I know how poorly designed languages look like and C despite its strengths is still a poorly designed language.

today it's paxos/raft questions for an internship writing Next.js for 10$ an hour.

If I may guess, this is for a web3 internship?

I know, especially, unemployed cats.

Yes, the next year off as well because they will fire you.

spill the tea, fired or quit?


Wasn't enough room at Twitter for those two egos.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: