urho3d / urho3d

Game engine
https://urho3d.github.io
MIT License
4.55k stars 996 forks source link

AngelScript should define AS_NO_THREADS ? #1870

Closed iSLC closed 4 years ago

iSLC commented 7 years ago

Since the scripts are always executed in the main thread and no multi-threading seems to be performed via scripts. Should AS_NO_THREADS be defined at compile time? According to the documentation this should increase the performance by a bit.

Should I make a pull request for this or is it the intended behavior?

JSandusky commented 7 years ago

I wasn't around for the initial implementation of Angelscript but my concern would be the reference counting. During threading that may result in issues similar to sorting boost::shared_ptr in C++03, you had to use stable_sort to guarantee that parallelism didn't set the ref count to 0 and nuke an object.

It resulted in code that worked in debug builds, but broke unexplainably in release builds ... then you stable_sort it and it all just works because of the interim copy.

cadaver commented 7 years ago

To be sure, you would need to test quite thoroughly, including background threaded loads; see ScriptFile::BeginLoad() which creates the AS script module and uses the parser but could be executing in a background thread. It's true actual execution or script compilation never threads.

If there are no problems in practice, then AS_NO_THREADS would be good for the little bit of performance gain.

github-actions[bot] commented 4 years ago

Marking this stale since there has been no activity for 30 days. It will be closed if there is no activity for another 15 days.