Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Feb 12, 2024
1 parent 5e67aac commit 48cddf1
Show file tree
Hide file tree
Showing 3 changed files with 648 additions and 91 deletions.
2 changes: 1 addition & 1 deletion internal/minipipeline/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewLinearWebAnalysis(input *WebObservationsContainer) (output []*WebObserva
output = append(output, entry)
}

// sort in descending order
// sort using complex sorting rule
sort.SliceStable(output, func(i, j int) bool {
left, right := output[i], output[j]

Expand Down
46 changes: 37 additions & 9 deletions internal/minipipeline/sorting.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
// timing dependent churn when generating testcases for the minipipeline.
func SortDNSLookupResults(inputs []*model.ArchivalDNSLookupResult) (outputs []*model.ArchivalDNSLookupResult) {
// copy the original slice
outputs = append(outputs, inputs...)
outputs = append([]*model.ArchivalDNSLookupResult{}, inputs...)

// sort using complex sorting rule
sort.SliceStable(outputs, func(i, j int) bool {
left, right := outputs[i], outputs[j]

// we sort groups by resolver type to avoid the churn caused by parallel runs.
// we sort groups by resolver type to avoid the churn caused by parallel runs
if left.Engine < right.Engine {
return true
}
Expand Down Expand Up @@ -48,20 +48,30 @@ func SortDNSLookupResults(inputs []*model.ArchivalDNSLookupResult) (outputs []*m
// SortNetworkEvents is like [SortDNSLookupResults] but for network events.
func SortNetworkEvents(inputs []*model.ArchivalNetworkEvent) (outputs []*model.ArchivalNetworkEvent) {
// copy the original slice
outputs = append(outputs, inputs...)
outputs = append([]*model.ArchivalNetworkEvent{}, inputs...)

// sort using complex sorting rule
sort.SliceStable(outputs, func(i, j int) bool {
left, right := outputs[i], outputs[j]

// we sort by endpoint address to significantly reduce the churn
if left.Address < right.Address {
return true
}
if left.Address > right.Address {
return false
}

return left.TransactionID < right.TransactionID
// if the address is the same, then we group by transaction
if left.TransactionID < right.TransactionID {
return true
}
if left.TransactionID > right.TransactionID {
return false
}

// with same transaction, we sort by increasing time
return left.T < right.T
})

return
Expand All @@ -71,27 +81,36 @@ func SortNetworkEvents(inputs []*model.ArchivalNetworkEvent) (outputs []*model.A
func SortTCPConnectResults(
inputs []*model.ArchivalTCPConnectResult) (outputs []*model.ArchivalTCPConnectResult) {
// copy the original slice
outputs = append(outputs, inputs...)
outputs = append([]*model.ArchivalTCPConnectResult{}, inputs...)

// sort using complex sorting rule
sort.SliceStable(outputs, func(i, j int) bool {
left, right := outputs[i], outputs[j]

// we sort by endpoint address to significantly reduce the churn
if left.IP < right.IP {
return true
}
if left.IP > right.IP {
return false
}

if left.Port < right.Port {
return true
}
if left.Port > right.Port {
return false
}

return left.TransactionID < right.TransactionID
// if the address is the same, then we group by transaction
if left.TransactionID < right.TransactionID {
return true
}
if left.TransactionID > right.TransactionID {
return false
}

// with same transaction, we sort by increasing time
return left.T < right.T
})

return
Expand All @@ -101,7 +120,7 @@ func SortTCPConnectResults(
func SortTLSHandshakeResults(
inputs []*model.ArchivalTLSOrQUICHandshakeResult) (outputs []*model.ArchivalTLSOrQUICHandshakeResult) {
// copy the original slice
outputs = append(outputs, inputs...)
outputs = append([]*model.ArchivalTLSOrQUICHandshakeResult{}, inputs...)

// sort using complex sorting rule
sort.SliceStable(outputs, func(i, j int) bool {
Expand All @@ -114,7 +133,16 @@ func SortTLSHandshakeResults(
return false
}

return left.TransactionID < right.TransactionID
// if the address is the same, then we group by transaction
if left.TransactionID < right.TransactionID {
return true
}
if left.TransactionID > right.TransactionID {
return false
}

// with same transaction, we sort by increasing time
return left.T < right.T
})

return
Expand Down
Loading

0 comments on commit 48cddf1

Please sign in to comment.