3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

reset cache in ast_translation periodically to avoid congestion

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-12-15 07:21:37 -08:00
parent 6b258578f9
commit 030868d8de
5 changed files with 97 additions and 27 deletions

View file

@ -24,11 +24,12 @@ Revision History:
#include<limits.h>
#include "util/memory_manager.h"
#include "util/hash.h"
#include "util/vector.h"
#define DEFAULT_HASHTABLE_INITIAL_CAPACITY 8
#define SMALL_TABLE_CAPACITY 64
// #define HASHTABLE_STATISTICS
// #define HASHTABLE_STATISTICS
#ifdef HASHTABLE_STATISTICS
#define HS_CODE(CODE) { CODE }
@ -375,8 +376,7 @@ public:
} ((void) 0)
void insert(data && e) {
if ((m_size + m_num_deleted) << 2 > (m_capacity * 3)) {
// if ((m_size + m_num_deleted) * 2 > (m_capacity)) {
if (((m_size + m_num_deleted) << 2) > (m_capacity * 3)) {
expand_table();
}
unsigned hash = get_hash(e);
@ -488,7 +488,9 @@ public:
else if (curr->is_free()) { \
return 0; \
} \
HS_CODE(const_cast<core_hashtable*>(this)->m_st_collision++;); \
else { \
HS_CODE(const_cast<core_hashtable*>(this)->m_st_collision++;); \
} \
} ((void) 0)
entry * find_core(data const & e) const {
@ -655,7 +657,33 @@ public:
unsigned long long get_num_collision() const { return 0; }
#endif
#define COLL_LOOP_BODY() { \
if (curr->is_used()) { \
if (curr->get_hash() == hash && equals(curr->get_data(), e)) return; \
collisions.push_back(curr->get_data()); \
continue; \
} \
else if (curr->is_free()) { \
continue; \
} \
collisions.push_back(curr->get_data()); \
} ((void) 0);
void get_collisions(data const& e, vector<data>& collisions) {
unsigned hash = get_hash(e);
unsigned mask = m_capacity - 1;
unsigned idx = hash & mask;
entry * begin = m_table + idx;
entry * end = m_table + m_capacity;
entry * curr = begin;
for (; curr != end; ++curr) {
COLL_LOOP_BODY();
}
for (curr = m_table; curr != begin; ++curr) {
COLL_LOOP_BODY();
}
}
};
template<typename T, typename HashProc, typename EqProc>

View file

@ -204,6 +204,14 @@ public:
unsigned long long get_num_collision() const { return m_table.get_num_collision(); }
void get_collisions(Key * k, vector<Key*>& collisions) {
vector<key_data> cs;
m_table.get_collisions(key_data(k), cs);
for (key_data const& kd : cs) {
collisions.push_back(kd.m_key);
}
}
void swap(obj_map & other) {
m_table.swap(other.m_table);
}