Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Don't use batch size for channel buffers #258

Merged
merged 2 commits into from
Oct 28, 2019

Conversation

seebs
Copy link
Contributor

@seebs seebs commented Oct 25, 2019

Channel buffers are there to let workers do a bit more work
while things are running, but batch size is for the amount of stuff
we want to accumulate before dropping a whole batch of computed
results off with the server. There's no reason for the channel buffer
to be that size, and having it be that size (which is typically at
least 65536) means that each import worker is typically sitting on
a channel that has about a million interface-flavored objects containing
pointers to records in it, and suddenly we have memory pressure.

(Fixes, I hope, #4.)

seebs added 2 commits October 25, 2019 18:21
Channel buffers are there to let workers do a bit more work
while things are running, but batch size is for the amount of stuff
we want to accumulate before dropping a whole batch of computed
results off with the server. There's no reason for the channel buffer
to be that size, and having it be that size (which is typically at
least 65536) means that each import worker is typically sitting on
a channel that has about a million interface-flavored objects containing
pointers to records in it, and suddenly we have memory pressure.
In a previous version of this, I thoughtfully resliced slices
to [:0] rather than allocating. That's a great idea, except that
you don't necessarily ever see a given shard again. If you
don't see that shard again, or if you don't get as many items
in it, all the old record pointers are still sitting there in
reachable parts of the slice's backing store, preventing them
from ever being garbage collected.
@seebs
Copy link
Contributor Author

seebs commented Oct 26, 2019

FWIW: a workload that was getting OOM-killed somewhere past 30GB of memory before this is staying under 1GB of memory after this. This is the mysterious memory leak I was pretty sure I'd detected in imagine, but hadn't fixed yet.

@tgruben
Copy link
Contributor

tgruben commented Oct 28, 2019

@seebs
Copy link
Contributor Author

seebs commented Oct 28, 2019

There's some utility to small-positive channel sizes, although mostly as an implementation of semaphores, but they can be useful for buffering to provide some insulation against bursty things. But we definitely don't need 65k+ sized channels.

@seebs seebs merged commit 39c2f0e into FeatureBaseDB:master Oct 28, 2019
@seebs seebs mentioned this pull request Nov 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants