aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2020-04-30 20:16:42 -0700
committerGitHub <noreply@github.com>2020-04-30 20:16:42 -0700
commit78422c2f694c124da13c6289ad3ce8c31d33e38a (patch)
tree603f8448091a2f20eb1d25523828580506f45a6e
parent871efa4fc15822d518f1bcc952ebf4d80fb0defd (diff)
parentd819865fe7036ec64a28d896aca61ba8b3a39d02 (diff)
downloadseaweedfs-78422c2f694c124da13c6289ad3ce8c31d33e38a.tar.xz
seaweedfs-78422c2f694c124da13c6289ad3ce8c31d33e38a.zip
Merge pull request #1298 from song-zhang/master
add fsync option for benchmark
-rw-r--r--weed/command/benchmark.go3
-rw-r--r--weed/operation/submit.go4
2 files changed, 7 insertions, 0 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go
index a73a4e81c..5b2e31622 100644
--- a/weed/command/benchmark.go
+++ b/weed/command/benchmark.go
@@ -42,6 +42,7 @@ type BenchmarkOptions struct {
grpcDialOption grpc.DialOption
masterClient *wdclient.MasterClient
grpcRead *bool
+ fsync *bool
}
var (
@@ -67,6 +68,7 @@ func init() {
b.cpuprofile = cmdBenchmark.Flag.String("cpuprofile", "", "cpu profile output file")
b.maxCpu = cmdBenchmark.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
b.grpcRead = cmdBenchmark.Flag.Bool("grpcRead", false, "use grpc API to read")
+ b.fsync = cmdBenchmark.Flag.Bool("fsync", false, "flush data to disk after write")
sharedBytes = make([]byte, 1024)
}
@@ -230,6 +232,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
Reader: &FakeReader{id: uint64(id), size: fileSize, random: random},
FileSize: fileSize,
MimeType: "image/bench", // prevent gzip benchmark content
+ Fsync: *b.fsync,
}
ar := &operation.VolumeAssignRequest{
Count: 1,
diff --git a/weed/operation/submit.go b/weed/operation/submit.go
index d1c4706ce..7cf5b9645 100644
--- a/weed/operation/submit.go
+++ b/weed/operation/submit.go
@@ -27,6 +27,7 @@ type FilePart struct {
Ttl string
Server string //this comes from assign result
Fid string //this comes from assign result, but customizable
+ Fsync bool
}
type SubmitResult struct {
@@ -116,6 +117,9 @@ func (fi FilePart) Upload(maxMB int, master string, usePublicUrl bool, jwt secur
if fi.ModTime != 0 {
fileUrl += "?ts=" + strconv.Itoa(int(fi.ModTime))
}
+ if fi.Fsync {
+ fileUrl += "?fsync=true"
+ }
if closer, ok := fi.Reader.(io.Closer); ok {
defer closer.Close()
}