WopsS / RED4ext.SDK

A library to create mods for REDengine 4 (Cyberpunk 2077), independently of RED4ext.
MIT License
93 stars 31 forks source link

Optimized sorted array merging #66

Closed psiberx closed 1 year ago

psiberx commented 1 year ago

The main reason for this optimization is editing TweakDB. Flats are stored in a sorted unique array with over 2M entries. Flat insertion is expensive and adds up quickly when creating/cloning records with many properties.

The new method allows batch insertions. The bigger the batch, the bigger the gain.

N of insertions Avg. boost
10 8x
100 25x
1000 170x

With this optimization applied to creating/cloning records, a real mod that adds items shows around 20x faster load times (each item record has 80-110 properties).

WopsS commented 1 year ago

Nice improvement!