Skip to content

Commit bc4cce9

Browse files
fix(size): create new message if size changes (#33)
* fix(size): create new message if size changes * Update readme * Prevent flaky test
1 parent 207420c commit bc4cce9

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ $ go install github.com/m-lab/msak/cmd/minimal-download@latest
7272
...
7373
# Local
7474
$ minimal-download -duration 1s -server.url ws://localhost:8080/throughput/v1/download
75-
Download server #1 - rate 34215.33 Mbps, rtt 0.04ms, elapsed 0.1009s, application r/w: 0/436207616, network r/w: 0/435163654 kernel* r/w: 538/431369776
76-
Download server #1 - rate 33915.22 Mbps, rtt 0.02ms, elapsed 0.2009s, application r/w: 0/856687767, network r/w: 0/855647819 kernel* r/w: 538/851814781
77-
Download server #1 - rate 34634.09 Mbps, rtt 0.04ms, elapsed 0.5741s, application r/w: 0/2489321624, network r/w: 0/2488297250 kernel* r/w: 538/2485238689
78-
Download server #1 - rate 34451.50 Mbps, rtt 0.04ms, elapsed 0.7029s, application r/w: 0/3031436447, network r/w: 0/3030417247 kernel* r/w: 538/3026848582
79-
Download server #1 - rate 34387.62 Mbps, rtt 0.03ms, elapsed 1.0008s, application r/w: 0/4304408743, network r/w: 0/4304450273 kernel* r/w: 538/4301737109
80-
Download client #1 - Avg 34353.74 Mbps, MinRTT 0.00ms, elapsed 1.0024s, application r/w: 0/4304409778
75+
minimal-download -duration 1s -server.url ws://localhost:8080/throughput/v1/download
76+
Download server #1 - rate 35260.80 Mbps, rtt 0.03ms, elapsed 0.2076s, application r/w: 0/918552576, network r/w: 0/917513214 kernel* r/w: 538/914903145
77+
Download server #1 - rate 34191.58 Mbps, rtt 0.03ms, elapsed 0.5168s, application r/w: 0/2213545117, network r/w: 0/2212518109 kernel* r/w: 538/2208912708
78+
Download server #1 - rate 33703.03 Mbps, rtt 0.05ms, elapsed 0.9170s, application r/w: 0/3868199075, network r/w: 0/3867187851 kernel* r/w: 538/3863293895
79+
Download server #1 - rate 33591.42 Mbps, rtt 0.03ms, elapsed 1.0005s, application r/w: 0/4203744426, network r/w: 0/4203784992 kernel* r/w: 538/4200858760
80+
Download client #1 - Avg 33552.56 Mbps, MinRTT 0.00ms, elapsed 1.0023s, application r/w: 0/4203745461
8181

8282
# Remote with time limit.
8383
$ minimal-download -duration 1s
@@ -92,7 +92,7 @@ Download client #1 - Avg 502.43 Mbps, MinRTT 4.11ms, elapsed 1.0520s, applicati
9292
# Remote with bytes limit.
9393
$ minimal-download -bytes=150000
9494
Download server #1 - rate 8.24 Mbps, rtt 12.17ms, elapsed 0.0128s, application r/w: 0/150000, network r/w: 0/164976 kernel* r/w: 1309/13146
95-
Download client #1 - Avg 30.51 Mbps, MinRTT 10.99ms, elapsed 0.0433s, application r/w: 0/164972
95+
Download client #1 - Avg 30.51 Mbps, MinRTT 10.99ms, elapsed 0.0433s, application r/w: 0/151008
9696
```
9797

9898
Every TCP connection has performance metrics accessible from the server end and

internal/latency1/latency1_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ func TestHandler_Result(t *testing.T) {
157157
rw.Result().StatusCode)
158158
}
159159

160+
// Delay return to allow handler go routines to settle.
161+
// TODO: add complete shutdown of handler to prevent flaky tests.
162+
time.Sleep(100 * time.Millisecond)
160163
}
161164

162165
func TestHandler_processPacket(t *testing.T) {

pkg/throughput1/protocol.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,20 @@ func (p *Protocol) sender(ctx context.Context, measurerCh <-chan model.Measureme
292292
return
293293
}
294294

295+
origSize := size
295296
// Determine whether it's time to scale the message size.
296297
if size >= spec.MaxScaledMessageSize || size > bytesSent/spec.ScalingFraction {
297298
size = p.ScaleMessage(size, bytesSent)
299+
} else {
300+
size = p.ScaleMessage(size*2, bytesSent)
301+
}
302+
303+
if size == origSize {
304+
// We do not need to create a new message.
298305
continue
299306
}
300307

301-
size = p.ScaleMessage(size*2, bytesSent)
308+
// Create a new message for the new size.
302309
message, err = p.makePreparedMessage(size)
303310
if err != nil {
304311
log.Printf("failed to make prepared message (ctx: %p, err: %v)", ctx, err)

0 commit comments

Comments
 (0)