sim: A trie data structure specifically to speed up paging lookups.
Review Request #1141 - Created April 7, 2012 and submitted
| Information | |
|---|---|
| Gabe Black | |
| gem5 | |
| default | |
| Reviewers | |
| Default | |
Changeset 8951:0f73b60079f2 --------------------------- sim: A trie data structure specifically to speed up paging lookups. This change adds a trie data structure which stores an arbitrary pointer type based on an address and a number of relevant bits. Then lookups can be done against the trie where the tree is traversed and the first legitimate match found is returned.
Issue Summary
| Description | From | Last Updated | Status |
|---|---|---|---|
| const std::string& title? | Andreas Hansson | April 8, 2012, 12:52 a.m. | Open |
| What about templating on the key type too (Addr)? Then it would be a totally generic trie and should definitely ... | Steve Reinhardt | April 8, 2012, 10:33 a.m. | Open |
| Not sure if the official style guide says anything, but my gut (and I think emacs) would line up the ... | Steve Reinhardt | April 8, 2012, 10:33 a.m. | Open |
| I don't see what you gain by separating lookup() and lookupNode(), since the latter is only called from the former, ... | Steve Reinhardt | April 8, 2012, 10:33 a.m. | Open |
It looks good. The level of comments definitely needs a bump to make Doxygen happy.
-
src/sim/addrtrie.hh (Diff revision 1) -
const std::string& title?
Seems fine overall, although I would think it would best be in src/base not src/sim. I second Andreas' comments about Doxygen.
Looks basically ok. I'd prefer to see this merged with the unit test and the x86 TLB patch and committed as a single changeset.
-
src/sim/addrtrie.hh (Diff revision 1) -
What about templating on the key type too (Addr)? Then it would be a totally generic trie and should definitely go in base and not sim.
-
src/sim/addrtrie.hh (Diff revision 1) -
Not sure if the official style guide says anything, but my gut (and I think emacs) would line up the two goesAfter() calls, not offset them by one space.
-
src/sim/addrtrie.hh (Diff revision 1) -
I don't see what you gain by separating lookup() and lookupNode(), since the latter is only called from the former, and the separation requires an extra check of node for being non-null.
-
src/sim/addrtrie.hh (Diff revision 1) -
i.e., just return node->value here instead of node and be done with it...
Description: |
|
|||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 2 (+465) |
Description: |
|
|---|
Description: |
|
|||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+469) |
Nice! Thanks. My only comment is that it still seems strange to have lookupHandle() in the public interface, particularly so now that it's not used anywhere in the x86 TLB code. [Aside: another reason to have the x86 TLB code folded in to the same patch... so we can more easily see how the trie code is supposed to be used at the same time we're reviewing it! ;-) not trying to start an argument, just couldn't resist making the point...] I can see where if someone wanted to use the trie but didn't want to bother tracking all the handles themselves, then you might think you'd need this. However, the only thing a user can do with a handle is call remove on it, so I'd advocate for making an overloaded remove(Key key) method like this: Handle h = lookupHandle(key); if (h) remove(h); You could even return a bool if you think the caller will ever care whether something actually got removed or not. Then lookupHandle() could be made protected, and you have a nice clean public interface that's basically just insert/lookup/remove, and the whole Handle thing is just an optimization to avoid an extra lookup by allowing users to call remove(Handle) instead of remove(Key). And people reading your code don't have to wonder why you've bothered to factor lookupHandle() out of lookup() even though no one else ever calls it...
-
src/base/trie.hh (Diff revisions 2 - 3) -
I think you mean Handle here (and elsewhere in this comment).
Description: |
|
|||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+486) |
Ship It!
