-
Notifications
You must be signed in to change notification settings - Fork 281
s3fifo add ghost fifo #21653
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
Merged
Merged
s3fifo add ghost fifo #21653
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
7cdb069
s3fifo
cpegeric f285c50
Merge branch 'main' into s3fifo
mergify[bot] 39962f2
cleanup s3fifo
cpegeric 3657f06
Merge branch 's3fifo' of github.com:cpegeric/matrixone into s3fifo
cpegeric 1221a24
update
cpegeric c74b9ba
update
cpegeric 57fdc12
add license
cpegeric ed93655
remove shards
cpegeric 85b5127
update comment
cpegeric 308a877
fix sca
cpegeric 1f35b2a
add shardmap and cleanup mutex
cpegeric 748d4f6
fix sca
cpegeric 9548e7c
gofmt
cpegeric d0e0f5e
use RWMutex
cpegeric 64ff0b0
revert queue changes
cpegeric 64c377a
update
cpegeric bd1dcd3
Merge branch 'main' into s3fifo-merge
cpegeric 203959b
cleanup
cpegeric 375ba77
fix sca
cpegeric 062d820
cleanup
cpegeric eb79a8c
more comments
cpegeric 2a18a98
bug fix and add s3fifo related tests
cpegeric 7ba1be8
set min target = 1
cpegeric 6742e29
test push to main when ghost has entries
cpegeric 2c2ad79
fix evict criteria
cpegeric cf2120b
Revert "fix evict criteria"
cpegeric a677266
reuse the old evict
cpegeric 4f9c530
add bench2
cpegeric 8ab887e
update
cpegeric 48b9a96
update
cpegeric dec93cc
b.N
cpegeric 894e10e
add license
cpegeric 452d372
Merge branch 'main' into s3fifo
cpegeric 71db09e
add disable_s3fifo
cpegeric f65a319
add disable_s3fifo
cpegeric e5a38e3
set 32K per data
cpegeric a596684
improve the locking
cpegeric 4439fc0
use defer unlock
cpegeric a82d397
fix sca test and merge fix
cpegeric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,130 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// 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 fifocache | ||
|
||
import ( | ||
"context" | ||
"math/rand/v2" | ||
"runtime" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/matrixorigin/matrixone/pkg/fileservice/fscache" | ||
) | ||
|
||
const g_cache_size = 51200000 // 512M | ||
const g_item_size = 128000 // 128K | ||
const g_io_read_time = 20 * time.Microsecond | ||
|
||
func cache_read(ctx context.Context, cache *Cache[int64, int64], key int64) { | ||
|
||
_, ok := cache.Get(ctx, key) | ||
if !ok { | ||
// cache miss and sleep penalty as IO read | ||
time.Sleep(g_io_read_time) | ||
cache.Set(ctx, key, int64(0), g_item_size) | ||
} | ||
} | ||
|
||
func get_rand(start int64, end int64, r *rand.Rand) int64 { | ||
return start + r.Int64N(end-start) | ||
} | ||
|
||
func dataset_read(b *testing.B, ctx context.Context, cache *Cache[int64, int64], startkey int64, endkey int64, r *rand.Rand) { | ||
|
||
ncpu := runtime.NumCPU() | ||
var wg sync.WaitGroup | ||
|
||
for i := 0; i < ncpu; i++ { | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
for n := 0; n < b.N; n++ { | ||
|
||
if n%ncpu != i { | ||
continue | ||
} | ||
|
||
//fmt.Printf("start = %d, end = %d\n", startkey, endkey) | ||
for range endkey - startkey { | ||
|
||
key := get_rand(startkey, endkey, r) | ||
cache_read(ctx, cache, key) | ||
} | ||
} | ||
}() | ||
} | ||
|
||
wg.Wait() | ||
} | ||
|
||
func data_shift(b *testing.B, time int64) { | ||
ctx := context.Background() | ||
cache_size := g_cache_size | ||
cache := New[int64, int64](fscache.ConstCapacity(int64(cache_size)), ShardInt[int64], nil, nil, nil, false) | ||
r := rand.New(rand.NewPCG(1, 2)) | ||
|
||
offset := int64(0) | ||
start := int64(0) | ||
end := int64(g_cache_size) / int64(g_item_size) * time | ||
d1 := []int64{start, end} | ||
offset += end | ||
d2 := []int64{offset + start, offset + end} | ||
offset += end | ||
d3 := []int64{offset + start, offset + end} | ||
|
||
b.ResetTimer() | ||
|
||
dataset_read(b, ctx, cache, d1[0], d1[1], r) | ||
dataset_read(b, ctx, cache, d2[0], d2[1], r) | ||
dataset_read(b, ctx, cache, d3[0], d3[1], r) | ||
} | ||
|
||
func data_readNx(b *testing.B, time int64) { | ||
ctx := context.Background() | ||
cache_size := g_cache_size | ||
cache := New[int64, int64](fscache.ConstCapacity(int64(cache_size)), ShardInt[int64], nil, nil, nil, false) | ||
start := int64(0) | ||
end := int64(g_cache_size) / int64(g_item_size) * time | ||
r := rand.New(rand.NewPCG(1, 2)) | ||
|
||
b.ResetTimer() | ||
dataset_read(b, ctx, cache, start, end, r) | ||
} | ||
|
||
func BenchmarkSimCacheRead1x(b *testing.B) { | ||
data_readNx(b, 1) | ||
} | ||
|
||
func BenchmarkSimCacheRead1xShift(b *testing.B) { | ||
data_shift(b, 1) | ||
} | ||
|
||
func BenchmarkSimCacheRead2x(b *testing.B) { | ||
data_readNx(b, 2) | ||
} | ||
|
||
func BenchmarkSimCacheRead2xShift(b *testing.B) { | ||
data_shift(b, 2) | ||
} | ||
|
||
func BenchmarkSimCacheRead4x(b *testing.B) { | ||
data_readNx(b, 4) | ||
} | ||
|
||
func BenchmarkSimCacheRead4xShift(b *testing.B) { | ||
data_shift(b, 4) | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.