Skip to content

wip: reduce size of thread buckets at larger maxtermsize#829

Draft
jodavies wants to merge 2 commits into
form-dev:masterfrom
jodavies:threadbuckets
Draft

wip: reduce size of thread buckets at larger maxtermsize#829
jodavies wants to merge 2 commits into
form-dev:masterfrom
jodavies:threadbuckets

Conversation

@jodavies
Copy link
Copy Markdown
Collaborator

These commits address the second point of the discussion in #795. With the default buffer sizes nothing changes, but then the size of the threadbuckets increases only logarithmically with maxtermsize, until eventually it increases linearly again to ensure at least BUCKETMINTERMS=2 terms fit. But this linear increase is much slower than the current behaviour, which is 125*MaxTermSize.

The compressbuffer can also start small, and be doubled in size only when necessary.

Only forcer and mbox1l tests in form-bench set a larger-than-default maxtermsize. With 24 workers, the forcer allocation (80K maxtermsize) goes from 22.4GB -> 20.4GB, but the mbox1l (3M maxtermsize) reduces from 389GB -> 260GB. There is no measurable change in performance.

Any thoughts on this?

jodavies added 2 commits May 13, 2026 16:07
Splitting the buffer will allow valgrind to detect out-of-bounds
accesses of deferbuffer or threadbuffer.

Start with a small compressbuffer, and double it as needed. This
saves a lot of memory with many threads and large maxtermsize.
Using "large" values of MaxTermSize (say, 5M, 10M, ...) results in
very large allocations for the thread buffers, since they historically
have been ThreadBucketCount(500)/4*MaxTermSize * 2 * workers, which
easily reaches 100GB or more.

Reduce the size of these allocations, such that with the default setup
nothing changes, and then the buffers grow as log(MaxTermSize), up to
the point where we enforce a BUCKETMINTERMS*MaxTermSize limit. Then
they grow linearly, but BUCKETMINTERMS is much smaller than the default
ThreadBucketCount.
@jodavies jodavies marked this pull request as draft May 14, 2026 05:01
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 58.456% (-0.03%) from 58.481% — jodavies:threadbuckets into form-dev:master

@jodavies
Copy link
Copy Markdown
Collaborator Author

Related: #831 separately takes the mbox1l test allocation to 353GB. The forcer test is unaffected (its configured small+large is not the limiting factor).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants