Skip to content

Commit

Permalink
feat(perf): continuosly measure on single conn (iperf-style)
Browse files Browse the repository at this point in the history
Our current throughput tests open a connection, open a stream,
up- or download 100MB and close the connection. 100 MB is not enough on the
given path (60ms, ~5gbit/s) to exit congestion controller's slow-start. See
#261 for details.

Instead of downloading 100MB multiple times, each on a new connection, establish
a single connection and continuously measure the throughput for a fixed
duration (60s).
  • Loading branch information
mxinden committed Aug 24, 2023
1 parent 8bf6d03 commit ad823e1
Show file tree
Hide file tree
Showing 7 changed files with 751 additions and 4,456 deletions.
15 changes: 3 additions & 12 deletions perf/impl/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
GO_SUBDIRS := $(wildcard go-libp2p/*/.)
RUST_SUBDIRS := $(wildcard rust-libp2p/*/.)
RUST_QUINN_SUBDIRS := $(wildcard rust-libp2p-quinn/*/.)
HTTPS_SUBDIRS := $(wildcard https/*/.)
QUIC_GO_SUBDIRS := $(wildcard quic-go/*/.)

all: $(RUST_SUBDIRS) $(RUST_QUINN_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS)
all: $(RUST_SUBDIRS) $(HTTPS_SUBDIRS)
$(RUST_SUBDIRS):
$(MAKE) -C $@
$(RUST_QUINN_SUBDIRS):
$(MAKE) -C $@
$(GO_SUBDIRS):
$(MAKE) -C $@
$(HTTPS_SUBDIRS):
$(MAKE) -C $@
$(QUIC_GO_SUBDIRS):
$(MAKE) -C $@

clean: $(RUST_SUBDIRS:%=%clean) $(RUST_QUINN_SUBDIRS:%=%clean) $(GO_SUBDIRS:%=%clean) $(HTTPS_SUBDIRS:%=%clean) $(QUIC_GO_SUBDIRS:%=%clean)
clean: $(RUST_SUBDIRS:%=%clean) $(HTTPS_SUBDIRS:%=%clean)

%clean:
$(MAKE) -C $* clean

.PHONY: $(RUST_SUBDIRS) $(RUST_QUINN_SUBDIRS) $(GO_SUBDIRS) $(HTTPS_SUBDIRS) $(QUIC_GO_SUBDIRS) all clean
.PHONY: $(RUST_SUBDIRS) $(HTTPS_SUBDIRS)
32 changes: 29 additions & 3 deletions perf/impl/https/v0.1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,41 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
type nullReader struct {
N uint64
read uint64
LastReportTime time.Time
lastReportRead uint64
}

var _ io.Reader = &nullReader{}

func (r *nullReader) Read(b []byte) (int, error) {
if time.Since(r.LastReportTime) > time.Second {
// TODO
jsonB, err := json.Marshal(Result{
TimeSeconds: time.Since(r.LastReportTime).Seconds(),
UploadBytes: uint(r.lastReportRead),
Type: "intermediary",
})
if err != nil {
log.Fatalf("failed to marshal perf result: %s", err)
}
fmt.Println(string(jsonB))

r.LastReportTime = time.Now()
r.lastReportRead = 0
}

remaining := r.N - r.read
l := uint64(len(b))
if uint64(len(b)) > remaining {
l = remaining
}
r.read += l
r.lastReportRead += l

if r.read == r.N {
return int(l), io.EOF
}

return int(l), nil
}

Expand All @@ -84,7 +105,7 @@ func runClient(serverAddr string, uploadBytes, downloadBytes uint64) (time.Durat
fmt.Sprintf("https://%s/", serverAddr),
io.MultiReader(
bytes.NewReader(b),
&nullReader{N: uploadBytes},
&nullReader{N: uploadBytes, LastReportTime: time.Now()},
),
)
if err != nil {
Expand Down Expand Up @@ -167,7 +188,10 @@ func generateEphemeralCertificate() (tls.Certificate, error) {
}

type Result struct {
Latency float64 `json:"latency"`
Type string `json:"type"`
TimeSeconds float64 `json:"timeSeconds"`
UploadBytes uint `json:"uploadBytes"`
DownloadBytes uint `json:"downloadBytes"`
}

func main() {
Expand Down Expand Up @@ -219,8 +243,10 @@ func main() {
log.Fatal(err)
}

// TODO
jsonB, err := json.Marshal(Result{
Latency: latency.Seconds(),
TimeSeconds: latency.Seconds(),
Type: "final",
})
if err != nil {
log.Fatalf("failed to marshal perf result: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion perf/impl/rust-libp2p/v0.52/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
commitSha := 73dbde1519f71aa8d76f4c5fa018860ddcd2a8ea
commitSha := 9788b53bad52a2b0831b13c1c38e3523659a66af

all: perf

Expand Down
Loading

0 comments on commit ad823e1

Please sign in to comment.