Commit b4b70147 authored by Pavel Vainerman's avatar Pavel Vainerman

(SM): Оптимизация: 1) перевёл механизм аварийного следа с std::list на…

(SM): Оптимизация: 1) перевёл механизм аварийного следа с std::list на std::deque, т.к. у std::list - дорогой вызов size(), а так же, нам собственно требуется в основном работы с добавление и удаление в начало и конец буфера. Профайлер показал "выигрышь" в HistoryItem::add(). 2) Заодно перевёл "активацию" с mutex, на atomic (хотя commoncpp, всё-равно внутри для atomic использует pthread_mutex).
parent 705d6b82
...@@ -36,13 +36,12 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ) ...@@ -36,13 +36,12 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
heartbeatCheckTime(5000), heartbeatCheckTime(5000),
histSaveTime(0), histSaveTime(0),
wdt(0), wdt(0),
activated(false), activated(0),
workready(false), workready(0),
dblogging(false), dblogging(false),
msecPulsar(0) msecPulsar(0)
{ {
mutex_start.setName(myname + "_mutex_start"); mutex_start.setName(myname + "_mutex_start");
mutex_act.setName(myname + "_mutex_act");
string cname(confname); string cname(confname);
if( cname.empty() ) if( cname.empty() )
...@@ -140,7 +139,7 @@ void SharedMemory::timerInfo( const TimerMessage *tm ) ...@@ -140,7 +139,7 @@ void SharedMemory::timerInfo( const TimerMessage *tm )
checkHeartBeat(); checkHeartBeat();
else if( tm->id == tmEvent ) else if( tm->id == tmEvent )
{ {
workready = true; workready = 1;
// рассылаем уведомление, о том, чтобы стартанули // рассылаем уведомление, о том, чтобы стартанули
SystemMessage sm1(SystemMessage::WatchDog); SystemMessage sm1(SystemMessage::WatchDog);
sendEvent(sm1); sendEvent(sm1);
...@@ -236,10 +235,7 @@ bool SharedMemory::activateObject() ...@@ -236,10 +235,7 @@ bool SharedMemory::activateObject()
// пока не пройдёт инициализация датчиков // пока не пройдёт инициализация датчиков
// см. sysCommand() // см. sysCommand()
{ {
{ activated = 0;
uniset_rwmutex_wrlock l(mutex_act);
activated = false;
}
UniSetTypes::uniset_rwmutex_wrlock l(mutex_start); UniSetTypes::uniset_rwmutex_wrlock l(mutex_start);
res = IONotifyController_LT::activateObject(); res = IONotifyController_LT::activateObject();
...@@ -258,10 +254,7 @@ bool SharedMemory::activateObject() ...@@ -258,10 +254,7 @@ bool SharedMemory::activateObject()
hit->ioit = myioEnd(); hit->ioit = myioEnd();
} }
{ activated = 1;
uniset_rwmutex_wrlock l(mutex_act);
activated = true;
}
} }
cerr << "************************** activate: " << pt.getCurrent() << " msec " << endl; cerr << "************************** activate: " << pt.getCurrent() << " msec " << endl;
...@@ -767,7 +760,6 @@ std::ostream& operator<<( std::ostream& os, const SharedMemory::HistoryInfo& h ) ...@@ -767,7 +760,6 @@ std::ostream& operator<<( std::ostream& os, const SharedMemory::HistoryInfo& h )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool SharedMemory::isActivated() bool SharedMemory::isActivated()
{ {
uniset_rwmutex_rlock l(mutex_act);
return activated; return activated;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#define SharedMemory_H_ #define SharedMemory_H_
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#include <string> #include <string>
#include <list> #include <deque>
#include "IONotifyController_LT.h" #include "IONotifyController_LT.h"
#include "Mutex.h" #include "Mutex.h"
#include "PassiveTimer.h" #include "PassiveTimer.h"
...@@ -274,7 +274,7 @@ class SharedMemory: ...@@ -274,7 +274,7 @@ class SharedMemory:
// ------------ HISTORY -------------------- // ------------ HISTORY --------------------
typedef std::list<long> HBuffer; typedef std::deque<long> HBuffer;
struct HistoryItem struct HistoryItem
{ {
...@@ -289,7 +289,7 @@ class SharedMemory: ...@@ -289,7 +289,7 @@ class SharedMemory:
{ {
buf.push_back(val); buf.push_back(val);
if( buf.size() >= size ) if( buf.size() >= size )
buf.erase(buf.begin()); buf.pop_front();
} }
}; };
...@@ -400,8 +400,8 @@ class SharedMemory: ...@@ -400,8 +400,8 @@ class SharedMemory:
typedef std::list<HeartBeatInfo> HeartBeatList; typedef std::list<HeartBeatInfo> HeartBeatList;
HeartBeatList hlist; // список датчиков "сердцебиения" HeartBeatList hlist; // список датчиков "сердцебиения"
WDTInterface* wdt; WDTInterface* wdt;
bool activated; UniSetTypes::mutex_atomic_t activated;
bool workready; UniSetTypes::mutex_atomic_t workready;
typedef std::list<UniSetTypes::ObjectId> EventList; typedef std::list<UniSetTypes::ObjectId> EventList;
EventList elst; EventList elst;
...@@ -425,13 +425,10 @@ class SharedMemory: ...@@ -425,13 +425,10 @@ class SharedMemory:
void checkHistoryFilter( UniXML_iterator& it ); void checkHistoryFilter( UniXML_iterator& it );
bool isActivated(); bool isActivated();
IOStateList::iterator itPulsar; IOStateList::iterator itPulsar;
IOController_i::SensorInfo siPulsar; IOController_i::SensorInfo siPulsar;
int msecPulsar; int msecPulsar;
UniSetTypes::uniset_rwmutex mutex_act;
private: private:
HistorySlot m_historySignal; HistorySlot m_historySignal;
}; };
......
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