Logo Search packages:      
Sourcecode: scala version File versions  Download package

void scala::actors::FJTaskRunnerGroup::stats (  )  [inline]

Prints various snapshot statistics to System.out.

  • For each FJTaskRunner thread (labeled as Tn, for n from zero to group size - 1):
    • A star "*" is printed if the thread is currently active; that is, not sleeping while waiting for work. Because threads gradually enter sleep modes, an active thread may in fact be about to sleep (or wake up).
    • Q Cap The current capacity of its task queue.
    • Run The total number of tasks that have been run.
    • New The number of these tasks that were taken from either the entry queue or from other thread queues; that is, the number of tasks run that were not forked by the thread itself.
    • Scan The number of times other task queues or the entry queue were polled for tasks.
  • Execute The total number of tasks entered (but not necessarily yet run) via execute or invoke.
  • Time Time in seconds since construction of this FJTaskRunnerGroup.
  • Rate The total number of tasks processed per second across all threads. This may be useful as a simple throughput indicator if all processed tasks take approximately the same time to run.

Cautions: Some statistics are updated and gathered without synchronization, so may not be accurate. However, reported counts may be considered as lower bounds of actual values. Some values may be zero if classes are compiled with COLLECT_STATS set to false. (FJTaskRunner and FJTaskRunnerGroup classes can be independently compiled with different values of COLLECT_STATS.) Also, the counts are maintained as ints so could overflow in exceptionally long-lived applications.

These statistics can be useful when tuning algorithms or diagnosing problems. For example:

  • High numbers of scans may mean that there is insufficient parallelism to keep threads busy. However, high scan rates are expected if the number of Executes is also high or there is a lot of global synchronization in the application, and the system is not otherwise busy. Threads may scan for work hundreds of times upon startup, shutdown, and global synch points of task sets.
  • Large imbalances in tasks run across different threads might just reflect contention with unrelated threads on a system (possibly including JVM threads such as GC), but may also indicate some systematic bias in how you generate tasks.
  • Large task queue capacities may mean that too many tasks are being generated before they can be run. Capacities are reported rather than current numbers of tasks in queues because they are better indicators of the existence of these kinds of possibly-transient problems. Queue capacities are resized on demand from their initial value of 4096 elements, which is much more than sufficient for the kinds of applications that this framework is intended to best support.

Definition at line 461 of file FJTaskRunnerGroup.java.

References scala::actors::FJTaskRunner::deqSize(), entries, getActive(), initTime, scala::actors::FJTaskRunner::runs, scala::actors::FJTaskRunner::scans, scala::actors::FJTaskRunner::steals, and threads.

    long time = System.currentTimeMillis() - initTime;
    double secs = ((double)time) / 1000.0;
    long totalRuns = 0;
    long totalScans = 0;
    long totalSteals = 0;

    System.out.print("Thread" +
                     "\tQ Cap" +
                       "\tScans" +
                       "\tNew" +
                       "\tRuns" +

    for (int i = 0; i < threads.length; ++i) {
      FJTaskRunner t = threads[i];
      int truns = t.runs;
      totalRuns += truns;

      int tscans = t.scans;
      totalScans += tscans;

      int tsteals = t.steals;
      totalSteals += tsteals;

      String star = (getActive(t))? "*" : " ";

      System.out.print("T" + i + star +
                       "\t" + t.deqSize() +
                       "\t" + tscans +
                       "\t" + tsteals +
                       "\t" + truns +

    System.out.print("Total" +
                     "\t    " +
                     "\t" + totalScans +
                     "\t" + totalSteals +
                     "\t" + totalRuns +

    System.out.print("Execute: " + entries); 
    System.out.print("\tTime: " + secs);

    long rps = 0;
    if (secs != 0) rps = Math.round((double)(totalRuns) / secs);

    System.out.println("\tRate: " + rps);

Generated by  Doxygen 1.6.0   Back to index