Skip to content

Commit

Permalink
app/appengine: delete more dead code
Browse files Browse the repository at this point in the history
This is part of a series of CLs to clean up the build.golang.org App
Engine app in prep for it to be modernized, refactored, and replaced,
starting with deleting dead code.

Updates golang/go#34744

Change-Id: I6cddbb44a63597a308f1d4399d21e5b70a8d83bf
Reviewed-on: https://go-review.googlesource.com/c/build/+/208324
Reviewed-by: Andrew Gerrand <[email protected]>
  • Loading branch information
bradfitz committed Nov 21, 2019
1 parent f2aa121 commit 1380f86
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 865 deletions.
2 changes: 1 addition & 1 deletion app/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ handlers:
- url: /static
static_dir: app/appengine/static
secure: always
- url: /(init|buildtest)
- url: /init
script: auto
login: admin
secure: always
Expand Down
137 changes: 0 additions & 137 deletions app/appengine/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"io"
"io/ioutil"
"strconv"
"strings"
"time"

Expand All @@ -23,7 +22,6 @@ import (

const (
maxDatastoreStringLen = 500
PerfRunLength = 1024
)

// A Package describes a package that is listed on the dashboard.
Expand Down Expand Up @@ -101,12 +99,6 @@ type Commit struct {
// The complete data set is stored in Result entities.
ResultData []string `datastore:",noindex"`

// PerfResults holds a set of “builder|benchmark” tuples denoting
// what benchmarks have been executed on the commit.
PerfResults []string `datastore:",noindex"`

FailNotificationSent bool

buildingURLs map[builderAndGoHash]string
}

Expand Down Expand Up @@ -183,25 +175,6 @@ func (com *Commit) RemoveResult(r *Result) {
com.ResultData = rd
}

// AddPerfResult remembers that the builder has run the benchmark on the commit.
// It must be called from inside a datastore transaction.
func (com *Commit) AddPerfResult(c context.Context, builder, benchmark string) error {
if err := datastore.Get(c, com.Key(c), com); err != nil {
return fmt.Errorf("getting Commit: %v", err)
}
if !com.NeedsBenchmarking {
return fmt.Errorf("trying to add perf result to Commit(%v) that does not require benchmarking", com.Hash)
}
s := builder + "|" + benchmark
for _, v := range com.PerfResults {
if v == s {
return nil
}
}
com.PerfResults = append(com.PerfResults, s)
return putCommit(c, com)
}

func trim(s []string, n int) []string {
l := min(len(s), n)
return s[len(s)-l:]
Expand Down Expand Up @@ -314,116 +287,6 @@ func reverse(s []string) {
}
}

// A CommitRun provides summary information for commits [StartCommitNum, StartCommitNum + PerfRunLength).
// Descendant of Package.
type CommitRun struct {
PackagePath string // (empty for main repo commits)
StartCommitNum int
Hash []string `datastore:",noindex"`
User []string `datastore:",noindex"`
Desc []string `datastore:",noindex"` // Only first line.
Time []time.Time `datastore:",noindex"`
NeedsBenchmarking []bool `datastore:",noindex"`
}

func (cr *CommitRun) Key(c context.Context) *datastore.Key {
p := Package{Path: cr.PackagePath}
key := strconv.Itoa(cr.StartCommitNum)
return datastore.NewKey(c, "CommitRun", key, 0, p.Key(c))
}

// GetCommitRun loads and returns CommitRun that contains information
// for commit commitNum.
func GetCommitRun(c context.Context, commitNum int) (*CommitRun, error) {
cr := &CommitRun{StartCommitNum: commitNum / PerfRunLength * PerfRunLength}
err := datastore.Get(c, cr.Key(c), cr)
if err != nil && err != datastore.ErrNoSuchEntity {
return nil, fmt.Errorf("getting CommitRun: %v", err)
}
if len(cr.Hash) != PerfRunLength {
cr.Hash = make([]string, PerfRunLength)
cr.User = make([]string, PerfRunLength)
cr.Desc = make([]string, PerfRunLength)
cr.Time = make([]time.Time, PerfRunLength)
cr.NeedsBenchmarking = make([]bool, PerfRunLength)
}
return cr, nil
}

func (cr *CommitRun) AddCommit(c context.Context, com *Commit) error {
if com.Num < cr.StartCommitNum || com.Num >= cr.StartCommitNum+PerfRunLength {
return fmt.Errorf("AddCommit: commit num %v out of range [%v, %v)",
com.Num, cr.StartCommitNum, cr.StartCommitNum+PerfRunLength)
}
i := com.Num - cr.StartCommitNum
// Be careful with string lengths,
// we need to fit 1024 commits into 1 MB.
cr.Hash[i] = com.Hash
cr.User[i] = shortDesc(com.User)
cr.Desc[i] = shortDesc(com.Desc)
cr.Time[i] = com.Time
cr.NeedsBenchmarking[i] = com.NeedsBenchmarking
if _, err := datastore.Put(c, cr.Key(c), cr); err != nil {
return fmt.Errorf("putting CommitRun: %v", err)
}
return nil
}

// GetCommits returns [startCommitNum, startCommitNum+n) commits.
// Commits information is partial (obtained from CommitRun),
// do not store them back into datastore.
func GetCommits(c context.Context, startCommitNum, n int) ([]*Commit, error) {
if startCommitNum < 0 || n <= 0 {
return nil, fmt.Errorf("GetCommits: invalid args (%v, %v)", startCommitNum, n)
}

p := &Package{}
t := datastore.NewQuery("CommitRun").
Ancestor(p.Key(c)).
Filter("StartCommitNum >=", startCommitNum/PerfRunLength*PerfRunLength).
Order("StartCommitNum").
Limit(100).
Run(c)

res := make([]*Commit, n)
for {
cr := new(CommitRun)
_, err := t.Next(cr)
if err == datastore.Done {
break
}
if err != nil {
return nil, err
}
if cr.StartCommitNum >= startCommitNum+n {
break
}
// Calculate start index for copying.
i := 0
if cr.StartCommitNum < startCommitNum {
i = startCommitNum - cr.StartCommitNum
}
// Calculate end index for copying.
e := PerfRunLength
if cr.StartCommitNum+e > startCommitNum+n {
e = startCommitNum + n - cr.StartCommitNum
}
for ; i < e; i++ {
com := new(Commit)
com.Hash = cr.Hash[i]
com.User = cr.User[i]
com.Desc = cr.Desc[i]
com.Time = cr.Time[i]
com.NeedsBenchmarking = cr.NeedsBenchmarking[i]
res[cr.StartCommitNum-startCommitNum+i] = com
}
if e != PerfRunLength {
break
}
}
return res, nil
}

// partsToResult converts a Commit and ResultData substrings to a Result.
func partsToResult(c *Commit, p []string) *Result {
return &Result{
Expand Down
93 changes: 0 additions & 93 deletions app/appengine/config.go

This file was deleted.

12 changes: 5 additions & 7 deletions app/appengine/dash.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ func main() {
handleFunc("/packages", AuthHandler(packagesHandler))
handleFunc("/result", AuthHandler(resultHandler))
handleFunc("/tag", AuthHandler(tagHandler))
handleFunc("/todo", AuthHandler(todoHandler))

// public handlers
handleFunc("/", uiHandler)
handleFunc("/log/", logHandler)
handleFunc("/updatebenchmark", updateBenchmark)
handleFunc("/buildtest", testHandler)

appengine.Main()
}
Expand All @@ -48,10 +45,12 @@ func hstsHandler(fn http.HandlerFunc) http.Handler {
}

// Dashboard describes a unique build dashboard.
//
// (There used to be more than one dashboard, so this is now somewhat
// less important than it once was.)
type Dashboard struct {
Name string // This dashboard's name (eg, "Go")
Namespace string // This dashboard's namespace (eg, "" (default), "Git")
Prefix string // The path prefix (no trailing /)
Name string // This dashboard's name (always "Go" nowadays)
Namespace string // This dashboard's namespace (always "Git" nowadays)
Packages []*Package // The project's packages to build
}

Expand All @@ -72,7 +71,6 @@ func (d *Dashboard) Context(ctx context.Context) context.Context {
var goDash = &Dashboard{
Name: "Go",
Namespace: "Git",
Prefix: "",
Packages: goPackages,
}

Expand Down
Loading

0 comments on commit 1380f86

Please sign in to comment.