Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote launch capability (resubmit #189) #192

Merged
merged 5 commits into from
Jul 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 17 additions & 27 deletions co/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,7 @@
#include <lunchbox/scopedMutex.h>
#include <lunchbox/stdExt.h>

//#define STATISTICS
#ifdef STATISTICS
typedef std::map< uint64_t, size_t > Histogram;
typedef Histogram::const_iterator HistogramCIter;
lunchbox::Lockable< Histogram, lunchbox::SpinLock > _histogram;

# define ADD_STATISTIC( x ) \
{ \
lunchbox::ScopedFastWrite mutex( _histogram ); \
++(*_histogram)[ x ]; \
}
# define DUMP_STATISTIC \
{ \
lunchbox::ScopedFastRead mutex( _histogram ); \
LBINFO << lunchbox::disableFlush << lunchbox::disableHeader; \
for( HistogramCIter i=_histogram->begin(); i!=_histogram->end(); ++i) \
LBINFO << i->first << ", " << i->second << std::endl; \
LBINFO << lunchbox::enableHeader << lunchbox::enableFlush <<std::endl; \
}
#else
# define ADD_STATISTIC( x )
# define DUMP_STATISTIC
#endif

#define STATISTICS
namespace co
{
namespace detail
Expand All @@ -87,10 +64,15 @@ class Connection
/** The listeners on state changes */
ConnectionListeners listeners;

uint64_t outBytes; //!< Statistic: written bytes
uint64_t inBytes; //!< Statistic: read bytes

Connection()
: state( co::Connection::STATE_CLOSED )
, description( new ConnectionDescription )
, bytes( 0 )
, outBytes( 0 )
, inBytes( 0 )
{
description->type = CONNECTIONTYPE_NONE;
}
Expand Down Expand Up @@ -124,9 +106,12 @@ Connection::Connection()

Connection::~Connection()
{
delete _impl;
LBVERB << "Delete Connection @" << (void*)this << std::endl;
DUMP_STATISTIC;
#ifdef STATISTICS
LBDEBUG << *this << ": " << (_impl->outBytes >> 20) << " MB out, "
<< (_impl->inBytes >> 20) << " MB in" << std::endl;
#endif
delete _impl;
}

bool Connection::operator == ( const Connection& rhs ) const
Expand Down Expand Up @@ -264,6 +249,9 @@ bool Connection::recvSync( BufferPtr& outBuffer, const bool block )
return false;
LBASSERTINFO( bytes < LB_BIT48,
"Out-of-sync network stream: read size " << bytes << "?" );
#ifdef STATISTICS
_impl->inBytes += bytes;
#endif

// 'Iterators' for receive loop
uint8_t* ptr = outBuffer->getData() + outBuffer->getSize();
Expand Down Expand Up @@ -348,7 +336,9 @@ BufferPtr Connection::resetRecvData()
bool Connection::send( const void* buffer, const uint64_t bytes,
const bool isLocked )
{
ADD_STATISTIC( bytes );
#ifdef STATISTICS
_impl->outBytes += bytes;
#endif
LBASSERT( bytes > 0 );
if( bytes == 0 )
return true;
Expand Down
6 changes: 3 additions & 3 deletions co/fullMasterCM.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/* Copyright (c) 2007-2014, Stefan Eilemann <eile@equalizergraphics.com>
* 2011-2012, Daniel Nachbaur <danielnachbaur@gmail.com>
/* Copyright (c) 2007-2016, Stefan Eilemann <eile@equalizergraphics.com>
* Daniel Nachbaur <danielnachbaur@gmail.com>
*
* This file is part of Collage <https://github.com/Eyescale/Collage>
*
Expand Down Expand Up @@ -61,7 +61,7 @@ FullMasterCM::~FullMasterCM()
_instanceDataCache.clear();
}

void FullMasterCM::sendInstanceData( Nodes& nodes )
void FullMasterCM::sendInstanceData( const Nodes& nodes )
{
LB_TS_THREAD( _cmdThread );
Mutex mutex( _slaves );
Expand Down
142 changes: 71 additions & 71 deletions co/fullMasterCM.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/* Copyright (c) 2007-2014, Stefan Eilemann <eile@equalizergraphics.com>
* 2011-2012, Daniel Nachbaur <danielnachbaur@gmail.com>
/* Copyright (c) 2007-2016, Stefan Eilemann <eile@equalizergraphics.com>
* Daniel Nachbaur <danielnachbaur@gmail.com>
*
* This file is part of Collage <https://github.com/Eyescale/Collage>
*
Expand Down Expand Up @@ -28,77 +28,77 @@

namespace co
{
class ObjectDataIStream;

/**
* An object change manager handling only full versions for the master
* instance.
* @internal
*/
class FullMasterCM : public VersionedMasterCM
class ObjectDataIStream;

/**
* An object change manager handling only full versions for the master
* instance.
* @internal
*/
class FullMasterCM : public VersionedMasterCM
{
public:
explicit FullMasterCM( Object* object );
virtual ~FullMasterCM();

void init() override;
uint128_t commit( const uint32_t incarnation ) override;
void push( const uint128_t& groupID, const uint128_t& typeID,
const Nodes& nodes ) override;
bool sendSync( const MasterCMCommand& command ) override;

/** @name Versioning */
//@{
void setAutoObsolete( const uint32_t count ) override;
uint32_t getAutoObsolete() const override { return _nVersions; }
//@}

/** Speculatively send instance data to all nodes. */
void sendInstanceData( const Nodes& nodes ) override;

protected:
struct InstanceData
{
public:
explicit FullMasterCM( Object* object );
virtual ~FullMasterCM();

void init() override;
uint128_t commit( const uint32_t incarnation ) override;
void push( const uint128_t& groupID, const uint128_t& typeID,
const Nodes& nodes ) override;
bool sendSync( const MasterCMCommand& command ) override;

/** @name Versioning */
//@{
void setAutoObsolete( const uint32_t count ) override;
uint32_t getAutoObsolete() const override { return _nVersions; }
//@}

/** Speculatively send instance data to all nodes. */
void sendInstanceData( Nodes& nodes ) override;

protected:
struct InstanceData
{
explicit InstanceData( const VersionedMasterCM* cm )
: os( cm ), commitCount( 0 ) {}

ObjectInstanceDataOStream os;
uint32_t commitCount;
};

bool _initSlave( const MasterCMCommand&, const uint128_t&,
bool ) override;

InstanceData* _newInstanceData();
void _addInstanceData( InstanceData* data );
void _releaseInstanceData( InstanceData* data );

void _updateCommitCount( const uint32_t incarnation );
void _obsolete();
void _checkConsistency() const;

bool isBuffered() const override { return true; }
virtual void _commit();

private:
/** The number of commits, needed for auto-obsoletion. */
uint32_t _commitCount;

/** The number of old versions to retain. */
uint32_t _nVersions;

typedef std::deque< InstanceData* > InstanceDataDeque;
typedef std::vector< InstanceData* > InstanceDatas;

/** The list of full instance datas, head version last. */
InstanceDataDeque _instanceDatas;
InstanceDatas _instanceDataCache;

/* The command handlers. */
bool _cmdCommit( ICommand& command );
bool _cmdObsolete( ICommand& command );
bool _cmdPush( ICommand& command );
explicit InstanceData( const VersionedMasterCM* cm )
: os( cm ), commitCount( 0 ) {}

ObjectInstanceDataOStream os;
uint32_t commitCount;
};

bool _initSlave( const MasterCMCommand&, const uint128_t&,
bool ) override;

InstanceData* _newInstanceData();
void _addInstanceData( InstanceData* data );
void _releaseInstanceData( InstanceData* data );

void _updateCommitCount( const uint32_t incarnation );
void _obsolete();
void _checkConsistency() const;

bool isBuffered() const override { return true; }
virtual void _commit();

private:
/** The number of commits, needed for auto-obsoletion. */
uint32_t _commitCount;

/** The number of old versions to retain. */
uint32_t _nVersions;

typedef std::deque< InstanceData* > InstanceDataDeque;
typedef std::vector< InstanceData* > InstanceDatas;

/** The list of full instance datas, head version last. */
InstanceDataDeque _instanceDatas;
InstanceDatas _instanceDataCache;

/* The command handlers. */
bool _cmdCommit( ICommand& command );
bool _cmdObsolete( ICommand& command );
bool _cmdPush( ICommand& command );
};
}

#endif // CO_FULLMASTERCM_H
6 changes: 3 additions & 3 deletions co/global.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
/* Copyright (c) 2005-2016, Stefan Eilemann <eile@equalizergraphics.com>
*
* This file is part of Collage <https://github.com/Eyescale/Collage>
*
Expand Down Expand Up @@ -137,7 +137,7 @@ bool Global::fromString(const std::string& data )
return true;
}

void Global::toString( std::string& data )
std::string Global::toString()
{
std::stringstream stream;
stream << SEPARATOR << SEPARATOR;
Expand All @@ -146,7 +146,7 @@ void Global::toString( std::string& data )
stream << _iAttributes[i] << SEPARATOR;

stream << SEPARATOR;
data = stream.str();
return stream.str();
}

void Global::setDefaultPort( const uint16_t port )
Expand Down
4 changes: 2 additions & 2 deletions co/global.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

/* Copyright (c) 2005-2013, Stefan Eilemann <eile@equalizergraphics.com>
/* Copyright (c) 2005-2016, Stefan Eilemann <eile@equalizergraphics.com>
*
* This file is part of Collage <https://github.com/Eyescale/Collage>
*
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace co
CO_API static bool fromString( const std::string& data );

/** @internal Write global variables in the format for fromString(). */
CO_API static void toString( std::string& data );
CO_API static std::string toString();

/** @return the plugin registry. @version 1.0 */
CO_API static pression::PluginRegistry& getPluginRegistry();
Expand Down