CNDTHAUserView

Thread Analyzer User View

User

"Stevens & Leons" - users who want IDE to help them to quickly and intuitively narrow-down to the code that is wrong from the multithreading point of view. They are not going to spend much time on analyzing the code for "potential" problems, still they would like to get notification about existence of such problems. The clearer results are displayed - the happier our users are ;)

Issue the feature solves

Multithreading is a powerful tool which can help to dramatically improve the responsiveness and performance of programs. But this approach requires deeper understanding of program's data flows. Usually programmers face with a number of multi-threading-related problems. Among them "race condition" and "deadlocks". The fact that these problems are usually timing-specific, they are not easy reproducible. THA not only states about problems that occur during program execution, but also helps to detect *potential* problems in the code. For more information: http://docs.sun.com/app/docs/doc/820-0619/geeho?a=view

Scenarios

As this type of analyzing requires additional compilation flags and has significant (see "Performance measurements") performance penalty, this information should not be started by default on project start.

There should be some additional button/menu item that starts an experiment.

Races

  • Scenario:
  • User selects "Analyze concurrent memory access" menu item
  • Program should be re-compiled and data collection should start. (?Q? Recompilation in case of Makefile-based projects).
  • Report is generated

I would propose text report with hyper-links to navigate to the code. Something like:

Following concurrent memory access problems detected:

-+- 3 Concurrent accesses to address <XXX>(*)
 |
 +- 1 Concurrent access to address <YYY>
 |
 +- 2 Concurrent accesses to address <ZZZ>

(*) if we know variable name - we may include it here.

  • When there is only one concurrent access ... line is clickable (?)
  • User may expand any node and see all pairs of access ...

Following concurrent memory access problems detected:

-+- 3 Concurrent accesses to address <XXX>
 |  |
 |  +- parallel.c:102(*) (work()) [[R | R]] / parallel.c:102 (work()) [W](**)
 |  |
 |  +- parallel.c:102 (work()) [[R | R]] / someFile.c:11  (test()) [W]
 |  |
 |  +- parallel.c:102 (work()) [[W | W]] / someFile.c:11  (test()) [W]
 |
 |
 +- 1 Concurrent access to address <YYY>
 |  |
 |  +- prime_pthr.c:61 (main()) [[W | W]] / prime_pthr.c:41 (work()) [R] 
 |
 |
 +- 2 Concurrent accesses to address <ZZZ>
    |
    +- prime_pthr.c:46 (work()) [[W | W]] / prime_pthr.c:46 (work()) [W] (***)
    |
    +- prime_pthr.c:46 (work()) [[W | W]] / prime_pthr.c:46 (work()) [W] 

(*) link to a source code
(**) links to call-stacks (click on a link will open call stack window). R - means read access; W - means write access;
(***) here we have different pairs of call stacks (they all are at the same line, but paths to that line differ)

  • User may click on a line to switch to dual source view (?)
  • Annotations in user's code (?)


Locks

Thread Analyzer Engine characteristics

May require additional system patches. On my Solaris 10u4 I had to install patches 119964 and 120754.

races collection requires additional flag - -xinstrument=datarace.

'collect -r race' can not attach to PID, but can be run/suspended on signal ('-y SIG ,r' where 'r' means begin in run-mode ).

'collect -r race' can not coexist with another startup flags (like memory leak detection or hotspots detection)

Performance measurements:

  • Sample project: Buddhabrot, with ONLY ONE synchronization - when jobs are allocated. No synchronization on "tracks" storing.
  • Run Performance release configuration:
real    0m2.887s
user    0m5.376s
sys     0m0.006s
  • Run THA configuration (compiled with -xinstrument=datarace):
real    0m26.793s
user    0m56.002s
sys     0m0.017s

* 10 times slower.

</div>

  • Collecting races data: (collect -r race ./dist/..../THA/..../buddhabrot)
real    67m59.084s
user    133m12.279s
sys     0m4.087s

* 1300 times slower.

  • Collected experiment size: 1,6 Mb
  • Result of experiment:
bash-3.00$ er_print tha.4.er/
(/opt/SUNWspro/bin/../prod/bin/amd64/er_print) rdetail all

Total Races:  2 Experiment:  tha.4.er

Race #1, Vaddr: (Multiple Addresses)
      Access 1: Write, work + 0x000013A5,
                       line 102 in "parallel.c"
      Access 2: Read,  work + 0x00001357,
                       line 102 in "parallel.c"
  Total Traces: 1
  Trace 1
      Access 1: Write
                work + 0x000013A5, line 102 in "parallel.c"
                thread_hj_start_routine + 0x00000067
                _thr_setup + 0x0000004C
                _lwp_start + 0x00000000
      Access 2: Read
                work + 0x00001357, line 102 in "parallel.c"
                thread_hj_start_routine + 0x00000067
                _thr_setup + 0x0000004C
                _lwp_start + 0x00000000

Race #2, Vaddr: (Multiple Addresses)
      Access 1: Write, work + 0x000013A5,
                       line 102 in "parallel.c"
      Access 2: Write, work + 0x000013A5,
                       line 102 in "parallel.c"
  Total Traces: 1
  Trace 1
      Access 1: Write
                work + 0x000013A5, line 102 in "parallel.c"
                thread_hj_start_routine + 0x00000067
                _thr_setup + 0x0000004C
                _lwp_start + 0x00000000
      Access 2: Write
                work + 0x000013A5, line 102 in "parallel.c"
                thread_hj_start_routine + 0x00000067
                _thr_setup + 0x0000004C
                _lwp_start + 0x00000000
(/opt/SUNWspro/bin/../prod/bin/amd64/er_print)

</span>


Limitations

SunStudio collector required

Screen shots

http://wiki.netbeans.org/attach/CNDTHAUserView/profiler_integration_CNDTHAUserView.png

http://wiki.netbeans.org/attach/CNDTHAUserView/runTHA_CNDTHAUserView.png

Current UI snapshots taken from SunStudio

http://wiki.netbeans.org/attach/CNDTHAUserView/tha_deadlocks_CNDTHAUserView.png

http://wiki.netbeans.org/attach/CNDTHAUserView/tha_races_CNDTHAUserView.png

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo