-
Notifications
You must be signed in to change notification settings - Fork 212
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
stack item FIFO or LIFO to minimise page miss #162
Comments
It's LIFO, of course. Comment fixed. Thanks for spotting it! |
The code https://github.com/sustrik/libmill/blob/master/stack.c#L169 calls "push_back", which places item in the end, doesn't it? |
Ah, correct. Look few lines below that. The stack is popped and deallocated. However, we cannot deallocate the stack we are running on... I guess that with a bit of effort you can reshuffle the code is such a way that it's true LIFO. |
You meat this one: https://github.com/sustrik/libmill/blob/master/stack.c#L178? Since it's LIFO, could we do sth like "pop_back" to free the last in the slist? |
I would simply first delete one stack from the cache (if appropriate) then put the current one to the cache. |
The stack that needs to be deleted should be the last one, if LIFO is respected. Had a quick look at slist, it seems that it doesn't support implementing pop_back easily... Since each stack frame has the same size, using sth like slab allocator seems more sensible, IMO. |
Sounds good, would you like to implement that? |
Further investigation convinced me that ring buffer is a simple data structure for LIFO in this case. |
https://github.com/sustrik/libmill/blob/master/stack.c#L77-L78 This makes sense, because next pop would get the stack item from previous push, which is presumably "hot". However, https://github.com/sustrik/libmill/blob/master/stack.c#L76 mentions FIFO, while it seems like LIFO. The implementation, https://github.com/sustrik/libmill/blob/master/stack.c#L169 if I understand correctly, is FIFO actually. Is the comment outdated or what?
The text was updated successfully, but these errors were encountered: