karolek110199 Posted August 22, 2015 Share Posted August 22, 2015 I don't know it's a good section, so i'm sorry. What do you think? One resource or few in gamemode. In the case of one resource, export is redundant, but is it a good optimization? Thanks for your answers! Link to comment
MTA Team botder Posted August 22, 2015 MTA Team Share Posted August 22, 2015 https://www.mta-sa.org/thread/31092-umf ... ufteilung/ I made a similiar voting in a different forum (German). Link to comment
Moderators IIYAMA Posted August 22, 2015 Moderators Share Posted August 22, 2015 Both choices have benefits, but it has nothing to do with optimization. You won't notice those extra execution time for exports. As long as you use more exports in stead of custom events, everything is al right. This is a choice for the developer, based on his knowledge and logic thinking. Some resources can be placed together and others can better not. Link to comment
MTA Team botder Posted August 22, 2015 MTA Team Share Posted August 22, 2015 There is a huge/noticeable performance difference between localized functions and exported functions. A good developer/scripter will find a balance between exported and local functions. Link to comment
myonlake Posted August 23, 2015 Share Posted August 23, 2015 A rather experienced scripter told me that he batched all of his gamemode scripts into a single resource and it ran more efficiently and was apparently many times faster than with multiple resources. You have a few more advantages with single resource too, as you can properly manage classes and objects without hassle. Also makes compiling easier, as you can ultimately compile your whole gamemode into two or three files: client and server, and additionally shared. You need to make sure you start building the gamemode properly. Building it wrong at first will come around and stab you in the back easily. Properly name your methods and functions. Use events whenever needed, but minimize the amount of events. Stack things together. Make use of Lua's coroutines and use tables efficiently. Updating the gamemode will become more difficult on a live server, if you want to perform live updates. Other than that you're good (live updates are never good anyway). Link to comment
MTA Team botder Posted August 23, 2015 MTA Team Share Posted August 23, 2015 Updating the gamemode will become more difficult on a live server, if you want to perform live updates. Other than that you're good (live updates are never good anyway). For live updates: Scheduled server restarts should happen every week (or every day) and only a stable script package should be on the "production" system. You should also control the memory/cpu usage if you keep the server running to check if there are any leaks in your script, which occur when the server runs under load (with players). About the part with the performance: I once made a local math.clamp and an exported function math_clamp (from an util resource) and tested the amount of times they were executed in a second. The local function had about 3200 calls and the exported function had something around 900 - 1000 if I recall correctly. You can say it's 3 times faster. As conclusion, you are likely to run into performance issues if you have many resources, which use exported functions. Try to make a main resource with the "critical" code and various other resources without exported functions, which purely work with events and no more, to avoid using the exported functions. Link to comment
JR10 Posted August 23, 2015 Share Posted August 23, 2015 What about the development process though? You'll have to restart the whole game-mode to implement any change, however small it is. Another disadvantage is extensibility and collaboration. It won't be a walk in the park to allow others to contribute and test their work. The major advantage for me is OOP, classes and objects are much easier to work with. Link to comment
myonlake Posted August 23, 2015 Share Posted August 23, 2015 What about the development process though? You'll have to restart the whole game-mode to implement any change, however small it is. Another disadvantage is extensibility and collaboration. It won't be a walk in the park to allow others to contribute and test their work.The major advantage for me is OOP, classes and objects are much easier to work with. Indeed. These are the things for a single resource. Really depends what you are doing and how are you doing it from a technical point of view. You could have everything set into their own resources, but then you would have your own compiler which compiles all resources into a single package with just those three core files that run the server script. It could work, but there could be conflicts, and that's never good. Link to comment
JR10 Posted August 23, 2015 Share Posted August 23, 2015 It isn't. Performance aside, it's better to use several resources. As for live updates, like Necktrox said, scheduled server restarts would do. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now