-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into fix-47508
Signed-off-by: Yang Keao <[email protected]>
- Loading branch information
Showing
228 changed files
with
11,858 additions
and
8,752 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7067,13 +7067,13 @@ def go_deps(): | |
name = "com_github_tikv_client_go_v2", | ||
build_file_proto_mode = "disable_global", | ||
importpath = "github.com/tikv/client-go/v2", | ||
sha256 = "e4953948d2346bf26d95fcc860b612c7c1d86f07c80a754db2551067912d37c8", | ||
strip_prefix = "github.com/tikv/client-go/[email protected].20231010061802-07432ef6c031", | ||
sha256 = "1b4e8e9df95d2ed7ff41d756cd00c8159f0aa9483791b50af8afebefa94e5b6c", | ||
strip_prefix = "github.com/tikv/client-go/[email protected].20231025022411-cad314220659", | ||
urls = [ | ||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip", | ||
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip", | ||
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip", | ||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231010061802-07432ef6c031.zip", | ||
"http://bazel-cache.pingcap.net:8080/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231025022411-cad314220659.zip", | ||
"http://ats.apps.svc/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231025022411-cad314220659.zip", | ||
"https://cache.hawkingrei.com/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231025022411-cad314220659.zip", | ||
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/tikv/client-go/v2/com_github_tikv_client_go_v2-v2.0.8-0.20231025022411-cad314220659.zip", | ||
], | ||
) | ||
go_repository( | ||
|
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 |
---|---|---|
|
@@ -123,6 +123,7 @@ reviewers: | |
- fixdb | ||
- fzzf678 | ||
- iamxy | ||
- jiyfhust | ||
- JmPotato | ||
- js00070 | ||
- lamxTyler | ||
|
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,75 @@ | ||
// Copyright 2023 PingCAP, Inc. | ||
// | ||
// 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 external | ||
|
||
import "github.com/docker/go-units" | ||
|
||
// DefaultBlockSize is the default block size for preAllocKVBuf. | ||
const DefaultBlockSize = 16 * units.MiB | ||
|
||
// preAllocKVBuf pre allocates a large buffer of limit memLimit to reduce memory | ||
// allocation, all space in this buffer will be reused when reset. | ||
type preAllocKVBuf struct { | ||
blocks [][]byte | ||
blockSize int | ||
curBlock []byte | ||
curBlockIdx int | ||
curIdx int | ||
} | ||
|
||
func newPreAllocKVBuf(memLimit uint64, blockSize int) *preAllocKVBuf { | ||
blockCount := (memLimit + uint64(blockSize) - 1) / uint64(blockSize) | ||
b := &preAllocKVBuf{ | ||
blocks: make([][]byte, 0, blockCount), | ||
blockSize: blockSize, | ||
} | ||
for i := 0; i < int(blockCount); i++ { | ||
b.blocks = append(b.blocks, make([]byte, blockSize)) | ||
} | ||
b.reset() | ||
return b | ||
} | ||
|
||
func (b *preAllocKVBuf) Alloc(s int) (blockIdx int32, res []byte, offset int32, allocated bool) { | ||
if s > b.blockSize { | ||
return | ||
} | ||
if b.blockSize-b.curIdx < s { | ||
if b.curBlockIdx+1 >= len(b.blocks) { | ||
return | ||
} | ||
b.curBlockIdx++ | ||
b.curBlock = b.blocks[b.curBlockIdx] | ||
b.curIdx = 0 | ||
} | ||
blockIdx = int32(b.curBlockIdx) | ||
res = b.curBlock[b.curIdx : b.curIdx+s] | ||
offset = int32(b.curIdx) | ||
allocated = true | ||
|
||
b.curIdx += s | ||
return | ||
} | ||
|
||
func (b *preAllocKVBuf) reset() { | ||
b.curBlockIdx = 0 | ||
b.curBlock = b.blocks[0] | ||
b.curIdx = 0 | ||
} | ||
|
||
func (b *preAllocKVBuf) destroy() { | ||
b.blocks = nil | ||
b.curBlock = nil | ||
} |
Oops, something went wrong.