Open carmineos opened 3 years ago
For instance these are the number of lists contained (as embedded parts) in core.ypt
blocks:
RageLib.Resources.Common.SimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_009]: 74541
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.KeyframeProp]: 16533
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.Behaviour]: 8310
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_006]: 7225
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.EvolutionName]: 3278
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_003]: 3278
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_007]: 3278
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_013]: 1662
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.ShaderVar]: 1662
RageLib.Resources.Common.ResourceSimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_012]: 1662
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.EventEmitter]: 934
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Drawables.ShaderFX]: 46
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Drawables.DrawableGeometry]: 46
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Drawables.DrawableModel]: 46
RageLib.Resources.Common.SimpleList64`1[System.UInt32]: 5
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Textures.TextureDX11]: 1
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Drawables.Drawable]: 1
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.ParticleRule]: 1
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.EffectRule]: 1
RageLib.Resources.Common.ResourcePointerList64`1[RageLib.Resources.GTA5.PC.Particles.EmitterRule]: 1
I've made a quick and dirty test at https://github.com/carmineos/gta-toolkit/tree/test/lists replacing just
RageLib.Resources.Common.SimpleList64`1[RageLib.Resources.GTA5.PC.Particles.Unknown_P_009]: 74541
with a struct holding the array header data.
When replacing list blocks with structs, the containing block will remove such list blocks from GetParts()
and add the pointed array to GetReferences()
Before
| Method | filename | save | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------ |--------- |------ |-----------:|---------:|---------:|-----------:|-----------:|----------:|----------:|
| LoadSaveYpt | core.ypt | False | 733.4 ms | 6.37 ms | 5.96 ms | 20000.0000 | 9000.0000 | 3000.0000 | 226.48 MB |
| LoadSaveYpt | core.ypt | True | 2,800.6 ms | 26.84 ms | 25.11 ms | 48000.0000 | 16000.0000 | 4000.0000 | 477.27 MB |
After
| Method | filename | save | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------ |--------- |------ |-----------:|---------:|---------:|-----------:|-----------:|----------:|----------:|
| LoadSaveYpt | core.ypt | False | 652.5 ms | 10.03 ms | 9.38 ms | 17000.0000 | 8000.0000 | 3000.0000 | 190.17 MB |
| LoadSaveYpt | core.ypt | True | 2,652.2 ms | 34.90 ms | 30.94 ms | 39000.0000 | 14000.0000 | 3000.0000 | 422.07 MB |
The list blocks should be replaced with value types, they are part of the structure data of the blocks which contain them, they are never referenced by another block, the actual references are the arrays the point at. This will improve invoking GetParts which won't have to iterate on such "parts" and will drastically reduce number of allocations specially in resources like Particles. They are all 16 bytes structs (pointer to array, count, capacity, padding).
The involved blocks are: