Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Lbas

  • Rank
  1. Lbas

    Compiler performance issue

    Hello, I just wanted to share a problem I came accross. First, I'm a long time AS user... I'm using a very old version now (2.6) :) so please accept my apologize if I didn't take the time to experiment with newest version nor check into change logs / threads if problem has already been reported / fixed. I have a tool than generate script code file. As projects become larger and larger, the generated script files can reach about 10000 lines ! Recently, users of my tool reported me the (very) long time spent to run the scripts. I though it came from any processing function called by script, but I recently investigated a bit to realize that the time was spent into asIScriptEngine::Build() method. To give an idea, a file using about 5000 spent about 6 minutes into that method. I then found the bottleneck (but didn't investigated more on it) : All the generated script code was generated into only one main() function. I tried to split the generated script into small functions, then call each of these functions from the main(). Result = less than 1 second !! So, maybe the problem has already been fixed since, but I just wanted to share my experience, it's better to write small function with many calls rather than a huge one without any call. Generated scripts example : Old way (pseudo code) : void main() { { // block 0 treatment (could be many statements) } { // block 1 treatment } ... { // block n treatment } } New way (huge faster) : void Block0() { // block 0 treatment (could be many statements) } void Block1() { // block 1 treatment } ... void BlockN() { // block n treatment } void main() { Block0(); Block1(); ... BlockN(); } Hopefully it could be of any help, Lbas
  2. Lbas

    VC6 compiler bug ?

    I think I didn't explain clearly the problem encountered, sorry for that. _goat: No, I don't confuse source control with custom directories :), but thanks anyway for your point of vue. Spoonbender: I'm using Perforce. Let me try to explain a bit better (I hope :)). I have many (many many) libraries in dev, where files are structured like this : - include\lib1\lib1_header_files.h - include\lib2\lib2_header_files.h - lib\ output binary .lib - sources\lib1\Make\lib1 make files (dsp, solutions, makefiles, etc.) - sources\lib1\lib1_files.cpp - sources\lib2\Make\lib2 make files (dsp, solutions, makefiles, etc.) - sources\lib2\lib2_files.cpp ... When I tried to configure source control in Visual2005, it refused to get (nor checkin/checkout of course) project files (for example for the solution file located in sources\lib1\Make\lib1.sln, source control didn't take care of sources\lib1\files.cpp and include\lib1\files.h) because these project files are not in the same directory tree of .sln file (at least that's what it reported). As I previously said, I didn't have many time to investigate on this (and don't have now), but I'll try later and let you know. Thanks for your comments, [Edited by - Lbas on January 4, 2007 2:13:52 AM]
  3. Lbas

    VC6 compiler bug ?

    I encountered a problem using VC 2005 regarding source control I didn't succeeded to circumvent. The problem is that you must have sources+headers files in the same directory (or in a sub-directory) than the solution files, and our projects are structured in other way (sources & header in different directories and project files in a sub-directory). I didn't investigate a lot on this problem, but it's very annoying... I'll have a look at the newly released SP1 of VC 2005 to see if they fixed this problem (I'll let you know). BTW, I'm still very satisfied with VC6, even if I agree it's very old now :) Regards, Lbas
  4. Lbas

    VC6 compiler bug ?

    Hi, I experienced a strange bug in my engine, and my conclusion is that it could come from a VC6++ compiler bug... (sp6, in release mode optimization on Maximize speed). The bug happens when I try to register more than 68 object methods in one function. When I add a 69th, the compiler seems to "stop" to pass the method adress to the RegisterObjectMethod() from about 30 registered methods (seen by steping in produced optimized code). To be more accurate, compiler don't make the asMemCopy() anymore, that is, it don't call the asMethod::Convert() as if method had a zero size length!!... - If I split my registering function in two smaller functions, it works fine - If I turn optimization on 'Minimize speed', it works fine too Did someone already experienced this ? Lbas
  5. In fact, you're right, I'll try to investigate in templated function to simplify wrapping purposes. But, there's not only wrapping issues with this model, but also to have to keep track on a global instance of the required class, which is not the best way to think in a OO model... Thanks for your quick reply, Best regards, Lbas
  6. Hi all, Is there any way to register a function considered as global function in the scripts but using a (non static) method of a class (for example a derived asScriptEngine) ? In other words, is it possible to give the "this" address to a calling function. To be a bit clearer :), here's an example : registering a simple Message() function which require properties owned by the script engine, for example a header string given by the application should look something like: class MyScriptEngine : public asScriptEngine { .. blabla.. void Init() { ... RegisterGlobalFunction( "void Message( const string& in msg )", asMETHODPR( MyScriptEngine, Message, ( const string& ) const, void ), asCALL_CDECL ); } void Message( const string& msg ) const { // display m_msgHeader + msg } void SetMessageHeader( const string& msgHeader ) { m_msgHeader = msgHeader; } private: string m_msgHeader; }; I knwo there's a problem with the code above (the calling convention), but is there a way to give the instance of MyScriptEngine (ie this) required to run this function ? The only way I found until now is to declare (ducplicate) a static (singleton) method (or static global function) which have to now how to get a pointer on the MyScriptEngine instance, then call the method : static void MyScriptEngine::_Message( const string& msg ) { MyScriptEngine* pEngine = GetCurrentScriptEngine(); pEngine->Message( msg ); } then register this _Message() function using CDECL instead of Message() on. The problem comes mainly when you have thousands :) methods to redirect like this. In addition, I would like this Message() method being virtual for MyScriptEngine overriding... The idea behind this problem would maybe being able to "say" to a registered function to give the pointer of the asScriptEngine itself ? (some another calling convention type such CALL_ENGINE or CALL_THISENGINE) ? What do you think about it (I hope you see what I mean:)) ? Regards, Lbas
  7. Lbas

    Angelscript 2.7.0 leaks?

    Hi, Did you tried to use _CrtSetBreakAlloc() to break on the code who made allocation responsible for the leak ? In your case, you could try : _CrtSetBreakAlloc( 759 ); _CrtSetBreakAlloc( 760 ); Regards, Lbas
  8. Lbas

    Registering a file::write() script method

    Ok thanks, That's what I done but I innocently hoped there's a more flexible way to do it (by flexible I mean being able to read/write untyped datas so that you can save non registered types, like in C...). Hurriedly the pointer support :) Lbas
  9. Hi all, I would like to register a standard write file script method with a prototype like this : size_t file::write( void* ptr, size_t size ); such as you could write any kind of data in the file. How guys would you manage to register it (if possible) ? Another way would be to register dedicated write methods for each possible types (like WriteInt8, WriteInt16, etc.), but just wondered if it was possible to stay near to the standard C way to be more flexible, for example if user wants to declare a structure in its script and then write it out in a binary file (without serializing process). PS: same for file::read() of course :) Thanks in advance, Regards, Lbas
  10. Lbas

    Pointer access to a primiter memory area

    Thanks WitchLord, It works fine and it's an alternative to write more optimized algorithms, we would just have to replace all 'GetRef(p)' with '*p' when it will be available. Thanks a lot, Lbas
  11. Hi, I would like to be able writing something like this in my scipts : uint8* p = GetDataPtr(); for( ...; ... ;... ) { uint n = *p; p++; } I know that pointer are (still :)) not allowed, but is there any other way (using references or such) to do that without registering complex object ? The reason here is for performance issue : accessing buffer using some GetData( nIdx ) registered method is very very slower than getting a pointer on it and walk through datas (while it's not safe:)), so parsing huge amount of datas (like image processing :)) is a big issue. Thanks in advance, Lbas
  12. Hi, I investigated more on it and found that my function declaration (the registered one) was cleared into the asCScriptEngine from the RemoveArrayType() method (called from ClearUnusedTypes() itself called from Discard() :)). In fact, after running a script, I call Discard(). That's explain why my script works the first time and not the second. So here's the call stack I got where the array type is cleared: -->asCScriptEngine::RemoveArrayType(asCObjectType *) asCScriptEngine::ClearUnusedTypes() asCScriptEngine::Discard(const char *) MyEngine::RunScript() Here's the way I'm compiling and running a script (skiping unrelated parts), Is this correct ? : asIScriptEngine* pEngine; .. init stuff, registering etc .. pEngine->AddScriptSection( NULL, scriptName, scriptText, scriptLen, 0 ); pEngine->Build( NULL ) asIScriptContext* pContext = pEngine->CreateContext(); pContext->SetExceptionCallback( ... ) pContext->Prepare( pEngine->GetFunctionIDByName( "", "main" ) ) pContext->Execute() pContext->Release() pEngine->ResetModule( NULL ); pEngine->Discard( NULL ); Is this correct ? In particular, do I need to call both ResetModule() & Discard() between two running scripts ? Regards, Lbas
  13. Hi, I made the test using your test framework, into test_array.cpp, and it worked, so it confirms the problem comes from my part. I'm using unsafe references, so I'm looking in that way... I'll let you know. Regards, Lbas
  14. Hi, Sorry, I didn't mention I use 2.6.0 The problem I encounter sounds like a memory "patch", so it probably comes from my part. I'll try to reproduce it using provided string factory for example, trying to isolate the problem. Regards, Seb
  15. Hi, I want to declare a function such that users can pass a string array from scripts like that : STRING[] strArray; // (STRING is a string factory, based on wxString from wxWidgets) MyClass obj; // purpose is obj filling a string array, returning array length (same as using strArray.length() after the call int n = obj.BuildArray( strArray ); I registered it in C++ : r = pEngine->RegisterObjectMethod( "MyClass", "int BuildArray( STRING[]& out destArray ) const", asMETHODPR( cMyClass, BuildArray, ( asIScriptArray& ) const, int ), asCALL_THISCALL ); with method : int cMyClass::BuildArray( asIScriptArray& destArray ) const { // validate array type if( (m_pEngine) && (destArray.GetArrayTypeId() == m_pEngine->GetTypeIdByDecl( 0, "STRING[]" )) ) { destArray.Resize( 2 ); *((STRING*)destArray.GetElementPointer( 0 )) = "one"; *((STRING*)destArray.GetElementPointer( 1 )) = "two"; } return destArray.GetElementCount(); } Then all works fine the first time I execute the script, but if I execute it twice (re-compiling it twice), I run into an assert in asCCompiler::ConvertToVariableNotIn(), on expression ctx->type.dataType.IsReference() I guess it's related to object handles or such (but make some tries without success). Any Idea ? BTW, Is there a tutorial on how receive an array reference (here a string array, but for any other types) in a registered method/function ? Thanks, Lbas
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!