Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Oct 12, 2023
1 parent cf1e28d commit 12f3cfe
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: go test -race -v ./...
run: go test -race -v ./...
- name: go test -v ./...
run: go test -v ./...

coverage:
runs-on: 'ubuntu-latest'
Expand All @@ -34,7 +34,7 @@ jobs:
with:
go-version: '1.20'
- name: Run coverage
run: go test -race -covermode=atomic -coverprofile=coverage.out -v ./...
run: go test -covermode=atomic -coverprofile=coverage.out -v ./...
- name: Convert coverage.out to coverage.lcov
uses: jandelgado/gcov2lcov-action@v1
- name: Coveralls
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ It's primary focus is implementing [TVIX](https://cs.tvl.fyi/depot/-/tree/tvix)

## Roadmap

- [ ] Store
- [x] Store
- [x] Blob Service
- [ ] Path Info Service
- [ ] Directory Service
- [x] Path Info Service
- [x] Directory Service
- [ ] Improve test coverage

## Requirements

Expand Down
5 changes: 3 additions & 2 deletions internal/cli/store/run.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package store

import (
tvpb "code.tvl.fyi/tvix/store/protos"
"github.com/brianmcgee/nvix/pkg/pathinfo"
"net"
"net/http"
"runtime/debug"
"syscall"

tvpb "code.tvl.fyi/tvix/store/protos"
"github.com/brianmcgee/nvix/pkg/pathinfo"

"github.com/brianmcgee/nvix/pkg/directory"

"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery"
Expand Down
2 changes: 0 additions & 2 deletions nix/dev/tvix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
}
{
name = "PATH_INFO_SERVICE_ADDR";
# eval = "sled://$TVIX_HOME/store/path-info";
value = "grpc+http://localhost:5000";
}
{
name = "DIRECTORY_SERVICE_ADDR";
value = "grpc+http://localhost:5000";
# eval = "sled://$TVIX_HOME/store/directory";
}
{
name = "TVIX_MOUNT_DIR";
Expand Down
16 changes: 10 additions & 6 deletions pkg/blob/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package blob
import (
"bytes"
"context"
"crypto/rand"
"io"
"math/rand"
"net"
"testing"

Expand Down Expand Up @@ -83,9 +83,11 @@ func BenchmarkBlobService_Put(b *testing.B) {
b.ResetTimer()

b.RunParallel(func(p *testing.PB) {
rng := rand.New(rand.NewSource(1))
data := make([]byte, size)
rng.Read(data)
_, err := rand.Read(data)
if err != nil {
b.Fatal(err)
}

r := bytes.NewReader(data)

Expand Down Expand Up @@ -133,9 +135,11 @@ func BenchmarkBlobService_Read(b *testing.B) {
for _, size := range sizes {
size := size

rng := rand.New(rand.NewSource(1))
data := make([]byte, size)
rng.Read(data)
_, err := rand.Read(data)
if err != nil {
b.Fatal(err)
}

r := bytes.NewReader(data)

Expand Down Expand Up @@ -210,7 +214,7 @@ func TestBlobService_Put(t *testing.T) {
conn := test.GrpcConn(lis, t)
client := pb.NewBlobServiceClient(conn)

payload := make([]byte, 100*1024*1024)
payload := make([]byte, 16*1024*1024)
_, err := rand.Read(payload)
if err != nil {
t.Fatalf("failed to generate random bytes: %v", err)
Expand Down
7 changes: 4 additions & 3 deletions pkg/pathinfo/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package pathinfo

import (
"bytes"
"context"
"io"

capb "code.tvl.fyi/tvix/castore/protos"
tvpb "code.tvl.fyi/tvix/store/protos"
"context"

"github.com/brianmcgee/nvix/pkg/blob"
"github.com/brianmcgee/nvix/pkg/directory"
"github.com/brianmcgee/nvix/pkg/store"
Expand All @@ -17,7 +20,6 @@ import (
"github.com/nix-community/go-nix/pkg/nixbase32"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"io"
)

func NewServer(conn *nats.Conn, blob *blob.Server, directory *directory.Server) (*Service, error) {
Expand Down Expand Up @@ -76,7 +78,6 @@ func (s *Service) Get(ctx context.Context, req *tvpb.GetPathInfoRequest) (*tvpb.
l.Debug("executing", "outHash", outHash)

reader, err := s.outIdx.Get(outHash, ctx)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/store/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (c *CdcStore) Get(digest Digest, ctx context.Context) (io.ReadCloser, error
}

func (c *CdcStore) Put(reader io.ReadCloser, ctx context.Context) (*Digest, error) {

hasher := blake3.New(32, nil)
chunkHasher := blake3.New(32, nil)

Expand Down
4 changes: 2 additions & 2 deletions pkg/store/cdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func TestCdcStore_List(t *testing.T) {

digests := make(map[string]bool)

writeCount := 100
writeCount := 10
for i := 0; i < writeCount; i++ {
data := make([]byte, 20*1024*1024)
data := make([]byte, 8*1024*1024)
rng.Read(data)

digest, err := store.Put(io.NopCloser(bytes.NewReader(data)), context.Background())
Expand Down

0 comments on commit 12f3cfe

Please sign in to comment.