Fix CHD MPHF: increase bucket ratio for large partitions
bucket_count = entry_count/3 caused CHD construction failure on ~113K entry right partition (bucket too crowded → displacement search exhausted 65536 tries). entry_count/2 gives more buckets, trades ~19KB displacement overhead for reliable construction.
This commit is contained in:
parent
0908dc7c85
commit
99bf19180e
1 changed files with 3 additions and 3 deletions
|
|
@ -170,7 +170,7 @@ def build_chd(keys_and_bytes, entry_count):
|
||||||
displacements[bucket] = d value
|
displacements[bucket] = d value
|
||||||
slot_to_entry_idx[slot] = index into keys_and_bytes, or -1 if empty
|
slot_to_entry_idx[slot] = index into keys_and_bytes, or -1 if empty
|
||||||
"""
|
"""
|
||||||
bucket_count = max(entry_count // 3, min(entry_count, 16))
|
bucket_count = max(entry_count // 2, min(entry_count, 16))
|
||||||
|
|
||||||
# Assign keys to buckets
|
# Assign keys to buckets
|
||||||
buckets = defaultdict(list)
|
buckets = defaultdict(list)
|
||||||
|
|
@ -271,7 +271,7 @@ def compile_mphf(entries, max_size=None, block_size=4096):
|
||||||
unique_count = len(unique_translations)
|
unique_count = len(unique_translations)
|
||||||
|
|
||||||
# Estimate size
|
# Estimate size
|
||||||
bucket_count = max(entry_count // 3, min(entry_count, 16))
|
bucket_count = max(entry_count // 2, min(entry_count, 16))
|
||||||
est_value_bits = max(1, math.ceil(math.log2(max(unique_count, 2))))
|
est_value_bits = max(1, math.ceil(math.log2(max(unique_count, 2))))
|
||||||
est_disp_bits = 16 # conservative
|
est_disp_bits = 16 # conservative
|
||||||
est_disp_bytes = (bucket_count * est_disp_bits + 7) // 8
|
est_disp_bytes = (bucket_count * est_disp_bits + 7) // 8
|
||||||
|
|
@ -318,7 +318,7 @@ def compile_mphf(entries, max_size=None, block_size=4096):
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
|
||||||
entry_count = len(keys_and_bytes)
|
entry_count = len(keys_and_bytes)
|
||||||
bucket_count = max(entry_count // 3, min(entry_count, 16))
|
bucket_count = max(entry_count // 2, min(entry_count, 16))
|
||||||
|
|
||||||
print(f" Building CHD MPHF: {entry_count} entries, {bucket_count} buckets...",
|
print(f" Building CHD MPHF: {entry_count} entries, {bucket_count} buckets...",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue