diff options
author | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-12 01:07:22 +0000 |
---|---|---|
committer | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-12 01:07:22 +0000 |
commit | 8316697801a73a14a2fe3845e0d0f5add63a18be (patch) | |
tree | 4b50ab2a0f9fa8e3d95e3c72e26eca17e29019c6 /src/expr/node_builder.h | |
parent | ced51432b424f23e9ecea71566777bcd4e042800 (diff) |
Changes to hashing that solve the xinetd boolean benchmark in 14s (from ~25min). Switched to standard hash_set, hash_map, new hash for the vector of node values (from boost), changed the hash for nodes to be over id's, all the hash values are now size_t. The parser is down from 11s to 10s on the benchmark, so most of the solve time is parsing and we need to figure this out.
Diffstat (limited to 'src/expr/node_builder.h')
-rw-r--r-- | src/expr/node_builder.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h index 765a2f493..ce56fc08c 100644 --- a/src/expr/node_builder.h +++ b/src/expr/node_builder.h @@ -192,7 +192,6 @@ public: Debug("prop") << "append: " << this << " " << n << "[" << n.d_ev << "]" << std::endl; allocateEvIfNecessaryForAppend(); NodeValue* ev = n.d_ev; - d_hash = NodeValue::computeHash(d_hash, ev); ev->inc(); d_ev->d_children[d_ev->d_nchildren++] = ev; return *this; @@ -587,7 +586,9 @@ NodeBuilder<nchild_thresh>::operator Node() {// not const // was malloc'ed or not if(EXPECT_FALSE( evIsAllocated() )) { - NodeValue *ev = d_nm->lookupNoInsert(d_hash, d_ev); + // Lookup the expression value in the pool we already have (with insert) + NodeValue* ev = d_nm->poolLookup(d_ev); + // If something else is there, we reuse it if(ev != NULL) { // expression already exists in node manager dealloc(); @@ -595,20 +596,19 @@ NodeBuilder<nchild_thresh>::operator Node() {// not const Debug("prop") << "result: " << Node(ev) << std::endl; return Node(ev); } - - // otherwise create the canonical expression value for this node + // Otherwise crop and set the expression value to the allocate one crop(); ev = d_ev; d_ev = NULL; - // this inserts into the NodeManager; - // return the result of lookup() in case another thread beat us to it d_used = true; - Node n = d_nm->lookup(d_hash, ev); + d_nm->poolInsert(ev); + Node n(ev); Debug("prop") << "result: " << n << std::endl; return n; } - NodeValue *ev = d_nm->lookupNoInsert(d_hash, &d_inlineEv); + // Lookup the expression value in the pool we already have + NodeValue* ev = d_nm->poolLookup(&d_inlineEv); if(ev != NULL) { // expression already exists in node manager d_used = true; @@ -630,12 +630,9 @@ NodeBuilder<nchild_thresh>::operator Node() {// not const d_used = true; d_ev = NULL; - // this inserts into the NodeManager; - // return the result of lookup() in case another thread beat us to it - if(ev->getNumChildren()) { - Debug("prop") << "ev first child: " << *ev->ev_begin() << std::endl; - } - Node n = d_nm->lookup(d_hash, ev); + // Make the new expression + d_nm->poolInsert(ev); + Node n(ev); Debug("prop") << "result: " << n << std::endl; return n; } |