• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Memory visibility testing

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you suspect issues with thread memory caching in a legacy codebase, what's the best way to shake them out? Is there a way to get a JVM to avoid main memory writes whenever possible -- or maybe someone has a specially-made testing JVM that acts this way?
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've read that the VM selected by the -server option in the JDK is more likely to trigger concurrency issues. A multi-core system will also help, since the individual CPUs won't be immediately flushing values from their caches even when the JVM has written modified values.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting, was there a symptom which helped conclude that this may be a memory ordering problem? instead of just a standard race-condition?

Henry
 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you could try ...

- IBM's ConTest to instrument your code before you run your tests. Though I must admit I have coded some non JSR 133 compliant code that got away with it that still passed.

- or I've been playing with the idea of running tests with terracotta (java on clustered PC's) as it requires no libs just config and you can state the bits of memory you expect shared and they should then be shared cross PCs with memory going over the wires only on hitting memory barriers etc. I'm still not sure how practical this is as you still have to force threads via it onto differing PC's, currently all threads would start up on all PC's , you can program round this with things like singletons but I didn't want any special code for the test , I'm sure they could write a very nice testing tool, maybe use annotation to suggest to terracota what to do with the threads in a test scenario.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a bug which shows up only on the IBM 64-bit J9 VM, and only on multiprocessor machines. It happens on perhaps 2% of runs; when it happens, it always happens in the same way, at the same point. There are currently two theories about what's happening, and we're still trying to get the debug info we need to figure out which. One explanation is a JIT bug in J9; the other is a memory ordering issue.

The thing is, though, we can see some places in the code where visibility issues could be coming up. We say "could" because the writes and reads are so far apart, with so much related code in between, that it's hard to believe that a common lock hasn't been held at some point.
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic