Skip to content

Commit

Permalink
removed all timings
Browse files Browse the repository at this point in the history
  • Loading branch information
din-mukhammed committed Aug 14, 2023
1 parent 9af8457 commit 8fae5c8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package allocation

import (
"context"
"time"

"github.com/0chain/blobber/code/go/0chain.net/blobbercore/filestore"
"github.com/0chain/blobber/code/go/0chain.net/core/common"
"github.com/0chain/blobber/code/go/0chain.net/core/logging"
"go.uber.org/zap"
)

// BaseFileChanger base file change processor
Expand Down Expand Up @@ -95,12 +92,9 @@ func (fc *BaseFileChanger) CommitToFileStore(ctx context.Context) error {
fileInputData.ValidationRoot = fc.ValidationRoot
fileInputData.FixedMerkleRoot = fc.FixedMerkleRoot
fileInputData.ChunkSize = fc.ChunkSize
start := time.Now()
_, err := filestore.GetFileStore().CommitWrite(fc.AllocationID, fc.ConnectionID, fileInputData)
if err != nil {
return common.NewError("file_store_error", "Error committing to file store. "+err.Error())
}
elapsed := time.Since(start)
logging.Logger.Info("CommitToFileStore", zap.String("path", fc.Path), zap.Duration("elapsed", elapsed))
return nil
}
6 changes: 0 additions & 6 deletions code/go/0chain.net/blobbercore/filestore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"strings"
"sync"
"syscall"
"time"

"github.com/0chain/blobber/code/go/0chain.net/core/common"
"github.com/0chain/blobber/code/go/0chain.net/core/encryption"
Expand Down Expand Up @@ -244,7 +243,6 @@ func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData)
}

fileSize := rStat.Size()
start := time.Now()
hasher := GetNewCommitHasher(fileSize)
bufSize := BufferSize
if fileSize < BufferSize {
Expand All @@ -260,18 +258,15 @@ func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData)
if err != nil {
return false, common.NewError("finalize_error", err.Error())
}
elapsedHash := time.Since(start)
fmtRootBytes, err := hasher.fmt.CalculateRootAndStoreNodes(f)
if err != nil {
return false, common.NewError("fmt_hash_calculation_error", err.Error())
}
elapsedMerkle := time.Since(start) - elapsedHash

validationRootBytes, err := hasher.vt.CalculateRootAndStoreNodes(f)
if err != nil {
return false, common.NewError("validation_hash_calculation_error", err.Error())
}
elapsedValidation := time.Since(start) - elapsedMerkle - elapsedHash
fmtRoot := hex.EncodeToString(fmtRootBytes)
validationRoot := hex.EncodeToString(validationRootBytes)

Expand Down Expand Up @@ -305,7 +300,6 @@ func (fs *FileStore) CommitWrite(allocID, conID string, fileData *FileInputData)
// 5. Move: It is Copy + Delete. Delete will not delete file if ref exists in database. i.e. copy would create
// ref that refers to this file therefore it will be skipped
fs.incrDecrAllocFileSizeAndNumber(allocID, fileSize, 1)
logging.Logger.Info("CommitWrite", zap.Duration("elapsedHash", elapsedHash), zap.Duration("elapsedMerkle", elapsedMerkle), zap.Duration("elapsedValidation", elapsedValidation), zap.Duration("elapsedTotal", time.Since(start)))
return true, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"net/http"
"path/filepath"
"time"

"github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"

Expand Down Expand Up @@ -46,21 +45,18 @@ func (cmd *UploadFileCommand) GetPath() string {

// IsValidated validate request.
func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request, allocationObj *allocation.Allocation, clientID string) error {
start := time.Now()
if allocationObj.OwnerID != clientID && allocationObj.RepairerID != clientID {
return common.NewError("invalid_operation", "Operation needs to be performed by the owner or the payer of the allocation")
}

fileChanger := &allocation.UploadFileChanger{}

uploadMetaString := req.FormValue(UploadMeta)
elapsedReadForm := time.Since(start)
err := json.Unmarshal([]byte(uploadMetaString), fileChanger)
if err != nil {
return common.NewError("invalid_parameters",
"Invalid parameters. Error parsing the meta data for upload."+err.Error())
}
elapsedUnmarshal := time.Since(start) - elapsedReadForm

if fileChanger.Path == "/" {
return common.NewError("invalid_path", "Invalid path. Cannot upload to root directory")
Expand All @@ -76,7 +72,7 @@ func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request
logging.Logger.Error(err.Error())
return common.NewError("database_error", "Got db error while getting ref")
}
elapsedRefExist := time.Since(start) - elapsedUnmarshal - elapsedReadForm

if isExist {
msg := fmt.Sprintf("File at path :%s: already exists", fileChanger.Path)
return common.NewError("duplicate_file", msg)
Expand All @@ -100,7 +96,6 @@ func (cmd *UploadFileCommand) IsValidated(ctx context.Context, req *http.Request
}

cmd.fileChanger = fileChanger
logging.Logger.Info("isValidated", zap.Duration("elapsedReamForm", elapsedReadForm), zap.Duration("elapsedUnmarshal", elapsedUnmarshal), zap.Duration("elapsedRefExist", elapsedRefExist), zap.Duration("elapsed", time.Since(start)))
return nil
}

Expand Down

0 comments on commit 8fae5c8

Please sign in to comment.