7158800: Improve storage of symbol tables

Use an alternate version of hashing algorithm for symbol string tables and after a certain bucket size to improve performance

Reviewed-by: pbk, kamg, dlong, kvn, fparain
This commit is contained in:
Coleen Phillimore 2012-06-13 19:52:59 -04:00
parent 7c17e9e75b
commit 55b09e7016
17 changed files with 32031 additions and 55 deletions

View file

@ -40,6 +40,7 @@
// - symbolTableEntrys are allocated in blocks to reduce the space overhead.
class BoolObjectClosure;
class outputStream;
// Class to hold a newly created or referenced Symbol* temporarily in scope.
@ -78,6 +79,10 @@ private:
// The symbol table
static SymbolTable* _the_table;
// Set if one bucket is out of balance due to hash algorithm deficiency
static bool _needs_rehashing;
static jint _seed;
// For statistics
static int symbols_removed;
static int symbols_counted;
@ -119,6 +124,11 @@ private:
static Arena* arena() { return _arena; } // called for statistics
static void initialize_symbols(int arena_alloc_size = 0);
static bool use_alternate_hashcode() { return _seed != 0; }
static jint seed() { return _seed; }
unsigned int new_hash(Symbol* sym);
public:
enum {
symbol_alloc_batch_size = 8,
@ -146,6 +156,8 @@ public:
initialize_symbols();
}
static unsigned int hash_symbol(const char* s, int len, unsigned int hashValue = 0);
static Symbol* lookup(const char* name, int len, TRAPS);
// lookup only, won't add. Also calculate hash.
static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
@ -208,6 +220,7 @@ public:
// Debugging
static void verify();
static void dump(outputStream* st);
// Sharing
static void copy_buckets(char** top, char*end) {
@ -219,8 +232,13 @@ public:
static void reverse(void* boundary = NULL) {
the_table()->Hashtable<Symbol*>::reverse(boundary);
}
// Rehash the symbol table if it gets out of balance
static void rehash_table();
static bool needs_rehashing() { return _needs_rehashing; }
};
class StringTable : public Hashtable<oop> {
friend class VMStructs;
@ -228,6 +246,10 @@ private:
// The string table
static StringTable* _the_table;
// Set if one bucket is out of balance due to hash algorithm deficiency
static bool _needs_rehashing;
static jint _seed;
static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
oop basic_add(int index, Handle string_or_null, jchar* name, int len,
unsigned int hashValue, TRAPS);
@ -241,6 +263,10 @@ private:
: Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t,
number_of_entries) {}
static bool use_alternate_hashcode() { return _seed != 0; }
static jint seed() { return _seed; }
unsigned int new_hash(oop s);
public:
// The string table
static StringTable* the_table() { return _the_table; }
@ -265,6 +291,14 @@ public:
// Invoke "f->do_oop" on the locations of all oops in the table.
static void oops_do(OopClosure* f);
// Hashing algorithm, used as the hash value used by the
// StringTable for bucket selection and comparison (stored in the
// HashtableEntry structures). This is used in the String.intern() method.
static unsigned int hash_string(const jchar* s, int len, unsigned int hashValue = 0);
// Internal test.
static void test_alt_hash() PRODUCT_RETURN;
// Probing
static oop lookup(Symbol* symbol);
@ -275,6 +309,7 @@ public:
// Debugging
static void verify();
static void dump(outputStream* st);
// Sharing
static void copy_buckets(char** top, char*end) {
@ -286,6 +321,9 @@ public:
static void reverse() {
the_table()->Hashtable<oop>::reverse();
}
};
// Rehash the symbol table if it gets out of balance
static void rehash_table();
static bool needs_rehashing() { return _needs_rehashing; }
};
#endif // SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP