@@ -12,7 +12,6 @@ import (
12
12
"fmt"
13
13
"io"
14
14
"io/ioutil"
15
- "strconv"
16
15
"strings"
17
16
"time"
18
17
@@ -23,7 +22,6 @@ import (
23
22
24
23
const (
25
24
maxDatastoreStringLen = 500
26
- PerfRunLength = 1024
27
25
)
28
26
29
27
// A Package describes a package that is listed on the dashboard.
@@ -101,12 +99,6 @@ type Commit struct {
101
99
// The complete data set is stored in Result entities.
102
100
ResultData []string `datastore:",noindex"`
103
101
104
- // PerfResults holds a set of “builder|benchmark” tuples denoting
105
- // what benchmarks have been executed on the commit.
106
- PerfResults []string `datastore:",noindex"`
107
-
108
- FailNotificationSent bool
109
-
110
102
buildingURLs map [builderAndGoHash ]string
111
103
}
112
104
@@ -183,25 +175,6 @@ func (com *Commit) RemoveResult(r *Result) {
183
175
com .ResultData = rd
184
176
}
185
177
186
- // AddPerfResult remembers that the builder has run the benchmark on the commit.
187
- // It must be called from inside a datastore transaction.
188
- func (com * Commit ) AddPerfResult (c context.Context , builder , benchmark string ) error {
189
- if err := datastore .Get (c , com .Key (c ), com ); err != nil {
190
- return fmt .Errorf ("getting Commit: %v" , err )
191
- }
192
- if ! com .NeedsBenchmarking {
193
- return fmt .Errorf ("trying to add perf result to Commit(%v) that does not require benchmarking" , com .Hash )
194
- }
195
- s := builder + "|" + benchmark
196
- for _ , v := range com .PerfResults {
197
- if v == s {
198
- return nil
199
- }
200
- }
201
- com .PerfResults = append (com .PerfResults , s )
202
- return putCommit (c , com )
203
- }
204
-
205
178
func trim (s []string , n int ) []string {
206
179
l := min (len (s ), n )
207
180
return s [len (s )- l :]
@@ -314,116 +287,6 @@ func reverse(s []string) {
314
287
}
315
288
}
316
289
317
- // A CommitRun provides summary information for commits [StartCommitNum, StartCommitNum + PerfRunLength).
318
- // Descendant of Package.
319
- type CommitRun struct {
320
- PackagePath string // (empty for main repo commits)
321
- StartCommitNum int
322
- Hash []string `datastore:",noindex"`
323
- User []string `datastore:",noindex"`
324
- Desc []string `datastore:",noindex"` // Only first line.
325
- Time []time.Time `datastore:",noindex"`
326
- NeedsBenchmarking []bool `datastore:",noindex"`
327
- }
328
-
329
- func (cr * CommitRun ) Key (c context.Context ) * datastore.Key {
330
- p := Package {Path : cr .PackagePath }
331
- key := strconv .Itoa (cr .StartCommitNum )
332
- return datastore .NewKey (c , "CommitRun" , key , 0 , p .Key (c ))
333
- }
334
-
335
- // GetCommitRun loads and returns CommitRun that contains information
336
- // for commit commitNum.
337
- func GetCommitRun (c context.Context , commitNum int ) (* CommitRun , error ) {
338
- cr := & CommitRun {StartCommitNum : commitNum / PerfRunLength * PerfRunLength }
339
- err := datastore .Get (c , cr .Key (c ), cr )
340
- if err != nil && err != datastore .ErrNoSuchEntity {
341
- return nil , fmt .Errorf ("getting CommitRun: %v" , err )
342
- }
343
- if len (cr .Hash ) != PerfRunLength {
344
- cr .Hash = make ([]string , PerfRunLength )
345
- cr .User = make ([]string , PerfRunLength )
346
- cr .Desc = make ([]string , PerfRunLength )
347
- cr .Time = make ([]time.Time , PerfRunLength )
348
- cr .NeedsBenchmarking = make ([]bool , PerfRunLength )
349
- }
350
- return cr , nil
351
- }
352
-
353
- func (cr * CommitRun ) AddCommit (c context.Context , com * Commit ) error {
354
- if com .Num < cr .StartCommitNum || com .Num >= cr .StartCommitNum + PerfRunLength {
355
- return fmt .Errorf ("AddCommit: commit num %v out of range [%v, %v)" ,
356
- com .Num , cr .StartCommitNum , cr .StartCommitNum + PerfRunLength )
357
- }
358
- i := com .Num - cr .StartCommitNum
359
- // Be careful with string lengths,
360
- // we need to fit 1024 commits into 1 MB.
361
- cr .Hash [i ] = com .Hash
362
- cr .User [i ] = shortDesc (com .User )
363
- cr .Desc [i ] = shortDesc (com .Desc )
364
- cr .Time [i ] = com .Time
365
- cr .NeedsBenchmarking [i ] = com .NeedsBenchmarking
366
- if _ , err := datastore .Put (c , cr .Key (c ), cr ); err != nil {
367
- return fmt .Errorf ("putting CommitRun: %v" , err )
368
- }
369
- return nil
370
- }
371
-
372
- // GetCommits returns [startCommitNum, startCommitNum+n) commits.
373
- // Commits information is partial (obtained from CommitRun),
374
- // do not store them back into datastore.
375
- func GetCommits (c context.Context , startCommitNum , n int ) ([]* Commit , error ) {
376
- if startCommitNum < 0 || n <= 0 {
377
- return nil , fmt .Errorf ("GetCommits: invalid args (%v, %v)" , startCommitNum , n )
378
- }
379
-
380
- p := & Package {}
381
- t := datastore .NewQuery ("CommitRun" ).
382
- Ancestor (p .Key (c )).
383
- Filter ("StartCommitNum >=" , startCommitNum / PerfRunLength * PerfRunLength ).
384
- Order ("StartCommitNum" ).
385
- Limit (100 ).
386
- Run (c )
387
-
388
- res := make ([]* Commit , n )
389
- for {
390
- cr := new (CommitRun )
391
- _ , err := t .Next (cr )
392
- if err == datastore .Done {
393
- break
394
- }
395
- if err != nil {
396
- return nil , err
397
- }
398
- if cr .StartCommitNum >= startCommitNum + n {
399
- break
400
- }
401
- // Calculate start index for copying.
402
- i := 0
403
- if cr .StartCommitNum < startCommitNum {
404
- i = startCommitNum - cr .StartCommitNum
405
- }
406
- // Calculate end index for copying.
407
- e := PerfRunLength
408
- if cr .StartCommitNum + e > startCommitNum + n {
409
- e = startCommitNum + n - cr .StartCommitNum
410
- }
411
- for ; i < e ; i ++ {
412
- com := new (Commit )
413
- com .Hash = cr .Hash [i ]
414
- com .User = cr .User [i ]
415
- com .Desc = cr .Desc [i ]
416
- com .Time = cr .Time [i ]
417
- com .NeedsBenchmarking = cr .NeedsBenchmarking [i ]
418
- res [cr .StartCommitNum - startCommitNum + i ] = com
419
- }
420
- if e != PerfRunLength {
421
- break
422
- }
423
- }
424
- return res , nil
425
- }
426
-
427
290
// partsToResult converts a Commit and ResultData substrings to a Result.
428
291
func partsToResult (c * Commit , p []string ) * Result {
429
292
return & Result {
0 commit comments