-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* metastore: Extract SQL query building and add benchmark * metastore: Optimize query building for retrieving location lines * metastore: Use improved SQL query pre-allocation heuristic Instead of pre-allocating pessimistically for the largest possible integer, the new heuristic uses the largest integer that actually occurs in the query.
- Loading branch information
Showing
2 changed files
with
79 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2021 The Parca Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package metastore | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"testing" | ||
) | ||
|
||
var result string | ||
|
||
func BenchmarkBuildLinesByLocationIDsQuery(b *testing.B) { | ||
for k := 0.; k <= 6; k++ { | ||
n := uint64(math.Pow(10, k)) | ||
b.Run(fmt.Sprintf("%d", n), func(b *testing.B) { | ||
input := make([]uint64, 0, n) | ||
for i := uint64(0); i < n; i++ { | ||
input = append(input, i) | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
result = buildLinesByLocationIDsQuery(input[len(input)-1], input) | ||
} | ||
}) | ||
} | ||
} |