Proposal: Use struct to refine PageFile meta part
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1k
- Forks
- 423
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 24
Description
In pagefile.cpp function genWriteData or MetaMergingReader::moveNext , you can see we operate the PageFile meta info by put/get.
PageUtil::put
PageUtil::get
there are three disadvantages:
- The granularity of operation is too large, you can only operate the whole PageFile.
- All operation in write/reader function and also it can't split. So it hard to change and iteration new function into it.
- it's hard to changed , if we keep use point read/write meta info.
- Poorly readable. eq. you can found out what's info being the meta.
Suggestion :
Use the struct replace put/get function. struct can quick serialization/deserialization a memory buffer with special alignment.
here is a example for it:
// for meta head
struct meta_header {
uint64_t meta_byte_size : 32,
uint64_t meta_version : 32,
uint64_t meta_sequence_id : 64,
uint64_t meta_crc : 64
}
struct meta_wb_entry {
uint64_t wb_type : 8,
union wb_put_insert {
....
},
union wb_del {
....
},
union wb_ref {
....
}
}
struct flied_offset {
...
}
and also change writer/reader to :
- meta writer/reader
- wb writer/reader
- filed_offset writer/reader
- wb writer/reader
meta writer/reader will hold wb writer/reader , and wb writer/reader will hold filed_offset writer/reader(if type is put/upsert).
don't worry about memory problem , cause meta only need hold one write/reader with different buffer. also it can replace the meta reader hasNext , moveNext operation.
and there are two advantage for this proposal:
- It can split different in disk layer in PageFile , and make it more flexable and readable. eq. you can add more change into it.
- It can help next generation PageFile format and better compatibility with different versions of PageFile
- If the customer needs to switch the version of PageFile(when they want to upgrade tiflash version), or just migration the data. it will be more easy to do that.
- It can help make tools more convenient, eq . if i want to make a perf tool or a test tool, it can be more convenient.
@flowbehappy @JaySon-Huang can you review this proposal?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading pagefile.cpp, especially genWriteData and MetaMergingReader::moveNext, and trace how PageUtil::put and PageUtil::get currently handle PageFile metadata. Done would require an agreed struct-based metadata design plus the proposed layered meta, write-buffer, and field-offset readers and writers, with compatibility and tooling requirements resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, databases
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100