Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
46583: workload: enhance querybench r=yuzefovich a=yuzefovich

Release justification: non-production code changes.

`querybench` workload has been enhanced to support queries that consist
of multiple statements that are present on a single line. Previously,
the workload would fail on such queries because it attempts to `Prepare`
the whole line which would error out. Now we're still attempting to
prepare the whole line, but if that fails, we will store plain query and
will be executing it using `DB.Query` rather that `Stmt.Query`.

Fixes: #46547.
Fixes: #46607.

Release note: None

46587: colexec: optimize resetting of buffered groups in merge joiner r=yuzefovich a=yuzefovich

**colexec: fix resetting of buffered groups**

Release justification: bug fixes and low-risk updates to new
functionality.

Previously, whenever we needed to reset the buffered groups, we would
close the spilling queue and would create a new one when needed. This is
an overkill since we could simply reset the spilling queues that we have
which reduces amount of allocations and improves the performance.

Addresses: #46502.

Release note: None

**logictest: make results of queries in vectorize test deterministic**

Release justification: non-production code changes.

Several queries in `vectorize` logic test could have produced different
results, and this is now fixed.

Fixes: #46630.

Release note: None

46595: colexec: further optimize hash aggregator r=yuzefovich a=yuzefovich

Release justification: low-risk update to new functionality (it is
low-risk because it does not change anything fundamentally, rather only
improves the way we handle allocations and clear an internal state).

This commit optimizes the hash aggregator relationship with selection
vectors. Previously, we were maintaining a map from hash code (`uint64`)
to a slice of ints, and this would result in creating a new int slice
for every hash code that the hash aggregator ever encounters during its
run. However, we're processing atmost (about) `batchTupleLimit` tuples
at once, so at most we can have the same number of different hash codes.
This observation allows us to have constant number of int slices. To
accommodate this, we introducing a map from hash code to the "slot" in
`[][]int`, and the map is maintained to contain hash codes that we need
to process. Once the hash code has been processed, the entry is deleted.
This way both the map and the number of int slices stays constant
throughout the run of the hash aggregator.

Also this commit refactors `makeAggregateFuncs` to separate out the
creation of output types (this has some impact on performance of hash
aggregator which makes aggregate functions for every group).

Release note: None

46668: cli,build: remove backtrace support r=yuzefovich a=petermattis

Support for Backtrace Labs out of process tracers (i.e. ptrace) has been
disabled since Nov 2016. We never found this integration useful. It is
past time to remove it.

Release justification: removal of unused code

Release note: None

46673: build: do not fail RocksDB build on compiler warnings r=yuzefovich a=petermattis

Disable `-Werror` for the RocksDB build which has recently started
complaining about a missing exception specification in a jemalloc header
with the newest version of Xcode.

Release justification: low risk change to remove developer build
irritation. Should be a no-op for production builds.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
Co-authored-by: Peter Mattis <[email protected]>
  • Loading branch information
3 people committed Mar 27, 2020
6 parents c395c44 + f9a536c + e09543f + 60a3846 + ffe79b1 + 7f61159 commit 515406a
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 293 deletions.
9 changes: 0 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ $(ROCKSDB_DIR)/Makefile: $(C_DEPS_DIR)/rocksdb-rebuild | bin/.submodules-initial
-DSNAPPY_LIBRARIES=$(LIBSNAPPY) -DSNAPPY_INCLUDE_DIR="$(SNAPPY_SRC_DIR);$(SNAPPY_DIR)" -DWITH_SNAPPY=ON \
$(if $(use-stdmalloc),,-DJEMALLOC_LIBRARIES=$(LIBJEMALLOC) -DJEMALLOC_INCLUDE_DIR=$(JEMALLOC_DIR)/include -DWITH_JEMALLOC=ON) \
-DCMAKE_BUILD_TYPE=$(if $(ENABLE_ROCKSDB_ASSERTIONS),Debug,Release) \
-DFAIL_ON_WARNINGS=$(if $(findstring windows,$(XGOOS)),0,1) \
-DUSE_RTTI=1
-DUSE_RTTI=1 -DFAIL_ON_WARNINGS=0

$(SNAPPY_DIR)/Makefile: $(C_DEPS_DIR)/snappy-rebuild | bin/.submodules-initialized
rm -rf $(SNAPPY_DIR)
Expand Down
6 changes: 0 additions & 6 deletions build/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ if test -e "${alternates_file}"; then
vols="${vols} --volume=${alternates_path}:${alternates_path}${cached_volume_mode}"
fi

backtrace_dir=${cockroach_toplevel}/../../cockroachlabs/backtrace
if test -d "${backtrace_dir}"; then
vols="${vols} --volume=${backtrace_dir}:/opt/backtrace${cached_volume_mode}"
vols="${vols} --volume=${backtrace_dir}/cockroach.cf:${container_home}/.coroner.cf${cached_volume_mode}"
fi

if [ "${BUILDER_HIDE_GOPATH_SRC:-}" != "1" ]; then
vols="${vols} --volume=${gopath0}/src:/go/src${cached_volume_mode}"
fi
Expand Down
2 changes: 1 addition & 1 deletion c-deps/rocksdb-rebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bump the version below when changing rocksdb CMake flags. Search for "BUILD
ARTIFACT CACHING" in build/common.mk for rationale.

13
14
123 changes: 0 additions & 123 deletions pkg/cli/backtrace.go

This file was deleted.

19 changes: 0 additions & 19 deletions pkg/cli/backtrace_unsupported.go

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func initCLIDefaults() {
startCtx.listeningURLFile = ""
startCtx.pidFile = ""
startCtx.inBackground = false
startCtx.backtraceOutputDir = ""

quitCtx.serverDecommission = false

Expand Down Expand Up @@ -325,9 +324,6 @@ var startCtx struct {

// logging settings specific to file logging.
logDir log.DirName

// directory to use for logging backtrace outputs.
backtraceOutputDir string
}

// quitCtx captures the command-line parameters of the `quit` command.
Expand Down
6 changes: 2 additions & 4 deletions pkg/cli/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@ func testServerArgsForTransientCluster(nodeID roachpb.NodeID, joinAddr string) b
storeSpec.StickyInMemoryEngineID = fmt.Sprintf("demo-node%d", nodeID)

args := base.TestServerArgs{
PartOfCluster: true,
Stopper: initBacktrace(
fmt.Sprintf("%s/demo-node%d", startCtx.backtraceOutputDir, nodeID),
),
PartOfCluster: true,
Stopper: stop.NewStopper(),
JoinAddr: joinAddr,
DisableTLSForHTTP: true,
StoreSpecs: []base.StoreSpec{storeSpec},
Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,6 @@ func setupAndInitializeLoggingAndProfiling(
if p := logOutputDirectory(); p != "" {
outputDirectory = p
}
startCtx.backtraceOutputDir = outputDirectory
serverCfg.GoroutineDumpDirName = filepath.Join(outputDirectory, base.GoroutineDumpDir)
serverCfg.HeapProfileDirName = filepath.Join(outputDirectory, base.HeapProfileDir)

Expand Down Expand Up @@ -1250,7 +1249,7 @@ func setupAndInitializeLoggingAndProfiling(
// Disable Stopper task tracking as performing that call site tracking is
// moderately expensive (certainly outweighing the infrequent benefit it
// provides).
stopper = initBacktrace(outputDirectory)
stopper = stop.NewStopper()
log.Event(ctx, "initialized profiles")

return stopper, nil
Expand Down
55 changes: 43 additions & 12 deletions pkg/sql/colexec/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ func NewOrderedAggregator(
isScalar: isScalar,
}

a.aggregateFuncs, a.outputTypes, err = makeAggregateFuncs(a.allocator, aggTypes, aggFns)

a.aggregateFuncs, err = makeAggregateFuncs(a.allocator, aggTypes, aggFns)
if err != nil {
return nil, errors.AssertionFailedf(
"this error should have been checked in isAggregateSupported\n%+v", err,
)
}
a.outputTypes, err = makeAggregateFuncsOutputTypes(aggTypes, aggFns)
if err != nil {
return nil, errors.AssertionFailedf(
"this error should have been checked in isAggregateSupported\n%+v", err,
Expand All @@ -224,9 +229,8 @@ func NewOrderedAggregator(

func makeAggregateFuncs(
allocator *Allocator, aggTyps [][]coltypes.T, aggFns []execinfrapb.AggregatorSpec_Func,
) ([]aggregateFunc, []coltypes.T, error) {
) ([]aggregateFunc, error) {
funcs := make([]aggregateFunc, len(aggFns))
outTyps := make([]coltypes.T, len(aggFns))

for i := range aggFns {
var err error
Expand All @@ -250,26 +254,46 @@ func makeAggregateFuncs(
case execinfrapb.AggregatorSpec_BOOL_OR:
funcs[i] = newBoolOrAgg()
default:
return nil, nil, errors.Errorf("unsupported columnar aggregate function %s", aggFns[i].String())
return nil, errors.Errorf("unsupported columnar aggregate function %s", aggFns[i].String())
}

if err != nil {
return nil, err
}
}

return funcs, nil
}

func makeAggregateFuncsOutputTypes(
aggTyps [][]coltypes.T, aggFns []execinfrapb.AggregatorSpec_Func,
) ([]coltypes.T, error) {
outTyps := make([]coltypes.T, len(aggFns))

for i := range aggFns {
// Set the output type of the aggregate.
switch aggFns[i] {
case execinfrapb.AggregatorSpec_COUNT_ROWS, execinfrapb.AggregatorSpec_COUNT:
// TODO(jordan): this is a somewhat of a hack. The aggregate functions
// should come with their own output types, somehow.
outTyps[i] = coltypes.Int64
default:
case
execinfrapb.AggregatorSpec_ANY_NOT_NULL,
execinfrapb.AggregatorSpec_AVG,
execinfrapb.AggregatorSpec_SUM,
execinfrapb.AggregatorSpec_SUM_INT,
execinfrapb.AggregatorSpec_MIN,
execinfrapb.AggregatorSpec_MAX,
execinfrapb.AggregatorSpec_BOOL_AND,
execinfrapb.AggregatorSpec_BOOL_OR:
// Output types are the input types for now.
outTyps[i] = aggTyps[i][0]
}

if err != nil {
return nil, nil, err
default:
return nil, errors.Errorf("unsupported columnar aggregate function %s", aggFns[i].String())
}
}

return funcs, outTyps, nil
return outTyps, nil
}

func (a *orderedAggregator) initWithOutputBatchSize(outputSize int) {
Expand Down Expand Up @@ -470,14 +494,21 @@ func isAggregateSupported(
return false, errors.Newf("sum_int is only supported on Int64 through vectorized")
}
}
_, outputTypes, err := makeAggregateFuncs(
_, err = makeAggregateFuncs(
nil, /* allocator */
[][]coltypes.T{aggTypes},
[]execinfrapb.AggregatorSpec_Func{aggFn},
)
if err != nil {
return false, err
}
outputTypes, err := makeAggregateFuncsOutputTypes(
[][]coltypes.T{aggTypes},
[]execinfrapb.AggregatorSpec_Func{aggFn},
)
if err != nil {
return false, err
}
_, retType, err := execinfrapb.GetAggregateInfo(aggFn, inputTypes...)
if err != nil {
return false, err
Expand Down
Loading

0 comments on commit 515406a

Please sign in to comment.