Speed up the database by caching the Occurrence hash.
* Change: In Hurricane::SharedPath, the hash for the shared pathes, which serves for Map<> storing, were computed "on the fly" at each ::getHash() call, and were involving recursive calls of all the hashes along the components of the shared path. This is terribly slow especially in a design with a deep hierarchy (typical case LS180). Now, at the cost of one supplemenental unsigned long in each SharedPath, it is only computed once in the constructor, and is no longer recursive (only access the *first* tail, if any). As a consequence, the re-display computation delay becomes bearable. But also speed up any transhierarchical walkthough.
This commit is contained in:
parent
180aa52c74
commit
d0405d8152
|
@ -102,10 +102,11 @@ static char NAME_SEPARATOR = '.';
|
||||||
|
|
||||||
SharedPath::SharedPath(Instance* headInstance, SharedPath* tailSharedPath)
|
SharedPath::SharedPath(Instance* headInstance, SharedPath* tailSharedPath)
|
||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
: _headInstance(headInstance),
|
: _hash(0)
|
||||||
_tailSharedPath(tailSharedPath),
|
, _headInstance(headInstance)
|
||||||
_quarkMap(),
|
, _tailSharedPath(tailSharedPath)
|
||||||
_nextOfInstanceSharedPathMap(NULL)
|
, _quarkMap()
|
||||||
|
, _nextOfInstanceSharedPathMap(NULL)
|
||||||
{
|
{
|
||||||
if (!_headInstance)
|
if (!_headInstance)
|
||||||
throw Error("Can't create " + _TName("SharedPath") + " : null head instance");
|
throw Error("Can't create " + _TName("SharedPath") + " : null head instance");
|
||||||
|
@ -126,6 +127,7 @@ SharedPath::SharedPath(Instance* headInstance, SharedPath* tailSharedPath)
|
||||||
, getString(_tailSharedPath->getOwnerCell ()).c_str()
|
, getString(_tailSharedPath->getOwnerCell ()).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
_hash = (_headInstance->getId() << 1) + ((_tailSharedPath) ? _tailSharedPath->getHash() << 1: 0);
|
||||||
_headInstance->_getSharedPathMap()._insert(this);
|
_headInstance->_getSharedPathMap()._insert(this);
|
||||||
|
|
||||||
cdebug_log(0,0) << "SharedPath::SharedPath() pathHash:" << getHash() << " \"" << this << "\"" << endl;
|
cdebug_log(0,0) << "SharedPath::SharedPath() pathHash:" << getHash() << " \"" << this << "\"" << endl;
|
||||||
|
@ -187,7 +189,8 @@ string SharedPath::getName() const
|
||||||
|
|
||||||
unsigned long SharedPath::getHash() const
|
unsigned long SharedPath::getHash() const
|
||||||
// ***************************************
|
// ***************************************
|
||||||
{ return (_headInstance->getId() << 1) + ((_tailSharedPath) ? _tailSharedPath->getHash() << 1: 0); }
|
//{ return (_headInstance->getId() << 1) + ((_tailSharedPath) ? _tailSharedPath->getHash() << 1: 0); }
|
||||||
|
{ return _hash; }
|
||||||
|
|
||||||
string SharedPath::getJsonString(unsigned long flags) const
|
string SharedPath::getJsonString(unsigned long flags) const
|
||||||
// ********************************************************
|
// ********************************************************
|
||||||
|
@ -245,6 +248,10 @@ void SharedPath::setNameSeparator(char nameSeparator)
|
||||||
NAME_SEPARATOR = nameSeparator;
|
NAME_SEPARATOR = nameSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SharedPath::_getTypeName () const
|
||||||
|
// ******************************************
|
||||||
|
{ return _TName("SharedPath"); }
|
||||||
|
|
||||||
string SharedPath::_getString() const
|
string SharedPath::_getString() const
|
||||||
// **********************************
|
// **********************************
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,25 +1,35 @@
|
||||||
// ****************************************************************************************************
|
// -*- C++ -*-
|
||||||
// File: ./hurricane/SharedPath.h
|
//
|
||||||
// Authors: R. Escassut
|
|
||||||
// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
|
// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
|
||||||
//
|
//
|
||||||
// This file is part of Hurricane.
|
// This file is part of Hurricane.
|
||||||
//
|
//
|
||||||
// Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU
|
// Hurricane is free software: you can redistribute it and/or modify
|
||||||
// Lesser General Public License as published by the Free Software Foundation, either version 3 of the
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Hurricane is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
// Hurricane is distributed in the hope that it will be useful, but
|
||||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
|
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
|
||||||
|
// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
|
||||||
// General Public License for more details.
|
// General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the Lesser GNU General Public License along with Hurricane. If
|
// You should have received a copy of the Lesser GNU General Public
|
||||||
// not, see <http://www.gnu.org/licenses/>.
|
// License along with Hurricane. If not, see
|
||||||
// ****************************************************************************************************
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// +-----------------------------------------------------------------+
|
||||||
|
// | H U R R I C A N E |
|
||||||
|
// | V L S I B a c k e n d D a t a - B a s e |
|
||||||
|
// | |
|
||||||
|
// | Authors : Remy Escassut |
|
||||||
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
|
// | =============================================================== |
|
||||||
|
// | C++ Header : "./hurricane/RoutingPad.h" |
|
||||||
|
// +-----------------------------------------------------------------+
|
||||||
|
|
||||||
#ifndef HURRICANE_SHARED_PATH
|
|
||||||
#define HURRICANE_SHARED_PATH
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
#include "hurricane/Instances.h"
|
#include "hurricane/Instances.h"
|
||||||
#include "hurricane/SharedPathes.h"
|
#include "hurricane/SharedPathes.h"
|
||||||
#include "hurricane/Quark.h"
|
#include "hurricane/Quark.h"
|
||||||
|
@ -32,108 +42,73 @@ class Cell;
|
||||||
class Entity;
|
class Entity;
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Class : "SharedPath".
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// SharedPath declaration
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
||||||
class SharedPath {
|
class SharedPath {
|
||||||
// *************
|
public:
|
||||||
|
class QuarkMap : public IntrusiveMap<const Entity*, Quark> {
|
||||||
// Types
|
public:
|
||||||
// *****
|
typedef IntrusiveMap<const Entity*, Quark> Inherit;
|
||||||
|
public:
|
||||||
public: class QuarkMap : public IntrusiveMap<const Entity*, Quark> {
|
QuarkMap ();
|
||||||
// ***************************************************************
|
virtual const Entity* _getKey ( Quark* ) const;
|
||||||
|
virtual unsigned _getHashValue ( const Entity* ) const;
|
||||||
public: typedef IntrusiveMap<const Entity*, Quark> Inherit;
|
virtual Quark* _getNextElement ( Quark* ) const;
|
||||||
|
virtual void _setNextElement ( Quark* , Quark* nextQuark ) const;
|
||||||
public: QuarkMap();
|
|
||||||
|
|
||||||
public: virtual const Entity* _getKey(Quark* quark) const;
|
|
||||||
public: virtual unsigned _getHashValue(const Entity* entity) const;
|
|
||||||
public: virtual Quark* _getNextElement(Quark* quark) const;
|
|
||||||
public: virtual void _setNextElement(Quark* quark, Quark* nextQuark) const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attributes
|
public:
|
||||||
// **********
|
SharedPath ( Instance* headInstance, SharedPath* tailSharedPath = NULL );
|
||||||
|
~SharedPath ();
|
||||||
private: Instance* _headInstance;
|
private:
|
||||||
private: SharedPath* _tailSharedPath;
|
SharedPath ( const SharedPath& ) = delete;
|
||||||
private: QuarkMap _quarkMap;
|
SharedPath& operator= ( const SharedPath& ) = delete;
|
||||||
private: SharedPath* _nextOfInstanceSharedPathMap;
|
public:
|
||||||
|
static char getNameSeparator ();
|
||||||
// Constructors
|
static void setNameSeparator ( char nameSeparator );
|
||||||
// ************
|
public:
|
||||||
|
unsigned long getHash () const;
|
||||||
public: SharedPath(Instance* headInstance, SharedPath* tailSharedPath = NULL);
|
inline Instance* getHeadInstance () const;
|
||||||
|
inline SharedPath* getTailSharedPath () const;
|
||||||
private: SharedPath(const SharedPath& sharedPath);
|
SharedPath* getHeadSharedPath () const;
|
||||||
// not implemented to forbid copy construction
|
Instance* getTailInstance () const;
|
||||||
|
std::string getName () const;
|
||||||
// Destructor
|
std::string getJsonString ( unsigned long flags ) const;
|
||||||
// **********
|
Cell* getOwnerCell () const;
|
||||||
|
Cell* getMasterCell () const;
|
||||||
public: ~SharedPath();
|
Instances getInstances () const;
|
||||||
|
Transformation getTransformation ( const Transformation& transformation=Transformation() ) const;
|
||||||
// Operators
|
public:
|
||||||
// *********
|
std::string _getTypeName () const;
|
||||||
|
std::string _getString () const;
|
||||||
private: SharedPath& operator=(const SharedPath& sharedPath);
|
Record* _getRecord () const;
|
||||||
// not implemented to forbid assignment
|
inline Quark* _getQuark (const Entity* entity ) const;
|
||||||
|
inline Quarks _getQuarks () const;
|
||||||
// Accessors
|
inline QuarkMap& _getQuarkMap ();
|
||||||
// *********
|
inline SharedPath* _getNextOfInstanceSharedPathMap () const;
|
||||||
|
inline void _setNextOfInstanceSharedPathMap ( SharedPath* sharedPath );
|
||||||
public: static char getNameSeparator();
|
private:
|
||||||
|
// Attributes.
|
||||||
public: unsigned long getHash() const;
|
unsigned long _hash;
|
||||||
public: Instance* getHeadInstance() const {return _headInstance;};
|
Instance* _headInstance;
|
||||||
public: SharedPath* getTailSharedPath() const {return _tailSharedPath;};
|
SharedPath* _tailSharedPath;
|
||||||
public: SharedPath* getHeadSharedPath() const;
|
QuarkMap _quarkMap;
|
||||||
public: Instance* getTailInstance() const;
|
SharedPath* _nextOfInstanceSharedPathMap;
|
||||||
public: string getName() const;
|
|
||||||
public: string getJsonString(unsigned long flags) const;
|
|
||||||
public: Cell* getOwnerCell() const;
|
|
||||||
public: Cell* getMasterCell() const;
|
|
||||||
public: Instances getInstances() const;
|
|
||||||
public: Transformation getTransformation(const Transformation& transformation = Transformation()) const;
|
|
||||||
|
|
||||||
// Updators
|
|
||||||
// ********
|
|
||||||
|
|
||||||
public: static void setNameSeparator(char nameSeparator);
|
|
||||||
|
|
||||||
// Accessors
|
|
||||||
// *********
|
|
||||||
|
|
||||||
public: string _getTypeName() const { return _TName("SharedPath"); };
|
|
||||||
public: string _getString() const;
|
|
||||||
public: Record* _getRecord() const;
|
|
||||||
|
|
||||||
public: Quark* _getQuark(const Entity* entity) const {return _quarkMap.getElement(entity);};
|
|
||||||
public: Quarks _getQuarks() const {return _quarkMap.getElements();};
|
|
||||||
public: QuarkMap& _getQuarkMap() {return _quarkMap;};
|
|
||||||
public: SharedPath* _getNextOfInstanceSharedPathMap() const {return _nextOfInstanceSharedPathMap;};
|
|
||||||
|
|
||||||
public: void _setNextOfInstanceSharedPathMap(SharedPath* sharedPath) {_nextOfInstanceSharedPathMap = sharedPath;};
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline Instance* SharedPath::getHeadInstance () const { return _headInstance; }
|
||||||
|
inline SharedPath* SharedPath::getTailSharedPath () const { return _tailSharedPath; }
|
||||||
|
inline Quark* SharedPath::_getQuark (const Entity* entity ) const { return _quarkMap.getElement(entity); }
|
||||||
|
inline Quarks SharedPath::_getQuarks () const { return _quarkMap.getElements(); }
|
||||||
|
inline SharedPath::QuarkMap& SharedPath::_getQuarkMap () { return _quarkMap; }
|
||||||
|
inline SharedPath* SharedPath::_getNextOfInstanceSharedPathMap () const { return _nextOfInstanceSharedPathMap; }
|
||||||
|
inline void SharedPath::_setNextOfInstanceSharedPathMap ( SharedPath* sharedPath ) { _nextOfInstanceSharedPathMap = sharedPath; }
|
||||||
|
|
||||||
} // End of Hurricane namespace.
|
|
||||||
|
} // Hurricane namespace.
|
||||||
|
|
||||||
|
|
||||||
INSPECTOR_P_SUPPORT(Hurricane::SharedPath);
|
INSPECTOR_P_SUPPORT(Hurricane::SharedPath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // HURRICANE_SHARED_PATH
|
|
||||||
|
|
||||||
|
|
||||||
// ****************************************************************************************************
|
|
||||||
// Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
|
|
||||||
// ****************************************************************************************************
|
|
||||||
|
|
Loading…
Reference in New Issue