1

In Java, are there equivalences to functions such as GNU C extensions prefetch and align(64), that is, cache line alignment?

1

2 Answers 2

2

Not that I know of because it doesn't make sense in a compile-on-demand system. With Java, it's the run-time optimizer's job to figure this stuff out and the best result is going to depend on the current platform which may or may not benefit from the constructs that prefetch and align offer.

Sign up to request clarification or add additional context in comments.

3 Comments

I thought so. I guess having a GC won't help either, in Java objects may change addresses, I guess? I'm wondering if I should care about it at all, or just leave it to the runtime, as I leave scheduling to the OS...
Addresses could change, or rather you would have no way of knowing. That is all abstracted away to the point that all you can see if a reference id.
Most of the time you probably don't need to care. Sometimes it can matter though, which is why it would be nice to see an answer to this question. It is possible in Java, just not with the cache prefetch instruction. You could probably read some data from each cache line you're interested in, but you'll have to do it in a way that can't be optimized away by the JVM.
0

1- that's not how it works: if you read data, you're waiting for the result, and that's the point of ptefetching: you don't wait for it now, and with a bit of luck you don't wait at all

2- if the JVM is doing a decent job, there are few enough extra memory access that the cache isn't full: think of a heap for example, that has more or less predictable reads for the code, but not for the memory subsystem

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.