comparison src/share/vm/classfile/symbolTable.cpp @ 10991:01522ca68fc7

8015237: Parallelize string table scanning during strong root processing Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>. Reviewed-by: tschatzl, stefank, twisti
author johnc
date Tue, 18 Jun 2013 12:31:07 -0700
parents 8dbc025ff709
children 63147986a428 2c022e432e10
comparison
equal deleted inserted replaced
10990:0abfeed51c9e 10991:01522ca68fc7
596 // -------------------------------------------------------------------------- 596 // --------------------------------------------------------------------------
597 StringTable* StringTable::_the_table = NULL; 597 StringTable* StringTable::_the_table = NULL;
598 598
599 bool StringTable::_needs_rehashing = false; 599 bool StringTable::_needs_rehashing = false;
600 600
601 volatile int StringTable::_parallel_claimed_idx = 0;
602
601 // Pick hashing algorithm 603 // Pick hashing algorithm
602 unsigned int StringTable::hash_string(const jchar* s, int len) { 604 unsigned int StringTable::hash_string(const jchar* s, int len) {
603 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) : 605 return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
604 java_lang_String::hash_code(s, len); 606 java_lang_String::hash_code(s, len);
605 } 607 }
759 entry = *p; 761 entry = *p;
760 } 762 }
761 } 763 }
762 } 764 }
763 765
764 void StringTable::oops_do(OopClosure* f) { 766 void StringTable::buckets_do(OopClosure* f, int start_idx, int end_idx) {
765 for (int i = 0; i < the_table()->table_size(); ++i) { 767 const int limit = the_table()->table_size();
768
769 assert(0 <= start_idx && start_idx <= limit,
770 err_msg("start_idx (" INT32_FORMAT ") oob?", start_idx));
771 assert(0 <= end_idx && end_idx <= limit,
772 err_msg("end_idx (" INT32_FORMAT ") oob?", end_idx));
773 assert(start_idx <= end_idx,
774 err_msg("Ordering: start_idx=" INT32_FORMAT", end_idx=" INT32_FORMAT,
775 start_idx, end_idx));
776
777 for (int i = start_idx; i < end_idx; i += 1) {
766 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i); 778 HashtableEntry<oop, mtSymbol>* entry = the_table()->bucket(i);
767 while (entry != NULL) { 779 while (entry != NULL) {
768 assert(!entry->is_shared(), "CDS not used for the StringTable"); 780 assert(!entry->is_shared(), "CDS not used for the StringTable");
769 781
770 f->do_oop((oop*)entry->literal_addr()); 782 f->do_oop((oop*)entry->literal_addr());
771 783
772 entry = entry->next(); 784 entry = entry->next();
773 } 785 }
786 }
787 }
788
789 void StringTable::oops_do(OopClosure* f) {
790 buckets_do(f, 0, the_table()->table_size());
791 }
792
793 void StringTable::possibly_parallel_oops_do(OopClosure* f) {
794 const int ClaimChunkSize = 32;
795 const int limit = the_table()->table_size();
796
797 for (;;) {
798 // Grab next set of buckets to scan
799 int start_idx = Atomic::add(ClaimChunkSize, &_parallel_claimed_idx) - ClaimChunkSize;
800 if (start_idx >= limit) {
801 // End of table
802 break;
803 }
804
805 int end_idx = MIN2(limit, start_idx + ClaimChunkSize);
806 buckets_do(f, start_idx, end_idx);
774 } 807 }
775 } 808 }
776 809
777 void StringTable::verify() { 810 void StringTable::verify() {
778 for (int i = 0; i < the_table()->table_size(); ++i) { 811 for (int i = 0; i < the_table()->table_size(); ++i) {