Skip to content
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

Open
albertnetymk opened this issue Sep 5, 2016 · 8 comments
Open

stack item FIFO or LIFO to minimise page miss #162

albertnetymk opened this issue Sep 5, 2016 · 8 comments

Comments

@albertnetymk
Copy link

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?

@sustrik
Copy link
Owner

sustrik commented Sep 6, 2016

It's LIFO, of course. Comment fixed. Thanks for spotting it!

@sustrik sustrik closed this as completed Sep 6, 2016
@albertnetymk
Copy link
Author

The code https://github.com/sustrik/libmill/blob/master/stack.c#L169 calls "push_back", which places item in the end, doesn't it?

@sustrik
Copy link
Owner

sustrik commented Sep 7, 2016

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.

@sustrik sustrik reopened this Sep 7, 2016
@albertnetymk
Copy link
Author

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?

@sustrik
Copy link
Owner

sustrik commented Sep 7, 2016

I would simply first delete one stack from the cache (if appropriate) then put the current one to the cache.

@albertnetymk
Copy link
Author

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.

@sustrik
Copy link
Owner

sustrik commented Sep 8, 2016

Sounds good, would you like to implement that?

@albertnetymk
Copy link
Author

Further investigation convinced me that ring buffer is a simple data structure for LIFO in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants