2008-10-07 18:32 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbstack.h
  * harbour/source/vm/estack.c
  * harbour/source/vm/hvm.c
    % moved static USHORT uiPolls to HVM stack to not reduce the HVM
      performance in MT mode. In multi CPU environment if many threads
      try to change the same memory variable in the same time the overall
      performance is strongly reduced on most of tested hardware - probably
      some random CPU delay used to resolve the conflict.
This commit is contained in:
Przemyslaw Czerpak
2008-10-07 16:33:02 +00:00
parent 195f1446b5
commit f6eb3cfb17
4 changed files with 29 additions and 4 deletions

View File

@@ -8,6 +8,16 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-10-07 18:32 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* harbour/source/vm/hvm.c
% moved static USHORT uiPolls to HVM stack to not reduce the HVM
performance in MT mode. In multi CPU environment if many threads
try to change the same memory variable in the same time the overall
performance is strongly reduced on most of tested hardware - probably
some random CPU delay used to resolve the conflict.
2008-10-07 16:33 UTC+0200 Maurilio Longo (maurilio.longo@libero.it)
* harbour/source/rtl/seconds.c
+ Added OS/2 section to secondsCPU(), but it does not work as expected :)

View File

@@ -177,6 +177,7 @@ typedef struct
PHB_TSD_HOLDER pTSD; /* thread specific data holder */
HB_PRIVATE_STACK privates; /* private variables stack */
HB_SET_STRUCT set;
int iKeyPoll; /* counter for GT/keyboard polling */
#if defined( HB_MT_VM )
int iUnlocked; /* counter for nested hb_vmUnlock() calls */
PHB_DYN_HANDLES pDynH; /* dynamic symbol handles */
@@ -308,6 +309,8 @@ extern PHB_ITEM hb_stackWithObjectItem( void );
extern LONG hb_stackWithObjectOffset( void );
extern void hb_stackWithObjectSetOffset( LONG );
extern int * hb_stackKeyPolls( void );
extern void hb_stackDestroyTSD( void );
extern PHB_PRIVATE_STACK hb_stackGetPrivateStack( void );
@@ -442,6 +445,7 @@ extern void hb_stackIsStackRef( void *, PHB_TSD_FUNC );
#define hb_stackGetPrivateStack( ) ( &hb_stack.privates )
#define hb_stackSetStruct( ) ( &hb_stack.set )
#define hb_stackKeyPolls( ) ( &hb_stack.iKeyPoll )
#endif

View File

@@ -181,6 +181,7 @@ static void hb_stack_init( PHB_STACK pStack )
( * pStack->pItems )->item.asSymbol.stackstate = &pStack->state;
pStack->rdd.uiCurrArea = 1;
hb_stack.iKeyPoll = 1;
}
static void hb_stack_destroy_TSD( PHB_STACK pStack )
@@ -421,6 +422,16 @@ int hb_stackLock( void )
}
#endif
#undef hb_stackKeyPolls
int * hb_stackKeyPolls( void )
{
HB_STACK_TLS_PRELOAD
HB_TRACE(HB_TR_DEBUG, ("hb_stackKeyPolls()"));
return &hb_stack.iKeyPoll;
}
#undef hb_stackGetPrivateStack
PHB_PRIVATE_STACK hb_stackGetPrivateStack( void )
{

View File

@@ -1064,7 +1064,7 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
ULONG ulPastClock = 0; /* opcodes profiler support */
#endif
#if !defined( HB_GUI )
static unsigned short uiPolls = 1;
int * piKeyPolls = hb_stackKeyPolls();
#endif
HB_TRACE(HB_TR_DEBUG, ("hb_vmExecute(%p, %p)", pCode, pSymbols));
@@ -1089,10 +1089,10 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
#endif
#if !defined( HB_GUI )
if( ! --uiPolls )
if( ! --( *piKeyPolls ) )
{
hb_inkeyPoll();
/* uiPolls = 255; */
*piKeyPolls = 65536;
/* IMHO we should have a _SET_ controlled by user
* sth like:
@@ -1100,7 +1100,7 @@ HB_EXPORT void hb_vmExecute( const BYTE * pCode, PHB_SYMB pSymbols )
if( hb_stackSetStruct()->HB_SET_KEYPOLL )
{
hb_inkeyPoll();
uiPolls = hb_stackSetStruct()->HB_SET_KEYPOLL;
*piKeyPolls = hb_stackSetStruct()->HB_SET_KEYPOLL;
}
for some GTs which can work in assynchrous mode user may