Hi,

I think there could be a mistake in freespace/README. There are
several places where it says about ~4000 slots per FSM page for the
default BLKSZ:

"""
For example, assuming each FSM page can hold information about 4 pages (in
reality, it holds (BLCKSZ - headers) / 2, or ~4000 with default BLCKSZ),
"""

and:

"""
To keep things simple, the tree is always constant height. To cover the
maximum relation size of 2^32-1 blocks, three levels is enough with the default
BLCKSZ (4000^3 > 2^32).
"""

Let's determine the amount of levels in each FSM page first. I'm going
to use Python for this. Note that range(0,13) returns 13 numbers from
0 to 12:

```
>>> sum([pow(2,n) for n in range(0,13) ])
8191
>>> 8*1024
8192
```

13 levels are not going to fit since we need extra 24 bytes per
PageHeaderData and a few more bytes for an int value fp_next_slot.
Which gives us 12 levels and the number of slots:

```
>>> # there are pow(2,0) == 1 byte on the 1st level of the tree
>>> pow(2,12 - 1)
2048
```

The number of levels in the entire, high-level tree, seems to be correct:

```
>>> pow(2048,3) > pow(2,32) - 1
True
```

Hopefully I didn't miss or misunderstood anything.

Thoughts?

-- 
Best regards,
Aleksander Alekseev


Reply via email to