Straight to the action? set up your C# solution and resource or see examples
- Performance
- Dividing CitizenFX.Core.dll into multiple libraries
- Native updates and compatibility
- Hello fast Coroutines, bye bye slow Tasks
- Tick-less, removing unnecessary per-frame overhead
- Implicit parameter conversion for events, exports, and callbacks
Get on v2 and be the cyan guy |
*first mono runtime takes the biggest hit as well |
- Interop: all interop between C# and C++ is now done through thunks, a simple intermediate call
- Events and Exports are at least 84 times faster
- String recoding is 43~47% faster, precoding strings is also an option
- No unnecessary recoding on strings that aren't used
- Implicit parameter conversion on events, exports, and callbacks, decreasing invocation time by another 3 times.
- Runtime enter/exit cost: the default 0.04~0.06ms overhead cost in v1 has been eliminated, enjoy your 0.00ms.
- Custom
taskcoroutine scheduler: no longer uses the .NET scheduler, which brought quite some overhead. - Natives:
- Client can expect speed increases of 40~84% and higher
- Servers on Windows have a ~10 times speed increase (WSL ~160 times)
- Custom native invocation can expect speed increases by 10-folds
In v1 everything was included in CitizenFX.Core.dll, v2 comes with separated libraries
- CitizenFX.Core.dll: Core functionality for client, server, and shared libraries
- CitizenFX.Server.dll: Server related types and natives
- CitizenFX.FiveM.dll: FiveM (GTA V) related types and functionality
- CitizenFX.FiveM.Native.dll: All natives for FiveM (GTA V), make a copy of this one
- CitizenFX.RedM.dll RedM (RDR 2) related types and functionality
- CitizenFX.RedM.Native.dll: All natives for RedM (RDR 2), make a copy of this one
v2 will allow C# programmers to finally get back on track with the latest natives, allowing them to use the most up-to-date types that are currently known. At some point we'll even be able to add and remove parameters to natives!
This does come with some extra work for you as you'll need to copy the latest CitizenFX.FiveM.Native.dll for FiveM or CitizenFX.RedM.Native.dll for RedM and supply it with your resource. Doing this will add backwards compatibility to your C# resource, allowing them to always find the native methods they were compiled against. Failing to do so will result in MissingMethodException
s in the future, rendering your resource broken.
Task/Task<T> are used for the default .NET scheduler and its performance is well... really bad. It's now replaced with a custom scheduler that you can use by using Coroutine/Coroutine<T>, it's as simple as replacing Task with Coroutine and you are making use of it!
* As a side note; although its scheduler is no longer restricted, we do not offer any support for using Task in v2 and may be prone to deactivation if required.
v2 got updated to run on the core scheduler, removing any runtime switching cost (that were left) when there's no Tick
methods scheduled in your resource.
Now go and set up your C# solution and resource!