Apertura del repositorio

This commit is contained in:
2025-05-24 18:09:39 -03:00
parent 76e6359dad
commit d883ddd0d0
35253 changed files with 2891973 additions and 2 deletions
+68
View File
@@ -0,0 +1,68 @@
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "ndetw.h"
#ifdef LL_WINDOWS
#include <Windows.h>
namespace nd
{
namespace etw
{
HMODULE hETW;
tpLogFrame pLogFrame;
tpLogStartTask pLogStartTask;
tpLogEndTask pLogEndTask;
tpLogTickTask pLogTickTask;
LLTimer etwFrameTimer;
void init()
{
pLogFrame = NULL;
pLogStartTask = NULL;
pLogEndTask = NULL;
pLogTickTask = NULL;
// This is okay for now. We'll only need that for measuring under well defined circumstances.
// Maybe create an installer for this one day (very low prio) that copies and registers the provider.
hETW = ::LoadLibrary( L"c:\\xperf\\fs_etw.dll" );
if( hETW )
{
tpInitialize pInitialize = reinterpret_cast< tpInitialize>( ::GetProcAddress( hETW, "initialize" ) );
if( pInitialize && (*pInitialize)() )
{
pLogFrame = reinterpret_cast< tpLogFrame >( ::GetProcAddress( hETW, "log_beginFrame" ) );
pLogStartTask = reinterpret_cast< tpLogStartTask >( ::GetProcAddress( hETW, "log_startTask" ) );
pLogEndTask = reinterpret_cast< tpLogEndTask >( ::GetProcAddress( hETW, "log_endTask" ) );
pLogTickTask = reinterpret_cast< tpLogTickTask >( ::GetProcAddress( hETW, "log_tickTask" ) );
etwFrameTimer.reset();
}
}
}
}
}
#endif
+93
View File
@@ -0,0 +1,93 @@
#ifndef NDETW_H
#define NDETW_H
/**
* $LicenseInfo:firstyear=2014&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2014, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llpreprocessor.h"
#include "lltimer.h"
namespace nd
{
namespace etw
{
#ifdef LL_WINDOWS
typedef bool (_cdecl *tpInitialize)(void);
typedef void (_cdecl *tpLogFrame)(double);
typedef void (_cdecl *tpLogStartTask)(wchar_t const*);
typedef void (_cdecl *tpLogEndTask)(wchar_t const*);
typedef void (_cdecl *tpLogTickTask)(wchar_t const*);
extern tpLogFrame pLogFrame;
extern tpLogStartTask pLogStartTask;
extern tpLogEndTask pLogEndTask;
extern tpLogTickTask pLogTickTask;
extern LLTimer etwFrameTimer;
void init();
inline void logFrame( )
{
if( pLogFrame )
(*pLogFrame)( etwFrameTimer.getElapsedTimeAndResetF64() );
}
inline void logTaskStart( wchar_t const *aTask )
{
if( pLogStartTask )
(*pLogStartTask)( aTask );
}
inline void logTaskEnd( wchar_t const *aTask )
{
if( pLogEndTask )
(*pLogEndTask)( aTask );
}
inline void tickTask( wchar_t const *aTask )
{
if( pLogTickTask )
(*pLogTickTask)( aTask );
}
#else
inline void init()
{ }
inline void logFrame( )
{ }
inline void logTaskStart( wchar_t const *aTask )
{ }
inline void logTaskEnd( wchar_t const *aTask )
{ }
inline void tickTask( wchar_t const *aTask )
{ }
#endif
}
}
#endif
+41
View File
@@ -0,0 +1,41 @@
/**
* $LicenseInfo:firstyear=2013&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2013, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "ndexceptions.h"
namespace nd
{
namespace exceptions
{
xran::xran( std::string const &aReason )
{
mReason = aReason;
}
std::string const& xran::what() const
{
return mReason;
}
}
}
+51
View File
@@ -0,0 +1,51 @@
/**
* $LicenseInfo:firstyear=2013&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2013, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#ifndef NDEXCEPTIONS_H
#define NDEXCEPTIONS_H
#include <string>
/* Not derived from std::exception.
std::exception::what differs between gcc and MSVC. gcc has a throw() gurantee. Same with std::exception::~exception.
That would mean a lot of #ifdef for no real benefit of having the inheritance right now.
*/
namespace nd
{
namespace exceptions
{
class xran
{
std::string mReason;
public:
xran( std::string const & );
std::string const& what() const;
};
}
}
#endif
+146
View File
@@ -0,0 +1,146 @@
/**
* $LicenseInfo:firstyear=2013&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2013, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "ndlogthrottle.h"
#include <set>
#include "llpreprocessor.h"
#include "lltimer.h"
namespace nd
{
namespace logging
{
const U64 spamAvgInterval = 3 * 1000 * 1000; // 3 seconds
const U64 maxThrottle = 60 * 1000 * 1000; // 1 minute
const U64 minCallsBeforeThrottle = 250;
const U64 initialThrottle = 5*1000*1000; // 5 seconds
const U64 resetAfter = 30*1000*1000;
bool logThrottleEnabled = true;
struct CallSiteCall
{
char const *mFile;
int mLine;
mutable U64 mLastCall;
mutable U64 mAverage;
mutable U64 mCalls;
mutable U64 mThrottledCalls;
mutable U64 mLastUnthrottled;
mutable U32 mThrottle;
CallSiteCall( char const *aFile, int aLine )
: mFile( aFile )
, mLine( aLine )
, mLastCall( 0 )
, mAverage( 0 )
, mCalls( 0 )
, mThrottledCalls( 0 )
, mLastUnthrottled( 0 )
, mThrottle( initialThrottle )
{
}
bool operator< ( CallSiteCall const &aRHS ) const
{
if( mLine != aRHS.mLine )
return mLine < aRHS.mLine;
return mFile < aRHS.mFile;
}
};
bool throttle( char const *aFile, int aLine, std::ostream *aOut )
{
// Only called from Log::flush and protected by LogLock
if (!logThrottleEnabled)
{
return false;
}
static std::set< CallSiteCall > stCalls;
CallSiteCall oCall( aFile, aLine );
oCall.mLastCall = LLTimer::getTotalTime();
oCall.mLastUnthrottled = oCall.mLastCall;
std::set< CallSiteCall >::iterator itr = stCalls.find( oCall );
if( stCalls.end() == itr )
{
stCalls.insert( oCall );
return false;
}
U64 nDiffT = (oCall.mLastCall - itr->mLastCall);
U64 nDiffU = (oCall.mLastCall - itr->mLastUnthrottled);
if( nDiffT < resetAfter )
{
++itr->mCalls;
itr->mAverage = (itr->mAverage + nDiffT )/2;
itr->mLastCall = oCall.mLastCall;
}
else
{
itr->mCalls = 1;
itr->mAverage = 0;
itr->mLastCall = oCall.mLastCall;
itr->mLastUnthrottled = oCall.mLastCall;
itr->mThrottledCalls = 0;
itr->mThrottle = initialThrottle;
return false;
}
if( itr->mCalls > minCallsBeforeThrottle && itr->mAverage <= spamAvgInterval && nDiffU < itr->mThrottle )
{
++itr->mThrottledCalls;
return true;
}
itr->mLastUnthrottled = oCall.mLastCall;
if( itr->mThrottledCalls )
{
if( aOut )
*aOut << "( Supressed " << itr->mThrottledCalls << " calls, frequency " << itr->mAverage << " usec, throttle " << itr->mThrottle << " usec ) ";
if( itr->mThrottle < maxThrottle )
itr->mThrottle *= 2;
}
itr->mThrottledCalls = 0;
return false;
}
void setThrottleEnabled(bool enabled)
{
logThrottleEnabled = enabled;
}
}
}
+39
View File
@@ -0,0 +1,39 @@
#ifndef NDLOGTHROTTLE_H
#define NDLOGTHROTTLE_H
/**
* $LicenseInfo:firstyear=2013&license=fsviewerlgpl$
* Phoenix Firestorm Viewer Source Code
* Copyright (C) 2013, Nicky Dasmijn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include <iostream>
namespace nd
{
namespace logging
{
bool throttle( char const *aFile, int aLine, std::ostream *aOut );
void setThrottleEnabled(bool enabled);
}
}
#endif