Skip to content

Commit

Permalink
Drop support of old versions of reports
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Nov 14, 2023
1 parent 6a17bc1 commit 9abe623
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 124 deletions.
2 changes: 1 addition & 1 deletion pkg/analyzer/InsertReportManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (t *InsertReportManager) WriteMetrics(product string, row *RunResult, branc
args = append(args, product)
}
if t.config.HasInstallerField {
buildTimeUnix, err := getBuildTimeFromReport(row.Report, t.config.DbName)
buildTimeUnix, err := getBuildTimeFromReport(row.Report)
if err != nil {
return err
}
Expand Down
18 changes: 0 additions & 18 deletions pkg/analyzer/fleetReport.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package analyzer

import (
"github.com/mcuadros/go-version"
"github.com/valyala/fastjson"
"go.uber.org/zap"
"math"
Expand Down Expand Up @@ -46,30 +45,13 @@ func analyzeFleetReport(runResult *RunResult, data *fastjson.Value, _ *zap.Logge
threads = append(threads, string(measure.GetStringBytes("t")))
}

mapNameV22 := version.Compare(runResult.Report.Version, "22", "<=")
isLessThan36 := version.Compare(runResult.Report.Version, "36", "<")

for _, groupField := range []string{"items", "prepareAppInitActivities"} {
for _, measure := range data.GetArray(groupField) {
name := string(measure.GetStringBytes("n"))
if len(name) == 0 {
continue
}

if mapNameV22 {
if name == "create window" {
name = "editor appeared"
} else if name == "render" {
name = "window appeared"
}
} else if isLessThan36 {
if name == "render editor" {
name = "editor appeared"
} else if name == "render real panels" {
name = "window appeared"
}
}

// in milliseconds
names = append(names, name)
values = append(values, int32(measure.GetInt("d")))
Expand Down
90 changes: 29 additions & 61 deletions pkg/analyzer/ijReport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package analyzer

import (
"github.com/JetBrains/ij-perf-report-aggregator/pkg/model"
"github.com/mcuadros/go-version"
"github.com/valyala/fastjson"
"go.uber.org/zap"
"sort"
Expand All @@ -25,7 +24,7 @@ func analyzeIjReport(runResult *RunResult, data *fastjson.Value, logger *zap.Log

traceEvents := data.GetArray("traceEvents")

if version.Compare(report.Version, "12", ">=") && len(traceEvents) == 0 {
if len(traceEvents) == 0 {
logger.Warn("invalid report (due to opening second project?), report will be skipped", zap.Int("id", runResult.TcBuildId), zap.String("generated", report.Generated))
runResult.Report = nil
return nil
Expand All @@ -52,55 +51,39 @@ func analyzeIjReport(runResult *RunResult, data *fastjson.Value, logger *zap.Log

measures := make([]measureItem, 0)

if version.Compare(report.Version, "20", ">=") {
if version.Compare(report.Version, "32", ">=") {
report.Activities = readActivities("items", data)

for _, activity := range report.Activities {
measures = append(measures, measureItem{
name: activity.Name,
start: uint32(activity.Start),
duration: uint32(activity.Duration),
thread: activity.Thread,
})
}
} else {
report.Activities = readActivitiesInOldFormat("items", data)
report.PrepareAppInitActivities = readActivities("prepareAppInitActivities", data)
}

if version.Compare(report.Version, "27", ">=") {
classLoading := data.Get("classLoading")
resourceLoading := data.Get("resourceLoading")
if classLoading != nil && resourceLoading != nil {
clTotal = int32(classLoading.GetInt("time"))
clSearch = int32(classLoading.GetInt("searchTime"))
clDefine = int32(classLoading.GetInt("defineTime"))
clCount = int32(classLoading.GetInt("count"))

if version.Compare(report.Version, "38", ">=") {
clPreparedCount = int32(classLoading.GetInt("preparedCount"))
clLoadedCount = int32(classLoading.GetInt("loadedCount"))
}

rlTime = int32(resourceLoading.GetInt("time"))
rlCount = int32(resourceLoading.GetInt("count"))
}
}
} else {
report.Activities = readActivitiesInOldFormat("items", data)
report.PrepareAppInitActivities = readActivitiesInOldFormat("prepareAppInitActivities", data)
}
report.Activities = readActivities("items", data)

if version.Compare(report.Version, "37", ">=") {
for _, activity := range report.Activities {
measures = append(measures, measureItem{
name: "elementTypeCount",
start: 0,
duration: uint32(data.GetInt("langLoading", "elementTypeCount")),
thread: "",
name: activity.Name,
start: uint32(activity.Start),
duration: uint32(activity.Duration),
thread: activity.Thread,
})
}

classLoading := data.Get("classLoading")
resourceLoading := data.Get("resourceLoading")
if classLoading != nil && resourceLoading != nil {
clTotal = int32(classLoading.GetInt("time"))
clSearch = int32(classLoading.GetInt("searchTime"))
clDefine = int32(classLoading.GetInt("defineTime"))
clCount = int32(classLoading.GetInt("count"))

clPreparedCount = int32(classLoading.GetInt("preparedCount"))
clLoadedCount = int32(classLoading.GetInt("loadedCount"))

rlTime = int32(resourceLoading.GetInt("time"))
rlCount = int32(resourceLoading.GetInt("count"))
}

measures = append(measures, measureItem{
name: "elementTypeCount",
start: 0,
duration: uint32(data.GetInt("langLoading", "elementTypeCount")),
thread: "",
})

// Sort for better compression (same data pattern across column values). It is confirmed by experiment.
sort.Slice(measures, func(i, j int) bool {
return measures[i].name < measures[j].name
Expand Down Expand Up @@ -142,21 +125,6 @@ func analyzeIjReport(runResult *RunResult, data *fastjson.Value, logger *zap.Log
return nil
}

func readActivitiesInOldFormat(key string, data *fastjson.Value) []model.Activity {
array := data.GetArray(key)
result := make([]model.Activity, 0, len(array))
for _, v := range array {
result = append(result, model.Activity{
Name: string(v.GetStringBytes("name")),
Thread: string(v.GetStringBytes("thread")),
Start: v.GetInt("start"),
End: v.GetInt("end"),
Duration: v.GetInt("duration"),
})
}
return result
}

func readActivities(key string, value *fastjson.Value) []model.Activity {
array := value.GetArray(key)
result := make([]model.Activity, 0, len(array))
Expand Down
44 changes: 10 additions & 34 deletions pkg/analyzer/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ func init() {
return result
}

// createVersionedMetric := func(name string, sinceVersion string) *Metric {
// result := createMetric(name)
// result.sinceVersion = sinceVersion
// return result
//}

createVersionedUint16Metric := func(name string, sinceVersion string) *Metric {
result := createMetric(name)
result.sinceVersion = sinceVersion
Expand Down Expand Up @@ -179,40 +173,24 @@ func ComputeIjMetrics(nonMetricFieldCount int, report *model.Report, result *[]i
}
}

switch {
case version.Compare(report.Version, "32", ">="):
// part of report.Activities
case version.Compare(report.Version, "18", ">="):
for _, activity := range report.PrepareAppInitActivities {
for _, activity := range report.PrepareAppInitActivities {
switch activity.Name {
case "plugin descriptors loading":
(*result)[nonMetricFieldCount+metricNameToDescriptor["plugin descriptor loading"].index] = uint16(activity.Duration)
default:
err := setMetric(nonMetricFieldCount, activity, report, result)
if err != nil {
return err
}
}
default:
for _, activity := range report.PrepareAppInitActivities {
switch activity.Name {
case "plugin descriptors loading":
(*result)[nonMetricFieldCount+metricNameToDescriptor["plugin descriptor loading"].index] = uint16(activity.Duration)
default:
err := setMetric(nonMetricFieldCount, activity, report, result)
if err != nil {
return err
}
}
}
}

if version.Compare(report.Version, "11", ">=") {
for _, activity := range report.TraceEvents {
if activity.Phase == "i" && (activity.Name == "splash" || activity.Name == "splash shown") {
(*result)[nonMetricFieldCount+metricNameToDescriptor["splash initialization"].index] = int32(activity.Timestamp / 1000)
}
for _, activity := range report.TraceEvents {
if activity.Phase == "i" && (activity.Name == "splash" || activity.Name == "splash shown") {
(*result)[nonMetricFieldCount+metricNameToDescriptor["splash initialization"].index] = int32(activity.Timestamp / 1000)
}
}

is14orGreater := version.Compare(report.Version, "14", ">=")

var notFoundMetrics []string
for _, metric := range IjMetricDescriptors {
if (*result)[nonMetricFieldCount+metric.index] != -1 {
Expand All @@ -228,10 +206,8 @@ func ComputeIjMetrics(nonMetricFieldCount int, report *model.Report, result *[]i

// undefined
(*result)[nonMetricFieldCount+metric.index] = 0
if is14orGreater || (metric.Name != "editorRestoringTillPaint" && metric.Name != "projectProfileLoading_d") {
if len(metric.sinceVersion) != 0 && version.Compare(report.Version, metric.sinceVersion, ">=") {
notFoundMetrics = append(notFoundMetrics, metric.Name)
}
if len(metric.sinceVersion) != 0 && version.Compare(report.Version, metric.sinceVersion, ">=") {
notFoundMetrics = append(notFoundMetrics, metric.Name)
}
}

Expand Down
15 changes: 5 additions & 10 deletions pkg/analyzer/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package analyzer
import (
"github.com/JetBrains/ij-perf-report-aggregator/pkg/model"
"github.com/develar/errors"
"github.com/mcuadros/go-version"
"github.com/valyala/fastjson"
"go.uber.org/zap"
"time"
Expand Down Expand Up @@ -54,17 +53,13 @@ func ReadReport(runResult *RunResult, config DatabaseConfiguration, logger *zap.
return nil
}

func getBuildTimeFromReport(report *model.Report, dbName string) (time.Time, error) {
func getBuildTimeFromReport(report *model.Report) (time.Time, error) {
var buildTimeUnix time.Time
if dbName != "ij" || version.Compare(report.Version, "13", ">=") {
buildTime, err := ParseTime(report.BuildDate)
if err != nil {
return time.Time{}, err
}
buildTimeUnix = buildTime
} else {
buildTimeUnix = time.Time{}
buildTime, err := ParseTime(report.BuildDate)
if err != nil {
return time.Time{}, err
}
buildTimeUnix = buildTime
return buildTimeUnix, nil
}

Expand Down

0 comments on commit 9abe623

Please sign in to comment.