Blender Git Loki
Git Commits -> Revision d840658
Revision d840658 by Bastien Montagne (master) December 20, 2019, 13:29 (GMT) |
ID Management: Improve speed of code used when creating/renaming and ID. This alone can make e.g. adding 40k IDs with default name (i.e. 'fully constant' case in table below) about 15-20% faster: | Number and type of names of IDs | old code | new code | speed improvement | | -------------------------------- | -------- | -------- | ----------------- | | 40K, mixed (14k rand, 26k const) | 75s | 62s | 21% | | 40K, fully random | 90s | 76s | 18% | | 40K, fully constant | 94s | 77s | 22% | Idea is to use a first pass, where we just check one item every nth ones, until we have found the chunk in which we want to insert the new item, then do a basic linear comparison with all items in that chunk as before. Also, list is now walked backward, as in most common 'massive insertion' cases new ID's names have higher number, hence ends up towards the end of the list. This new sorting function can be between a few percents and 50% quicker than original code, depending on various factors (like length of common parts of ID names, whether new IDs should be added towards the end or not, how high in numbering we are, etc.). Note: another, full bisecting approach was also tried, which gives a massive reduction of comparisons (from n items to log2(n)), but it only gave minor improvements of speed from original fully linear code, while adding a fair amount of complexity to the logic. Only case it was shining was the unlikely 'very long, almost similar ID names' case (since `strcasecmp()` is rather costly then). |
Commit Details:
Full Hash: d84065807810d008ea57de39bd90ac417537c488
Parent Commit: 9984dd3
Lines Changed: +49, -7
1 Modified Path:
/source/blender/blenkernel/intern/library.c (+49, -7) (Diff)