mirror of
				https://github.com/minio/minio.git
				synced 2025-10-31 08:11:19 +01:00 
			
		
		
		
	Design: https://gist.github.com/klauspost/025c09b48ed4a1293c917cecfabdf21c Gist of improvements: * Cross-server caching and listing will use the same data across servers and requests. * Lists can be arbitrarily resumed at a constant speed. * Metadata for all files scanned is stored for streaming retrieval. * The existing bloom filters controlled by the crawler is used for validating caches. * Concurrent requests for the same data (or parts of it) will not spawn additional walkers. * Listing a subdirectory of an existing recursive cache will use the cache. * All listing operations are fully streamable so the number of objects in a bucket no longer dictates the amount of memory. * Listings can be handled by any server within the cluster. * Caches are cleaned up when out of date or superseded by a more recent one.
		
			
				
	
	
		
			124 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			124 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cmd
 | |
| 
 | |
| // Code generated by github.com/tinylib/msgp DO NOT EDIT.
 | |
| 
 | |
| import (
 | |
| 	"bytes"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/tinylib/msgp/msgp"
 | |
| )
 | |
| 
 | |
| func TestMarshalUnmarshalmetacache(t *testing.T) {
 | |
| 	v := metacache{}
 | |
| 	bts, err := v.MarshalMsg(nil)
 | |
| 	if err != nil {
 | |
| 		t.Fatal(err)
 | |
| 	}
 | |
| 	left, err := v.UnmarshalMsg(bts)
 | |
| 	if err != nil {
 | |
| 		t.Fatal(err)
 | |
| 	}
 | |
| 	if len(left) > 0 {
 | |
| 		t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
 | |
| 	}
 | |
| 
 | |
| 	left, err = msgp.Skip(bts)
 | |
| 	if err != nil {
 | |
| 		t.Fatal(err)
 | |
| 	}
 | |
| 	if len(left) > 0 {
 | |
| 		t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func BenchmarkMarshalMsgmetacache(b *testing.B) {
 | |
| 	v := metacache{}
 | |
| 	b.ReportAllocs()
 | |
| 	b.ResetTimer()
 | |
| 	for i := 0; i < b.N; i++ {
 | |
| 		v.MarshalMsg(nil)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func BenchmarkAppendMsgmetacache(b *testing.B) {
 | |
| 	v := metacache{}
 | |
| 	bts := make([]byte, 0, v.Msgsize())
 | |
| 	bts, _ = v.MarshalMsg(bts[0:0])
 | |
| 	b.SetBytes(int64(len(bts)))
 | |
| 	b.ReportAllocs()
 | |
| 	b.ResetTimer()
 | |
| 	for i := 0; i < b.N; i++ {
 | |
| 		bts, _ = v.MarshalMsg(bts[0:0])
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func BenchmarkUnmarshalmetacache(b *testing.B) {
 | |
| 	v := metacache{}
 | |
| 	bts, _ := v.MarshalMsg(nil)
 | |
| 	b.ReportAllocs()
 | |
| 	b.SetBytes(int64(len(bts)))
 | |
| 	b.ResetTimer()
 | |
| 	for i := 0; i < b.N; i++ {
 | |
| 		_, err := v.UnmarshalMsg(bts)
 | |
| 		if err != nil {
 | |
| 			b.Fatal(err)
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func TestEncodeDecodemetacache(t *testing.T) {
 | |
| 	v := metacache{}
 | |
| 	var buf bytes.Buffer
 | |
| 	msgp.Encode(&buf, &v)
 | |
| 
 | |
| 	m := v.Msgsize()
 | |
| 	if buf.Len() > m {
 | |
| 		t.Log("WARNING: TestEncodeDecodemetacache Msgsize() is inaccurate")
 | |
| 	}
 | |
| 
 | |
| 	vn := metacache{}
 | |
| 	err := msgp.Decode(&buf, &vn)
 | |
| 	if err != nil {
 | |
| 		t.Error(err)
 | |
| 	}
 | |
| 
 | |
| 	buf.Reset()
 | |
| 	msgp.Encode(&buf, &v)
 | |
| 	err = msgp.NewReader(&buf).Skip()
 | |
| 	if err != nil {
 | |
| 		t.Error(err)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func BenchmarkEncodemetacache(b *testing.B) {
 | |
| 	v := metacache{}
 | |
| 	var buf bytes.Buffer
 | |
| 	msgp.Encode(&buf, &v)
 | |
| 	b.SetBytes(int64(buf.Len()))
 | |
| 	en := msgp.NewWriter(msgp.Nowhere)
 | |
| 	b.ReportAllocs()
 | |
| 	b.ResetTimer()
 | |
| 	for i := 0; i < b.N; i++ {
 | |
| 		v.EncodeMsg(en)
 | |
| 	}
 | |
| 	en.Flush()
 | |
| }
 | |
| 
 | |
| func BenchmarkDecodemetacache(b *testing.B) {
 | |
| 	v := metacache{}
 | |
| 	var buf bytes.Buffer
 | |
| 	msgp.Encode(&buf, &v)
 | |
| 	b.SetBytes(int64(buf.Len()))
 | |
| 	rd := msgp.NewEndlessReader(buf.Bytes(), b)
 | |
| 	dc := msgp.NewReader(rd)
 | |
| 	b.ReportAllocs()
 | |
| 	b.ResetTimer()
 | |
| 	for i := 0; i < b.N; i++ {
 | |
| 		err := v.DecodeMsg(dc)
 | |
| 		if err != nil {
 | |
| 			b.Fatal(err)
 | |
| 		}
 | |
| 	}
 | |
| }
 |