-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a faster linked list implementation #32234
Conversation
My only concern with swapping this out for std::list everywhere is from a cursory glance it looks like the first insertion into an empty list is going to be disproportionately expensive since the first block allocation will be large. If it does some kind of size increase strategy this concern is moot. |
As far as I can tell there is at least some kind of size increase strategy as there are minimum and maximum block sizes defined and the first allocation is always of the minimum block size. I haven't looked into this in detail though and can't yet tell you what that minimum size is aside from #define LIST_BLOCK_MIN static_cast<group_size_type>((sizeof(node) * 8 > (sizeof(*this) + sizeof(group)) * 2) ? 8 : (((sizeof(*this) + sizeof(group)) * 2) / sizeof(node)) + 1) Will look into it more in-depth this evening |
Alright I did some profiling and here are some numbers for lists of
As can be pretty clearly seen, this list implementation uses a growth factor of two, same as colony. I think this makes it fine for general use, but it's your call really. |
No that's totally fine, I was guessing there was a growth factor, but wanted to verify. |
Summary
SUMMARY: Infrastructure "Introduce a faster linked list implementation"
Purpose of change
The new 3d shadowcasting algorithm in #32012 uses an
std::list
which is not ideal in performance critical code asstd::list
is relatively slow.Describe the solution
The plflib list implementation is much faster than
std::list
, so I've imported that just like colony.Quoting from https://www.plflib.org/list.htm:
Describe alternatives you've considered
Not making things faster
Additional context
This PR merely imports the the list implementation, adjusts it to meet our needs, and adds tests.
In the next PR I plan to replace all uses of
std::list
in the codebase withcata::list
as it is a drop in replacement with no downsides aside from the removal of incomplete list splicing.