Skip to content

Shrink Position enum #590

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions BitFaster.Caching.UnitTests/Lfu/NodeMemoryLayoutDumps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public NodeMemoryLayoutDumps(ITestOutputHelper testOutputHelper)
}

//Type layout for 'AccessOrderNode`2'
//Size: 48 bytes.Paddings: 2 bytes(%4 of empty space)
//Size: 48 bytes.Paddings: 4 bytes(%8 of empty space)
//|====================================================|
//| Object Header(8 bytes) |
//|----------------------------------------------------|
Expand All @@ -31,16 +31,16 @@ public NodeMemoryLayoutDumps(ITestOutputHelper testOutputHelper)
//|----------------------------------------------------|
//| 32-39: Object<Value> k__BackingField(8 bytes) |
//|----------------------------------------------------|
//| 40-43: Position<Position> k__BackingField(4 bytes) |
//| 40-41: Position<Position> k__BackingField(2 bytes) |
//| |===============================| |
//| | 0-3: Int32 value__(4 bytes) | |
//| | 0-1: Int16 value__(2 bytes) | |
//| |===============================| |
//|----------------------------------------------------|
//| 44: Boolean wasRemoved(1 byte) |
//| 42: Boolean wasRemoved(1 byte) |
//|----------------------------------------------------|
//| 45: Boolean wasDeleted(1 byte) |
//| 43: Boolean wasDeleted(1 byte) |
//|----------------------------------------------------|
//| 46-47: padding(2 bytes) |
//| 44-47: padding(4 bytes) |
//|====================================================|
[Fact]
public void DumpAccessOrderNode()
Expand All @@ -49,8 +49,40 @@ public void DumpAccessOrderNode()
testOutputHelper.WriteLine(layout.ToString());
}

//Type layout for 'TimeOrderNode`2'
//Size: 72 bytes.Paddings: 2 bytes(%2 of empty space)
//Type layout for 'AccessOrderNode`2'
//Size: 40 bytes.Paddings: 0 bytes(%0 of empty space)
//|====================================================|
//| Object Header(8 bytes) |
//|----------------------------------------------------|
//| Method Table Ptr(8 bytes) |
//|====================================================|
//| 0-7: LfuNodeList`2 list(8 bytes) |
//|----------------------------------------------------|
//| 8-15: LfuNode`2 next(8 bytes) |
//|----------------------------------------------------|
//| 16-23: LfuNode`2 prev(8 bytes) |
//|----------------------------------------------------|
//| 24-31: Object<Value> k__BackingField(8 bytes) |
//|----------------------------------------------------|
//| 32-35: Int32 Key(4 bytes) |
//|----------------------------------------------------|
//| 36-37: Position<Position> k__BackingField(2 bytes) |
//| |===============================| |
//| | 0-1: Int16 value__(2 bytes) | |
//| |===============================| |
//|----------------------------------------------------|
//| 38: Boolean wasRemoved(1 byte) |
//|----------------------------------------------------|
//| 39: Boolean wasDeleted(1 byte) |
//|====================================================|
[Fact]
public void DumpAccessOrderNode32()
{
var layout = TypeLayout.GetLayout<AccessOrderNode<int, object>>(includePaddings: true);
testOutputHelper.WriteLine(layout.ToString());
}

//Size: 72 bytes.Paddings: 4 bytes(%5 of empty space)
//|====================================================|
//| Object Header(8 bytes) |
//|----------------------------------------------------|
Expand All @@ -66,16 +98,16 @@ public void DumpAccessOrderNode()
//|----------------------------------------------------|
//| 32-39: Object<Value> k__BackingField(8 bytes) |
//|----------------------------------------------------|
//| 40-43: Position<Position> k__BackingField(4 bytes) |
//| 40-41: Position<Position> k__BackingField(2 bytes) |
//| |===============================| |
//| | 0-3: Int32 value__(4 bytes) | |
//| | 0-1: Int16 value__(2 bytes) | |
//| |===============================| |
//|----------------------------------------------------|
//| 44: Boolean wasRemoved(1 byte) |
//| 42: Boolean wasRemoved(1 byte) |
//|----------------------------------------------------|
//| 45: Boolean wasDeleted(1 byte) |
//| 43: Boolean wasDeleted(1 byte) |
//|----------------------------------------------------|
//| 46-47: padding(2 bytes) |
//| 44-47: padding(4 bytes) |
//|----------------------------------------------------|
//| 48-55: TimeOrderNode`2 prevTime(8 bytes) |
//|----------------------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lfu/LfuNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal void Invalidate()
}
}

internal enum Position
internal enum Position : short
{
Window,
Probation,
Expand Down
Loading