Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resourcemanger: add cpu scheduler #39886

Merged
merged 32 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
14901ca
improve code
hawkingrei Dec 16, 2022
c528b13
*: fix revive false positive with generics
hawkingrei Dec 6, 2022
b354171
*: fix revive false positive with generics
hawkingrei Dec 6, 2022
2470c69
*: fix revive false positive with generics
hawkingrei Dec 6, 2022
6b3ff7b
update
hawkingrei Dec 6, 2022
bd60251
manage -> manager
hawkingrei Dec 6, 2022
6787d94
update
hawkingrei Dec 6, 2022
ca126e8
*: upgrade manage
hawkingrei Dec 7, 2022
e1ce5fb
use RWMutex
hawkingrei Dec 8, 2022
8c5287d
update commit
hawkingrei Dec 8, 2022
e9144c5
update commit
hawkingrei Dec 8, 2022
ce63425
refactor
hawkingrei Dec 9, 2022
279f27c
improve code
hawkingrei Dec 12, 2022
3ec7dc4
add comments
hawkingrei Dec 12, 2022
e7a8496
add comments
hawkingrei Dec 12, 2022
7e2e1bd
update test
hawkingrei Dec 12, 2022
2cfff72
minCPUSchedulerInterval use atomic value
hawkingrei Dec 12, 2022
681677b
minCPUSchedulerInterval use atomic value
hawkingrei Dec 12, 2022
1548c33
*: cpu resource manager
hawkingrei Dec 13, 2022
32a4f05
*: cpu resource manager
hawkingrei Dec 13, 2022
986a6a1
resourcemanger: add cpu scheduler
hawkingrei Dec 13, 2022
14cb418
resourcemanger: add cpu scheduler
hawkingrei Dec 13, 2022
1c873dd
resourcemanger: add cpu scheduler
hawkingrei Dec 13, 2022
4f1504b
resourcemanger: add cpu scheduler
hawkingrei Dec 13, 2022
8de0b4e
expression: close recordset
hawkingrei Dec 14, 2022
3588a50
*: add test
hawkingrei Jan 3, 2023
a509c0d
*: add test
hawkingrei Jan 3, 2023
d35f3e2
update bazel
hawkingrei Jan 3, 2023
da11763
update bazel
hawkingrei Jan 3, 2023
1abbfb9
bazel update
hawkingrei Jan 4, 2023
ce0cfec
update
hawkingrei Jan 4, 2023
1a4c7d6
Merge branch 'master' into add_resource_manage_2
ti-chi-bot Jan 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
*: add test
Signed-off-by: Weizhen Wang <[email protected]>
  • Loading branch information
hawkingrei committed Jan 4, 2023
commit 3588a5009567e134fc7cef93ec79fe2a754486b3
96 changes: 96 additions & 0 deletions resourcemanager/util/mock_gpool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright 2022 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 util

import "time"

// MockGPool is only for test
type MockGPool struct {
name string
}

// NewMockGPool is only for test
func NewMockGPool(name string) *MockGPool {
return &MockGPool{name: name}
}

// Release is only for test
func (m *MockGPool) Release() {
panic("implement me")
}

// Tune is only for test
func (m *MockGPool) Tune(size int) {
panic("implement me")
}

// LastTunerTs is only for test
func (m *MockGPool) LastTunerTs() time.Time {
panic("implement me")
}

// MaxInFlight is only for test
func (m *MockGPool) MaxInFlight() int64 {
panic("implement me")
}

// InFlight is only for test
func (m *MockGPool) InFlight() int64 {
panic("implement me")
}

// MinRT is only for test
func (m *MockGPool) MinRT() uint64 {
panic("implement me")
}

// MaxPASS is only for test
func (m *MockGPool) MaxPASS() uint64 {
panic("implement me")
}

// Cap is only for test
func (m *MockGPool) Cap() int {
panic("implement me")
}

// LongRTT is to represent the baseline latency by tracking a measurement of the long term, less volatile RTT.
func (m *MockGPool) LongRTT() float64 {
panic("implement me")
}

func (m *MockGPool) UpdateLongRTT(f func(float64) float64) {
panic("implement me")
}

// ShortRTT is to represent the current system latency by tracking a measurement of the short time, and more volatile RTT.
func (m *MockGPool) ShortRTT() uint64 {
panic("implement me")
}

// GetQueueSize is only for test
func (m *MockGPool) GetQueueSize() int64 {
panic("implement me")
}

// Running is only for test
func (m *MockGPool) Running() int {
panic("implement me")
}

// Name is only for test
func (m *MockGPool) Name() string {
return m.name
}
38 changes: 38 additions & 0 deletions resourcemanager/util/shard_pool_map_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2022 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 util

import (
"strconv"
"sync/atomic"
"testing"

"github.com/stretchr/testify/require"
)

func TestShardPoolMap(t *testing.T) {
rc := 10
pm := NewShardPoolMap()
for i := 0; i < rc; i++ {
id := strconv.FormatInt(int64(i), 10)
require.NoError(t, pm.Add(id, &PoolContainer{Pool: NewMockGPool(id), Component: DDL}))
}
require.Error(t, pm.Add("1", &PoolContainer{Pool: NewMockGPool("1"), Component: DDL}))
var cnt atomic.Int32
pm.Iter(func(pool *PoolContainer) {
cnt.Add(1)
})
require.Equal(t, rc, int(cnt.Load()))
}