I am reading What every programmer should know about memory and I am struggling with the notions of CPU cache tags (page 15.).
If I understand correctly, each CPU cache line has a tag, which specifies to which data in main memory the given line corresponds to. That is, if you write to a particular line, you use the tag to find out where in RAM should you write the contents of this line to. Conversely, if you read data from RAM into a L1 cache line, you compute a tag from the RAM address and store it somewhere, such that you know where the data in the L1 cache line came from. A tag is something like a pointer.
I would like to ask if this tag itself is written somewhere in the cache line, or is there some special memory next to the L1 cache to store the tag?
In my system, the L1 line size is 64 bytes and a ponter is 8 bytes. Should I aim to make frequently iterated objects in my program to be not more than 64 bytes? Or, given that the size of the tag should not be greater than the size of a pointer, should I aim for 56 bytes?