From c99164bcd91b01a4851ed9a4454e5b7acfc6cf56 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Thu, 5 Jan 2023 10:31:00 +0800 Subject: [PATCH 1/2] TxStats: add DEPRECATED comments for exported fields Signed-off-by: Wei Fu --- tx.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tx.go b/tx.go index 4d571b152..f8119a0b7 100644 --- a/tx.go +++ b/tx.go @@ -673,27 +673,45 @@ func (tx *Tx) Page(id int) (*PageInfo, error) { // TxStats represents statistics about the actions performed by the transaction. type TxStats struct { // Page statistics. + // + // DEPRECATED: Use GetPageCount() or IncPageCount() PageCount int64 // number of page allocations + // DEPRECATED: Use GetPageAlloc() or IncPageAlloc() PageAlloc int64 // total bytes allocated // Cursor statistics. + // + // DEPRECATED: Use GetCursorCount() or IncCursorCount() CursorCount int64 // number of cursors created // Node statistics + // + // DEPRECATED: Use GetNodeCount() or IncNodeCount() NodeCount int64 // number of node allocations + // DEPRECATED: Use GetNodeDeref() or IncNodeDeref() NodeDeref int64 // number of node dereferences // Rebalance statistics. - Rebalance int64 // number of node rebalances + // + // DEPRECATED: Use GetRebalance() or IncRebalance() + Rebalance int64 // number of node rebalances + // DEPRECATED: Use GetRebalanceTime() or IncRebalanceTime() RebalanceTime time.Duration // total time spent rebalancing // Split/Spill statistics. - Split int64 // number of nodes split - Spill int64 // number of nodes spilled + // + // DEPRECATED: Use GetSplit() or IncSplit() + Split int64 // number of nodes split + // DEPRECATED: Use GetSpill() or IncSpill() + Spill int64 // number of nodes spilled + // DEPRECATED: Use GetSpillTime() or IncSpillTime() SpillTime time.Duration // total time spent spilling // Write statistics. - Write int64 // number of writes performed + // + // DEPRECATED: Use GetWrite() or IncWrite() + Write int64 // number of writes performed + // DEPRECATED: Use GetWriteTime() or IncWriteTime() WriteTime time.Duration // total time spent writing to disk } From c1ce3b5ca86b19475c0f5609afee39d52caf1e42 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Thu, 5 Jan 2023 10:38:09 +0800 Subject: [PATCH 2/2] .github: use GOGC=30 to prevent high resource usage * Remove duplicate targets in Makefile * Use GOGC=30 to prevent high resource usage Signed-off-by: Wei Fu --- .github/workflows/tests.yaml | 24 +++++++++++++++++------- Makefile | 7 ++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2342f8ac5..00f2c8fe2 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -6,9 +6,10 @@ jobs: fail-fast: false matrix: target: + - linux-amd64-unit-test-1-cpu + - linux-amd64-unit-test-2-cpu - linux-amd64-unit-test-4-cpu - - linux-amd64-unit-test-4-cpu-freelist-hashmap-race - - linux-amd64-unit-test-2-cpu-freelist-array-short-race + - linux-amd64-unit-test-4-cpu-race runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -20,14 +21,23 @@ jobs: TARGET: ${{ matrix.target }} run: | case "${TARGET}" in + linux-amd64-unit-test-1-cpu) + CPU=1 make test + ;; + linux-amd64-unit-test-2-cpu) + CPU=2 make test + ;; linux-amd64-unit-test-4-cpu) CPU=4 make test ;; - linux-amd64-unit-test-4-cpu-freelist-hashmap-race) - CPU=4 ENABLE_RACE=true make test-freelist-hashmap - ;; - linux-amd64-unit-test-2-cpu-freelist-array-short-race) - CPU=2 ENABLE_RACE=true EXTRA_TESTFLAGS="-short" make test-freelist-array + linux-amd64-unit-test-4-cpu-race) + # XXX: By default, the Github Action runner will terminate the process + # if it has high resource usage. Try to use GOGC to limit memory and + # cpu usage here to prevent unexpected terminating. It can be replaced + # with GOMEMLIMIT=2048MiB if the go-version is updated to >=1.19.x. + # + # REF: https://github.com/actions/runner-images/issues/6680#issuecomment-1335778010 + GOGC=30 CPU=4 ENABLE_RACE=true make test ;; *) echo "Failed to find target" diff --git a/Makefile b/Makefile index fc6230124..f0584d181 100644 --- a/Makefile +++ b/Makefile @@ -19,14 +19,11 @@ fmt: lint: golangci-lint run ./... -test: test-freelist-hashmap test-freelist-array - -test-freelist-hashmap: +test: @echo "hashmap freelist test" TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout 30m TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./cmd/bbolt -test-freelist-array: @echo "array freelist test" TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout 30m TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./cmd/bbolt @@ -40,4 +37,4 @@ coverage: TEST_FREELIST_TYPE=array go test -v -timeout 30m \ -coverprofile cover-freelist-array.out -covermode atomic -.PHONY: fmt test test-freelist-hashmap test-freelist-array lint +.PHONY: fmt test lint