Skip to content

API for fetching Cache Line size for current CPU architecture #131703

Description

@JakeYallop

I was looking at #131696

From the comment in code the PR:

64 is the size of a cache line on many systems; larger ones may see a little more false sharing.

I think there may have been discussions in the past about this. I've found this: https://lemire.me/blog/2023/12/12/measuring-the-size-of-the-cache-line-empirically/ that suggests that at least M2 chips (and likely, M-series chips) have a cache line of 128 bytes.

If this differing cache line size is going to start cropping up, does it suggest the need for an API to retrieve this value?

There seems to be quite a few hits: https://github.com/search?q=%2F%28CacheLine%7CCACHE_LINE%7Ccache+line%29%2F+language%3AC%23+&type=code

I know that the runtime already has its own internal constant.

For this hypothetical API to be useful, it would need to adjust the value it returns based on the architecture its running on.

This is just a discussion instead of a concrete API proposal right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions