mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
feat(meta): Optimize the memory alignment of inode and dentry fields. #1000114802
Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
parent
c296a62206
commit
6f209ae5e9
@ -52,8 +52,8 @@ type DentryMultiSnap struct {
|
||||
|
||||
type Dentry struct {
|
||||
ParentId uint64 // FileID value of the parent inode.
|
||||
Name string // Name of the current dentry.
|
||||
Inode uint64 // FileID value of the current inode.
|
||||
Name string // Name of the current dentry.
|
||||
Type uint32
|
||||
// snapshot
|
||||
multiSnap *DentryMultiSnap
|
||||
|
||||
@ -77,32 +77,31 @@ type InodeMultiSnap struct {
|
||||
|
||||
type Inode struct {
|
||||
sync.RWMutex
|
||||
Inode uint64 // Inode ID
|
||||
Type uint32
|
||||
Uid uint32
|
||||
Gid uint32
|
||||
Size uint64
|
||||
Generation uint64
|
||||
CreateTime int64
|
||||
AccessTime int64
|
||||
ModifyTime int64
|
||||
// 8-bytes
|
||||
Inode uint64 // Inode ID
|
||||
Size uint64
|
||||
Generation uint64
|
||||
CreateTime int64
|
||||
AccessTime int64
|
||||
ModifyTime int64
|
||||
Reserved uint64 // reserved space
|
||||
LeaseExpireTime uint64
|
||||
|
||||
// 4-bytes
|
||||
Type uint32
|
||||
Uid uint32
|
||||
Gid uint32
|
||||
NLink uint32 // NodeLink counts
|
||||
Flag int32
|
||||
StorageClass uint32
|
||||
ClientID uint32
|
||||
|
||||
// pointer
|
||||
LinkTarget []byte // SymLink target name
|
||||
NLink uint32 // NodeLink counts
|
||||
Flag int32
|
||||
Reserved uint64 // reserved space
|
||||
// Extents *ExtentsTree
|
||||
// Extents *SortedExtents // in HybridCloud, this is for cache dp only
|
||||
|
||||
// ObjExtents *SortedObjExtents
|
||||
// Snapshot
|
||||
multiSnap *InodeMultiSnap
|
||||
|
||||
// HybridCloud
|
||||
StorageClass uint32
|
||||
multiSnap *InodeMultiSnap
|
||||
HybridCloudExtents *SortedHybridCloudExtents
|
||||
HybridCloudExtentsMigration *SortedHybridCloudExtentsMigration
|
||||
ClientID uint32
|
||||
LeaseExpireTime uint64
|
||||
}
|
||||
|
||||
func (i *Inode) LeaseNotExpire() bool {
|
||||
@ -635,7 +634,6 @@ func (i *Inode) MarshalV2(buff *buf.ByteBufExt) (err error) {
|
||||
|
||||
i.MarshalValueV2(tmpBuf)
|
||||
valBytes := tmpBuf.Bytes()
|
||||
// valBytes := i.MarshalValue()
|
||||
|
||||
keyLen := uint32(len(keyBytes))
|
||||
valLen := uint32(len(valBytes))
|
||||
|
||||
@ -315,3 +315,30 @@ func TestInodeMarshalCompitable(t *testing.T) {
|
||||
oldData = []byte{0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 195, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, 0, 107, 0, 0, 0, 7, 116, 101, 115, 116, 32, 111, 112, 0, 0, 0, 108, 0, 0, 0, 109, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
checkInodeCompatibility(oldData, oldIno, t)
|
||||
}
|
||||
|
||||
func BenchmarkInodeMarshal(b *testing.B) {
|
||||
oldIno := NewInode(1024, 0)
|
||||
oldIno.Uid = 101
|
||||
oldIno.Gid = 102
|
||||
oldIno.Generation = 104
|
||||
oldIno.CreateTime = 105
|
||||
oldIno.AccessTime = 106
|
||||
oldIno.ModifyTime = 107
|
||||
oldIno.NLink = 108
|
||||
oldIno.Flag = 109
|
||||
oldIno.StorageClass = proto.StorageClass_Replica_SSD
|
||||
oldIno.HybridCloudExtents.sortedEks = NewSortedExtentsFromEks([]proto.ExtentKey{{FileOffset: 100}})
|
||||
|
||||
buff := GetInodeBuf()
|
||||
defer PutInodeBuf(buff)
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
err := oldIno.MarshalV2(buff)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user