diff --git a/BitFaster.Caching.UnitTests/Lfu/NodeMemoryLayoutDumps.cs b/BitFaster.Caching.UnitTests/Lfu/NodeMemoryLayoutDumps.cs index 3ed11a65..7ac9eea9 100644 --- a/BitFaster.Caching.UnitTests/Lfu/NodeMemoryLayoutDumps.cs +++ b/BitFaster.Caching.UnitTests/Lfu/NodeMemoryLayoutDumps.cs @@ -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) | //|----------------------------------------------------| @@ -31,16 +31,16 @@ public NodeMemoryLayoutDumps(ITestOutputHelper testOutputHelper) //|----------------------------------------------------| //| 32-39: Object k__BackingField(8 bytes) | //|----------------------------------------------------| - //| 40-43: Position k__BackingField(4 bytes) | + //| 40-41: 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() @@ -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 k__BackingField(8 bytes) | + //|----------------------------------------------------| + //| 32-35: Int32 Key(4 bytes) | + //|----------------------------------------------------| + //| 36-37: 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>(includePaddings: true); + testOutputHelper.WriteLine(layout.ToString()); + } + + //Size: 72 bytes.Paddings: 4 bytes(%5 of empty space) //|====================================================| //| Object Header(8 bytes) | //|----------------------------------------------------| @@ -66,16 +98,16 @@ public void DumpAccessOrderNode() //|----------------------------------------------------| //| 32-39: Object k__BackingField(8 bytes) | //|----------------------------------------------------| - //| 40-43: Position k__BackingField(4 bytes) | + //| 40-41: 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) | //|----------------------------------------------------| diff --git a/BitFaster.Caching/Lfu/LfuNode.cs b/BitFaster.Caching/Lfu/LfuNode.cs index 5d37ad5e..e33f57a5 100644 --- a/BitFaster.Caching/Lfu/LfuNode.cs +++ b/BitFaster.Caching/Lfu/LfuNode.cs @@ -59,7 +59,7 @@ internal void Invalidate() } } - internal enum Position + internal enum Position : short { Window, Probation,