• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory visibility testing  RSS feed

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!