Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smoke: add image conversion time in benchmark #1508

Merged
merged 2 commits into from
Dec 8, 2023
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
10 changes: 5 additions & 5 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,16 @@ jobs:
esac
cd benchmark-result
metric_files=(
"${{ matrix.image }}-oci.json"
"${{ matrix.image }}-fsversion-v5.json"
"${{ matrix.image }}-fsversion-v6.json"
"${{ matrix.image }}-zran.json"
"${{ matrix.image }}-oci.json"
)
echo "| bench-result | e2e-time(s) | read-count | read-amount(MB) | image-size(MB) |" >> $GITHUB_STEP_SUMMARY
echo "|:-------------|:----------:|:----------:|:---------------:|:--------:|" >> $GITHUB_STEP_SUMMARY
echo "| bench-result | e2e-time(s) | read-count | read-amount(MB) | image-size(MB) |convert-time(s)|" >> $GITHUB_STEP_SUMMARY
echo "|:-------------|:-----------:|:----------:|:---------------:|:--------------:|:-------------:|" >> $GITHUB_STEP_SUMMARY
for file in "${metric_files[@]}"; do
name=$(basename "$file" .json | sed 's/^[^-]*-\(.*\)$/\1/')
data=$(jq -r '. | "\(.e2e_time / 1e9) \(.read_count) \(.read_amount_total / (1024 * 1024)) \(.image_size / (1024 * 1024))"' "$file" | \
awk '{ printf "%.2f | %.0f | %.2f | %.2f", $1, $2, $3, $4 }')
data=$(jq -r '. | "\(.e2e_time / 1e9) \(.read_count) \(.read_amount_total / (1024 * 1024)) \(.image_size / (1024 * 1024)) \(.conversion_elapsed / 1e9)"' "$file" | \
awk '{ printf "%.2f | %.0f | %.2f | %.2f | %.2f", $1, $2, $3, $4, $5 }')
echo "| $name | $data |" >> $GITHUB_STEP_SUMMARY
done
26 changes: 14 additions & 12 deletions smoke/tests/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"testing"
"time"

"github.com/dragonflyoss/image-service/smoke/tests/tool"
"github.com/dragonflyoss/image-service/smoke/tests/tool/test"
Expand Down Expand Up @@ -67,26 +68,27 @@ func (b *BenchmarkTestSuite) TestBenchmark(t *testing.T) {
b.t.Fatalf("Benchmark don't support image " + image)
}
}
targetImageSize := b.prepareImage(b.t, ctx, mode, image)
targetImageSize, conversionElapsed := b.prepareImage(b.t, ctx, mode, image)

// run contaienr
b.testContainerName = uuid.NewString()
containerMetic := tool.RunContainer(b.t, b.testImage, b.snapshotter, b.testContainerName)
b.metric = tool.ContainerMetrics{
E2ETime: containerMetic.E2ETime,
ReadCount: containerMetic.ReadCount,
ReadAmountTotal: containerMetic.ReadAmountTotal,
ImageSize: targetImageSize,
E2ETime: containerMetic.E2ETime,
ConversionElapsed: time.Duration(conversionElapsed),
ReadCount: containerMetic.ReadCount,
ReadAmountTotal: containerMetic.ReadAmountTotal,
ImageSize: targetImageSize,
}

// save metirc
b.dumpMetric()
t.Logf(fmt.Sprintf("Metric: ReadAmount %d ReadCount %d Runtime %d ImageSize %d", b.metric.ReadAmountTotal, b.metric.ReadCount, b.metric.E2ETime, b.metric.ImageSize))
t.Logf(fmt.Sprintf("Metric: E2ETime %d ConversionElapsed %s ReadCount %d ReadAmount %d ImageSize %d", b.metric.E2ETime, b.metric.ConversionElapsed, b.metric.ReadCount, b.metric.ReadAmountTotal, b.metric.ImageSize))
}

func (b *BenchmarkTestSuite) prepareImage(t *testing.T, ctx *tool.Context, mode string, image string) int64 {
func (b *BenchmarkTestSuite) prepareImage(t *testing.T, ctx *tool.Context, mode string, image string) (int64, int64) {
if b.testImage != "" {
return 0
return 0, 0
}

ctx.PrepareWorkDir(t)
Expand Down Expand Up @@ -116,20 +118,20 @@ func (b *BenchmarkTestSuite) prepareImage(t *testing.T, ctx *tool.Context, mode
metricData, err := os.ReadFile(convertMetricFile)
if err != nil {
t.Fatalf("can't read convert metric file")
return 0
return 0, 0
}
var convertMetirc map[string]int64
err = json.Unmarshal(metricData, &convertMetirc)
if err != nil {
t.Fatalf("can't parsing convert metric file")
return 0
return 0, 0
}
if b.snapshotter == "nydus" {
b.testImage = target
return convertMetirc["TargetImageSize"]
return convertMetirc["TargetImageSize"], convertMetirc["ConversionElapsed"]
} else {
b.testImage = source
return convertMetirc["SourceImageSize"]
return convertMetirc["SourceImageSize"], 0
}
}

Expand Down
9 changes: 5 additions & 4 deletions smoke/tests/tool/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
)

type ContainerMetrics struct {
E2ETime time.Duration `json:"e2e_time"`
ReadCount uint64 `json:"read_count"`
ReadAmountTotal uint64 `json:"read_amount_total"`
ImageSize int64 `json:"image_size"`
E2ETime time.Duration `json:"e2e_time"`
ConversionElapsed time.Duration `json:"conversion_elapsed"`
ReadCount uint64 `json:"read_count"`
ReadAmountTotal uint64 `json:"read_amount_total"`
ImageSize int64 `json:"image_size"`
}

type RunArgs struct {
Expand Down