forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…db#74091 73750: changefeedccl: limit in-memory rowfetcher cache r=[miretskiy] a=HonoreDB We generate a row.Fetcher for each new version of a watched table, and cache it in-memory. This is technically an unbounded memory usage and thus could cause an OOM, although in practice you won't hit that unless you are Schema Changes Georg, the hypothetical outlier who makes thousands of schema changes a second. To support Schema Changes Georg, this PR bounds the size of the cache and evicts the oldest record. There's smarter stuff we could do (per an existing TODO) to eagerly evict records using resolved timestamps, but that's an optimization only a small subset of hypothetical Georgs would care about (those running single changefeeds on many tables, all with many rapid schema changes) so I doubt we'll want to bother. Release note: None 73805: backupccl: add BackupMonitor to memory monitor file stitching r=dt a=adityamaru This change adds a BackupMonitor that hangs off the bulk memory monitor. This monitor currently only guards the queue that we use to buffer SSTs while stitching them together in the sstSink. Informs: cockroachdb#73815 Release note: None 74088: bazel: pass path argument to `find` r=irfansharif a=rickystewart The bare `find -name ...` invocation without a path argument fails on some versions of `find`, namely the one installed on macOS machines. Release note: None 74091: bazel: build `dev` with `--config nonogo` r=irfansharif a=rickystewart I didn't do this unconditionally because I was afraid it would thrash the cache, but in my testing it seems to not really happen (at least, compiling `dev` with `nonogo` is so fast that it vastly outweighs any invalidation that may be happening). Closes cockroachdb#74004. Release note: None Co-authored-by: Aaron Zinger <[email protected]> Co-authored-by: Aditya Maru <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
- Loading branch information
Showing
13 changed files
with
194 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2017 The Cockroach Authors. | ||
// | ||
// Licensed as a CockroachDB Enterprise file under the Cockroach Community | ||
// License (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt | ||
|
||
package backupccl | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/util/mon" | ||
"github.com/cockroachdb/cockroach/pkg/util/syncutil" | ||
) | ||
|
||
// memoryAccumulator is a thin wrapper around a BoundAccount that only releases memory | ||
// from the bound account when it is closed, otherwise it accumulates and | ||
// re-uses resources. | ||
// This is useful when resources, once accumulated should not be returned as | ||
// they may be needed later to make progress. | ||
// It is safe for concurrent use. | ||
type memoryAccumulator struct { | ||
syncutil.Mutex | ||
ba mon.BoundAccount | ||
reserved int64 | ||
} | ||
|
||
// newMemoryAccumulator creates a new accumulator backed by a bound account created | ||
// from the given memory monitor. | ||
func newMemoryAccumulator(mm *mon.BytesMonitor) *memoryAccumulator { | ||
return &memoryAccumulator{ba: mm.MakeBoundAccount()} | ||
} | ||
|
||
// request checks that the given number of bytes is available, requesting some | ||
// from the backing monitor if necessary. | ||
func (acc *memoryAccumulator) request(ctx context.Context, requested int64) error { | ||
acc.Lock() | ||
defer acc.Unlock() | ||
|
||
if acc.reserved >= requested { | ||
acc.reserved -= requested | ||
return nil | ||
} | ||
|
||
requested -= acc.reserved | ||
acc.reserved = 0 | ||
|
||
return acc.ba.Grow(ctx, requested) | ||
} | ||
|
||
// release releases a number of bytes back into the internal reserved pool. | ||
func (acc *memoryAccumulator) release(released int64) { | ||
acc.Lock() | ||
defer acc.Unlock() | ||
|
||
acc.reserved += released | ||
} | ||
|
||
// close returns all accumulated memory to the backing monitor. | ||
func (acc *memoryAccumulator) close(ctx context.Context) { | ||
acc.Lock() | ||
defer acc.Unlock() | ||
|
||
acc.reserved = 0 | ||
acc.ba.Close(ctx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.