diskquota
diskquota copied to clipboard
Add DiskquotaStatus.
This PR adds a DiskquotaStatus struct to maintain the shared memory usage caused by TableSizeMap and QuotaInfoMap.
Let's use TableSizeEntry as the example:
- totale_table_size_entries: the TableSizeEntry count in all bgworker.
- allocated_table_size_entries[workerid]: how many entries are allocated in the current bgworker.
Increase count:
- When
allocated[workerid] == hash_get_num_entries(table_size_map)
, the hashmap needs to allocate more memory for entries, which depends onchoose_nelem_alloc(Size entrysize)
. Thenallocated[workerid] += choose_nelem_alloc()
.
Decrease count:
- After using
hash_search(HASH_REMOVE)
to remove an entry from the table_size_map, the counter in table_size_map will be decreased automatically and the count of allocated memory keeps unchanged.