Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions pkg/coordinator/tasks/tx_pool_latency_analysis/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"encoding/json"
"fmt"
"github.com/noku-team/assertoor/pkg/coordinator/utils/tx_load_tool"
"math"
"math/rand"
"os"
"time"

"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -151,16 +153,17 @@ func (t *Task) Execute(ctx context.Context) error {

// Calculate statistics
var maxLatency int64 = 0
var minLatency int64 = 0
var minLatency int64 = math.MaxInt64
for _, lat := range result.LatenciesMus {
if lat > maxLatency {
maxLatency = lat
}
if lat < minLatency {
if lat < minLatency && lat > 0 {
minLatency = lat
}
}
t.logger.Infof("Max latency: %d mus, Min latency: %d mus", maxLatency, minLatency)
t.logger.Infof("Max latency: %d mus (%d ms), Min latency: %d mus (%d ms)",
maxLatency, maxLatency/1000, minLatency, minLatency/1000)

// Generate HDR plot
plot, err := hdr.HdrPlot(result.LatenciesMus)
Expand All @@ -169,13 +172,23 @@ func (t *Task) Execute(ctx context.Context) error {
t.ctx.SetResult(types.TaskResultFailure)
return nil
}
t.logger.Infof("HDR plot generated successfully")
plotFilePath := "tx_pool_latency_hdr_plot.csv"
err = os.WriteFile(plotFilePath, []byte(plot), 0644)
if err != nil {
t.logger.Errorf("Failed to write HDR plot to file: %v", err)
t.ctx.SetResult(types.TaskResultFailure)
return nil
}
t.logger.Infof("HDR plot saved to file: %s", plotFilePath)

t.ctx.Outputs.SetVar("tx_count", result.TotalTxs)
t.ctx.Outputs.SetVar("min_latency_mus", minLatency)
t.ctx.Outputs.SetVar("max_latency_mus", maxLatency)
t.ctx.Outputs.SetVar("duplicated_p2p_event_count", result.DuplicatedP2PEventCount)
t.ctx.Outputs.SetVar("missed_p2p_event_count", result.NotReceivedP2PEventCount)
t.ctx.Outputs.SetVar("coordinated_omission_event_count", result.CoordinatedOmissionEventCount)
t.ctx.Outputs.SetVar("hdr_plot", plot)

t.ctx.SetResult(types.TaskResultSuccess)

Expand Down
28 changes: 14 additions & 14 deletions pkg/coordinator/utils/tx_load_tool/tx_load_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ func NewLoadResult(totNumberOfTxes int) *LoadResult {
}

type Load struct {
target *LoadTarget
testDeadline time.Time
TPS int
Duration_s int
LogInterval int
Result *LoadResult
target *LoadTarget
testDeadline time.Time
TPS int
Duration_s int
LogInterval int
Result *LoadResult
}

// NewLoad creates a new Load instance
func NewLoad(target *LoadTarget, TPS int, duration_s int, testDeadline time.Time, logInterval int) *Load {
return &Load{
target: target,
TPS: TPS,
Duration_s: duration_s,
testDeadline: testDeadline,
LogInterval: logInterval,
Result: NewLoadResult(TPS * duration_s),
target: target,
TPS: TPS,
Duration_s: duration_s,
testDeadline: testDeadline,
LogInterval: logInterval,
Result: NewLoadResult(TPS * duration_s),
}
}

Expand Down Expand Up @@ -288,11 +288,11 @@ func (l *Load) MeasurePropagationLatencies() (*LoadResult, error) {
if l.Result.LatenciesMus[i] == 0 {
l.Result.NotReceivedP2PEventCount++
// Assign a default value for missing P2P events
l.Result.LatenciesMus[i] = (time.Duration(l.Duration_s) * time.Second).Microseconds()
l.Result.LatenciesMus[i] = -1
}
}
if l.Result.NotReceivedP2PEventCount > 0 {
l.target.logger.Warnf("Missed p2p events: %d (assigned latency=duration)", l.Result.NotReceivedP2PEventCount)
l.target.logger.Warnf("Missed p2p events: %d", l.Result.NotReceivedP2PEventCount)
}

return l.Result, nil
Expand Down
Loading