Commit 518a63c2 authored by pekka@mysql.com's avatar pekka@mysql.com

tux optim 4 - update prefixes at once (prepare to remove node cache)

parent 5fd214dc
......@@ -505,17 +505,10 @@ private:
struct NodeHandle;
friend struct NodeHandle;
struct NodeHandle {
enum Flags {
// bits 0,1 mark need for left,right prefix
DoInsert = (1 << 2),
DoDelete = (1 << 3),
DoUpdate = (1 << 4)
};
Dbtux& m_tux; // this block
Frag& m_frag; // fragment using the node
TupLoc m_loc; // physical node address
AccSize m_acc; // accessed size
unsigned m_flags; // flags
union {
Uint32 m_next; // next active node under fragment
Uint32 nextPool;
......@@ -675,7 +668,7 @@ private:
void insertNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, AccSize acc);
void deleteNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr);
void accessNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, AccSize acc);
void setNodePref(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, unsigned i);
void setNodePref(Signal* signal, Frag& frag, NodeHandle& node, unsigned i);
void commitNodes(Signal* signal, Frag& frag, bool updateOk);
/*
......@@ -1096,7 +1089,6 @@ Dbtux::NodeHandle::NodeHandle(Dbtux& tux, Frag& frag) :
m_frag(frag),
m_loc(),
m_acc(AccNone),
m_flags(0),
m_next(RNIL),
m_node(0)
{
......@@ -1176,7 +1168,6 @@ Dbtux::NodeHandle::setLink(unsigned i, TupLoc loc)
ndbrequire(i <= 2);
m_node->m_linkPI[i] = loc.m_pageId;
m_node->m_linkPO[i] = loc.m_pageOffset;
m_flags |= DoUpdate;
}
inline void
......@@ -1184,7 +1175,6 @@ Dbtux::NodeHandle::setSide(unsigned i)
{
ndbrequire(i <= 2);
m_node->m_side = i;
m_flags |= DoUpdate;
}
inline void
......@@ -1193,7 +1183,6 @@ Dbtux::NodeHandle::setOccup(unsigned n)
TreeHead& tree = m_frag.m_tree;
ndbrequire(n <= tree.m_maxOccup);
m_node->m_occup = n;
m_flags |= DoUpdate;
}
inline void
......@@ -1201,14 +1190,12 @@ Dbtux::NodeHandle::setBalance(int b)
{
ndbrequire(abs(b) <= 1);
m_node->m_balance = b;
m_flags |= DoUpdate;
}
inline void
Dbtux::NodeHandle::setNodeScan(Uint32 scanPtrI)
{
m_node->m_nodeScan = scanPtrI;
m_flags |= DoUpdate;
}
// parameters for methods
......
......@@ -355,7 +355,6 @@ operator<<(NdbOut& out, const Dbtux::NodeHandle& node)
out << "[NodeHandle " << hex << &node;
out << " [loc " << node.m_loc << "]";
out << " [acc " << dec << node.m_acc << "]";
out << " [flags " << hex << node.m_flags << "]";
out << " [node " << *node.m_node << "]";
if (node.m_acc >= Dbtux::AccPref) {
for (unsigned i = 0; i <= 1; i++) {
......
......@@ -140,7 +140,6 @@ Dbtux::insertNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, AccSize ac
tmpPtr.p->m_next = frag.m_nodeList;
frag.m_nodeList = tmpPtr.i;
tmpPtr.p->m_acc = acc;
tmpPtr.p->m_flags |= NodeHandle::DoInsert;
nodePtr = tmpPtr;
}
......@@ -159,7 +158,6 @@ Dbtux::deleteNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr)
// invalidate handle and storage
tmpPtr.p->m_loc = NullTupLoc;
tmpPtr.p->m_node = 0;
tmpPtr.p->m_flags |= NodeHandle::DoDelete;
// scans have already been moved by popDown or popUp
}
......@@ -169,7 +167,6 @@ Dbtux::deleteNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr)
void
Dbtux::accessNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, AccSize acc)
{
TreeHead& tree = frag.m_tree;
NodeHandlePtr tmpPtr = nodePtr;
ndbrequire(tmpPtr.p->m_loc != NullTupLoc && tmpPtr.p->m_node != 0);
if (tmpPtr.p->m_acc >= acc)
......@@ -182,13 +179,12 @@ Dbtux::accessNode(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, AccSize ac
* Set prefix.
*/
void
Dbtux::setNodePref(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, unsigned i)
Dbtux::setNodePref(Signal* signal, Frag& frag, NodeHandle& node, unsigned i)
{
TreeHead& tree = frag.m_tree;
NodeHandlePtr tmpPtr = nodePtr;
ReadPar readPar;
ndbrequire(i <= 1);
readPar.m_ent = tmpPtr.p->getMinMax(i);
readPar.m_ent = node.getMinMax(i);
readPar.m_first = 0;
readPar.m_count = frag.m_numAttrs;
// leave in signal data
......@@ -200,9 +196,8 @@ Dbtux::setNodePref(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, unsigned
copyPar.m_items = readPar.m_count;
copyPar.m_headers = true;
copyPar.m_maxwords = tree.m_prefSize;
Data pref = tmpPtr.p->getPref(i);
Data pref = node.getPref(i);
copyAttrs(pref, readPar.m_data, copyPar);
nodePtr.p->m_flags |= NodeHandle::DoUpdate;
}
/*
......@@ -212,31 +207,11 @@ Dbtux::setNodePref(Signal* signal, Frag& frag, NodeHandlePtr& nodePtr, unsigned
void
Dbtux::commitNodes(Signal* signal, Frag& frag, bool updateOk)
{
TreeHead& tree = frag.m_tree;
NodeHandlePtr nodePtr;
nodePtr.i = frag.m_nodeList;
frag.m_nodeList = RNIL;
while (nodePtr.i != RNIL) {
c_nodeHandlePool.getPtr(nodePtr);
const unsigned flags = nodePtr.p->m_flags;
if (flags & NodeHandle::DoDelete) {
jam();
ndbrequire(updateOk);
// delete already done
} else if (flags & NodeHandle::DoUpdate) {
jam();
ndbrequire(updateOk);
// set prefixes
if (flags & (1 << 0)) {
jam();
setNodePref(signal, frag, nodePtr, 0);
}
if (flags & (1 << 1)) {
jam();
setNodePref(signal, frag, nodePtr, 1);
}
// update already done via pointer
}
// release
NodeHandlePtr tmpPtr = nodePtr;
nodePtr.i = nodePtr.p->m_next;
......@@ -290,13 +265,13 @@ Dbtux::NodeHandle::pushUp(Signal* signal, unsigned pos, const TreeEnt& ent)
tmpList[i] = tmpList[i - 1];
}
tmpList[pos] = ent;
if (occup == 0 || pos == 0)
m_flags |= (1 << 0);
if (occup == 0 || pos == occup)
m_flags |= (1 << 1);
entList[0] = entList[occup + 1];
setOccup(occup + 1);
m_flags |= DoUpdate;
// fix prefixes
if (occup == 0 || pos == 0)
m_tux.setNodePref(signal, m_frag, *this, 0);
if (occup == 0 || pos == occup)
m_tux.setNodePref(signal, m_frag, *this, 1);
}
/*
......@@ -364,13 +339,13 @@ Dbtux::NodeHandle::popDown(Signal* signal, unsigned pos, TreeEnt& ent)
jam();
tmpList[i] = tmpList[i + 1];
}
if (occup != 1 && pos == 0)
m_flags |= (1 << 0);
if (occup != 1 && pos == occup - 1)
m_flags |= (1 << 1);
entList[0] = entList[occup - 1];
setOccup(occup - 1);
m_flags |= DoUpdate;
// fix prefixes
if (occup != 1 && pos == 0)
m_tux.setNodePref(signal, m_frag, *this, 0);
if (occup != 1 && pos == occup - 1)
m_tux.setNodePref(signal, m_frag, *this, 1);
}
/*
......@@ -441,12 +416,12 @@ Dbtux::NodeHandle::pushDown(Signal* signal, unsigned pos, TreeEnt& ent)
}
tmpList[pos] = ent;
ent = oldMin;
entList[0] = entList[occup];
// fix prefixes
if (true)
m_flags |= (1 << 0);
m_tux.setNodePref(signal, m_frag, *this, 0);
if (occup == 1 || pos == occup - 1)
m_flags |= (1 << 1);
entList[0] = entList[occup];
m_flags |= DoUpdate;
m_tux.setNodePref(signal, m_frag, *this, 1);
}
/*
......@@ -518,12 +493,12 @@ Dbtux::NodeHandle::popUp(Signal* signal, unsigned pos, TreeEnt& ent)
tmpList[i] = tmpList[i - 1];
}
tmpList[0] = newMin;
entList[0] = entList[occup];
// fix prefixes
if (true)
m_flags |= (1 << 0);
m_tux.setNodePref(signal, m_frag, *this, 0);
if (occup == 1 || pos == occup - 1)
m_flags |= (1 << 1);
entList[0] = entList[occup];
m_flags |= DoUpdate;
m_tux.setNodePref(signal, m_frag, *this, 1);
}
/*
......
......@@ -24,4 +24,8 @@ optim 2 mc02/a 41 ms 80 ms 96 pct
optim 3 mc02/a 43 ms 80 ms 85 pct
mc02/b 54 ms 118 ms 117 pct
optim 4 mc02/a 42 ms 80 ms 87 pct
mc02/b 51 ms 119 ms 129 pct
vim: set et:
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment