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

Please have a new run! #10

Open
aggsol opened this issue Jan 17, 2017 · 16 comments
Open

Please have a new run! #10

aggsol opened this issue Jan 17, 2017 · 16 comments

Comments

@aggsol
Copy link

aggsol commented Jan 17, 2017

This is great.

@r-lyeh-archived
Copy link
Owner

I will probably update all code bases & give it a new run this summer. I'm busy until then! :/

@asbai
Copy link

asbai commented Jan 24, 2017

I am also looking forward to the new results.

@asbai
Copy link

asbai commented Jan 25, 2017

I recommend using gcc (MinGW for windows) to compile angelscript. Because the standard string add-on of angelscript use std::string by default. And the performance of MSVC std::string is low (just allocate and copy, no reference counting and copy-on-write support. It's a big hurt for something like a benchmark).

I guess in most serious real cases where performance is a matter, almost all programmers will implement them own string type by hand. For example, we can even eliminate the memory allocation and memory copy overhead of the String Factory by using the static data semantic (see: https://www.gamedev.net/topic/685672-is-it-safe-to-use-the-char-argument-of-string-factory-as-static-data/). So in real case the performance can be further improved.

The purpose of the test is to reflect the true level of the engine, So I think it is necessary to adjust the engine to its real world status.

@asbai
Copy link

asbai commented Jan 25, 2017

Also, I suspect that register a line callback could dramatically slow down the engine. Use another timer thread which call ctx->Abort() on timeout instead.

@rosshadden
Copy link

I feel like there is a way this project can be architected such that these tests run on a VM and can be contributed by and perhaps even run by the community. It would be work up front, but in the long run would both mitigate a lot of work that @r-lyeh has to do, and let us keep it updated. Maybe we should brainstorm about ways to do that that aren't too difficult.

@aggsol
Copy link
Author

aggsol commented Jan 25, 2017

@rosshadden Like continuos integration? Whenever a library or test case is changed then run it again.

@rosshadden
Copy link

Yeah.

@iSLC
Copy link

iSLC commented Jan 31, 2017

Probably Off Topic:

@asbai AFAIK, MinGW/GCC don't use reference counting and copy-on-write design for std::string. What they're using is a small-buffer optimization. Meaning, if your string is less than 16 characters, then it'll be stored in a local buffer and no heap allocation is performed. This makes the string type size be 8 bytes bigger than it would normally be and require some extra work (like when doing move semantics). But it pays off in the end because you avoid heap allocation for small strings and you never have to check for null buffer because there's always a buffer present. Also, why only 8 extra bytes when the local buffer is 16 bytes? (on 64 bit at least) It uses a union for the local buffer and capacity since the capacity is always known for the local buffer. Kinda like:

struct String {
    static constexpr size_t MINCAP = 16;

    char * m_Buffer;
    size_t m_Occupied;

    union {
        char    m_LocalBuffer[MINCAP];
        size_t  m_Capacity;
    };

    String() noexcept
        : m_Buffer(m_LocalBuffer), m_Occupied(0)
    {
        m_LocalBuffer[0] = '\0';
    }
};

If you're so hell bent on avoiding string copies where not necessary. I'd suggest investing some time in studying string/array views. Which were even added in the next C++17 standard.

@r-lyeh-archived
Copy link
Owner

r-lyeh-archived commented Jan 31, 2017

Good ideas overall.

  • I've used CI a lot in most of my other repos and it's a valuable tool. Definitely @todo.
  • The VM idea sounds exciting and I am open to suggestions, what are the current options?
  • Current fibonacci test is somewhat lame, but very portable across all the implementations, plus it is handy to discard languages that lacks CC/tail optimization (also, bad for procedural stuff). Gotta add more computational/numeric tests. PRs welcome :)
  • Angelscript test (any test in fact!) should not use strings at all. If it does (like printing the fibonacci number), then it is my own mistake. Gotta review soon. No time right now :)

@asbai
Copy link

asbai commented Jan 31, 2017

@iSLC No, you are wrong :-)
At least in my gcc 4.4.7 and 4.5.2, they all use reference count for std::basic_string, you can check it at "bits/basic_string.h" in gcc's "include/c++" directory:

template<typename _CharT, typename _Traits, typename _Alloc>
  class basic_string
   {
      // Types:
    public:
      // ...
    private:
      struct _Rep_base
      {
	size_type    _M_length;
	size_type    _M_capacity;
	_Atomic_word _M_refcount; // <---- here
      };
       // ...

In addition, I did not use the GCC string class, I use my own string class with reference counting and copy-on-write support.

PS: The algorithm you described is very similar to what is used in VC++ STL, not GCC :-)

@asbai
Copy link

asbai commented Jan 31, 2017

@r-lyeh Sorry, I can not found where the test scripts were stored, I guess you have some string performance test like this: https://codeplea.com/game-scripting-languages.

So which algorithms we are using now?

UPDATE: I found it under the "tests" folder. :-)
It looks like the native2 test passed a string argument repeatedly? String performance may have a significant impact on this.

@iSLC
Copy link

iSLC commented Jan 31, 2017

@asbai I'm talking about GCC 5.x, 6.x and future versions.

@asbai
Copy link

asbai commented Jan 31, 2017

@iSLC Ok, so it's clearly that gcc 4.x is more benchmark friendly :-)

Especially for engines like AngelScript which has the ability to avoid the memory allocation and copy cost of the script / native calling conversion.

The memory allocation and copy cost of the native call is one of the biggest performance killer of dynamic languages.

@r-lyeh-archived
Copy link
Owner

@asbai, only fib.as is currently benchmarked. the native* and prime* tests are part of the original article you linked and are yet to be converted to the rest of languages before evaluation. such a difficult/boring task! :)

ps: the fib.as script is printing the result as I originally thought. this issue needs some global review before running the whole bench to be more fair at results.

@asbai
Copy link

asbai commented Jan 31, 2017

@r-lyeh Ok, I think the ability of fast native calling conversion will not cause unfairness, because it is a feature of the language and the engine. Just like JIT is a feature of some engine.

But a line callback is unfair unless you have been registered this call back for every other engines. :-)

PS: The author of AngelScript suggest us to use:
engine->SetEngineProperty(asEP_BUILD_WITHOUT_LINE_CUES, true);
to disable the line cues and not register any line callback under release (daily use production) mode.

@r-lyeh-archived
Copy link
Owner

Aha thanks, will do in the next run :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants