Skip to content

Build the LogBucket table the shingler settings ask for - #224

Open
r0ny123 wants to merge 5 commits into
familiary:mainfrom
r0ny123:fix/202-logbucket-table-per-parameters
Open

r0ny123 wants to merge 5 commits into
familiary:mainfrom
r0ny123:fix/202-logbucket-table-per-parameters

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #202, closes #215.

LogBucket cached its table as mcrit/cache/logbuckets.json no matter which max_value and bucket_width it was built for, and loaded that file whenever it existed. Since the package ships the file, every installation hashed with the 100,000 / 1 default table. SHINGLER_LOGBUCKETS and SHINGLER_LOGBUCKET_RANGE quietly did nothing — LogBucket(1024, 1) handed back 100,000 entries — and when the file was missing, a fresh one got written into the package directory, which can be read-only and is shared by every worker starting at the same time.

The shipped file is now logbuckets_100000_1.json, byte for byte the same table. Any other combination is built in memory once per process and never written anywhere. The builder uses a set for its membership test, so a full 100,000-entry table takes about 0.2 s instead of 1.3 s, and a test pins its output against the shipped file.

Deployment After upgrading
default logbucket settings hashes exactly as before, nothing to do
non-default settings was hashing with the default table all along; MinHashes now follow the config, so it needs a re-index (and fresh exports, since their config.shingler hash already named the non-default values)

Settings the builder can't serve properly (a range of 5 or more, a max_value too small for the range, max_value < 1, a negative range) now raise ValueError when the shinglers load, instead of a KeyError halfway through indexing; non-int values raise TypeError. The release smoke test checks that LogBucket() really loads the shipped table, not just that the file is there.

I checked the default path against a real corpus as well (7,244 samples, read-only): 3,655 functions recomputed from cached SMDA reports come out byte-identical to the stored MinHashes and to main. Unit and mongo suites, ruff and ty are green.

LogBucket cached its table as mcrit/cache/logbuckets.json whatever max_value
and bucket_width it was built for, and loaded that file whenever it existed.
The package ships it, so every installation hashed with the 100,000/1 default
table and SHINGLER_LOGBUCKETS and SHINGLER_LOGBUCKET_RANGE had no effect
(familiary#202, familiary#215).

The shipped file is now logbuckets_100000_1.json, byte for byte the same
table, so default deployments hash exactly as before. Any other table is
built in memory once per process and never written, since the package
directory may be read-only and several workers start at once. Building it
takes 0.2 s at 100,000 entries instead of 1.3 s, with a set for the builder's
membership test; its output is unchanged, which a test pins against the
shipped file.

The builder cannot give every value its full range once the width reaches 5,
or when max_value is too small for the width, which an installed package never
reached. Such a table is now refused with ValueError when the shinglers are
loaded rather than failing with KeyError in the middle of indexing, as are a
max_value below 1, a negative width and non-int values.

The release smoke test checks that LogBucket() loads the shipped table
instead of only that the file exists.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant