1

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

Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217
  • possible duplicate of [prefetch instruction in JVM/JAVA](http://stackoverflow.com/questions/22689712/prefetch-instruction-in-jvm-java) – Eloff Apr 24 '14 at 19:21

1 Answers1

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.

Andrew White
  • 52,720
  • 19
  • 113
  • 137
  • 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... – Dervin Thunk Apr 07 '12 at 17:06
  • 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. – Andrew White Apr 07 '12 at 17:07
  • 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. – Eloff Apr 24 '14 at 19:19