Mercurial > hg > truffle
comparison src/share/vm/utilities/taskqueue.hpp @ 546:05c6d52fa7a9
6690928: Use spinning in combination with yields for workstealing termination.
Summary: Substitute a spin loop for most calls to yield() to reduce the stress on the system.
Reviewed-by: tonyp
author | jmasa |
---|---|
date | Sun, 08 Feb 2009 13:18:01 -0800 |
parents | 23673011938d |
children | 0fbdb4381b99 |
comparison
equal
deleted
inserted
replaced
545:58054a18d735 | 546:05c6d52fa7a9 |
---|---|
424 }; | 424 }; |
425 | 425 |
426 // A class to aid in the termination of a set of parallel tasks using | 426 // A class to aid in the termination of a set of parallel tasks using |
427 // TaskQueueSet's for work stealing. | 427 // TaskQueueSet's for work stealing. |
428 | 428 |
429 #undef TRACESPINNING | |
430 | |
429 class ParallelTaskTerminator: public StackObj { | 431 class ParallelTaskTerminator: public StackObj { |
430 private: | 432 private: |
431 int _n_threads; | 433 int _n_threads; |
432 TaskQueueSetSuper* _queue_set; | 434 TaskQueueSetSuper* _queue_set; |
433 int _offered_termination; | 435 int _offered_termination; |
436 | |
437 #ifdef TRACESPINNING | |
438 static uint _total_yields; | |
439 static uint _total_spins; | |
440 static uint _total_peeks; | |
441 #endif | |
434 | 442 |
435 bool peek_in_queue_set(); | 443 bool peek_in_queue_set(); |
436 protected: | 444 protected: |
437 virtual void yield(); | 445 virtual void yield(); |
438 void sleep(uint millis); | 446 void sleep(uint millis); |
460 // The caller is responsible for ensuring that this is done | 468 // The caller is responsible for ensuring that this is done |
461 // in an MT-safe manner, once the previous round of use of | 469 // in an MT-safe manner, once the previous round of use of |
462 // the terminator is finished. | 470 // the terminator is finished. |
463 void reset_for_reuse(); | 471 void reset_for_reuse(); |
464 | 472 |
473 #ifdef TRACESPINNING | |
474 static uint total_yields() { return _total_yields; } | |
475 static uint total_spins() { return _total_spins; } | |
476 static uint total_peeks() { return _total_peeks; } | |
477 static void print_termination_counts(); | |
478 #endif | |
465 }; | 479 }; |
466 | 480 |
467 #define SIMPLE_STACK 0 | 481 #define SIMPLE_STACK 0 |
468 | 482 |
469 template<class E> inline bool GenericTaskQueue<E>::push(E t) { | 483 template<class E> inline bool GenericTaskQueue<E>::push(E t) { |