Skip to content

What is the process understanding of this part of the code? #1193

Answered by SandyXSD
dannyfe asked this question in Q&A
Discussion options

You must be logged in to vote

Basically this function is used to write data p to the slice (aka, wChunk). There is a field pages in wChunk that is used to cache data, so what the function does is just splitting p in an aligned way and copy bytes to pages.

As wChunk is split to several Blocks for further writing to the object storage, pages is a list of memory blocks. For better memory management, the first block in pages is split again to 64 KiB pages, in case len(p) is far smaller than BlockSize (defaults 4 MiB).

The following figure may help you better understand the process:

         64K 64K ...
wChunk: |_  _  _  _  ...  _|________|________|__...
               4 M             4M       4M      ...

     p:         …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dannyfe
Comment options

Answer selected by dannyfe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants