Hacker News new | past | comments | ask | show | jobs | submit login

Cache lines on modern architectures are usually 64 or sometimes even 128 bytes, not bits.



Thank you, I misread this from the article as saying 64 bit cache lines: "(assuming 32 bit pointers and 64 byte cache lines)"

So:

byte otherMembers[64];

is 512bits of addresses to other members, that will hold 16 32bit addresses.

From the article: "In the case of an array with pointers there may still be a cache miss when reading the ‘valid’ flag but there will be at most one additional cache miss every 16 pointers"

so idList must use operator[] to sensibly iterate over otherMembers.

class idMyClass {

    bool valid;
    byte otherMembers[64]; // over a cache line worth of other members
};

idList< idMyClass * > myObjects;

for ( int i = 0; i < myObjects.Num(); i++ ) {

    if (myObjects[i]>valid ) {
    }

}




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

Search: