Megatest

Check-in [95f5714070]
Login
Overview
Comment:Data syncs from server to dashboard but CPU load is too high
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | newdashboard
Files: files | file ages | folders
SHA1: 95f571407071982bf3a88988be3084165bea3704
User & Date: matt on 2013-03-14 00:32:22
Other Links: branch diff | manifest | tags
Context
2013-03-14
14:46
Added some instrumention, added missing use of synchash check-in: ab18b06155 user: mrwellan tags: newdashboard
00:32
Data syncs from server to dashboard but CPU load is too high check-in: 95f5714070 user: matt tags: newdashboard
2013-03-13
22:10
Outlined delta get run and tests method check-in: 1eb20fd535 user: matt tags: newdashboard
Changes

Modified newdashboard.scm from [bd9e7cef68] to [80e9599109].

379
380
381
382
383
384
385



386
387
388
389
390
391
392
  (let ((run-ids '()))
    ;; count and offset => #f so not used
    ;; the synchash calls modify the "data" hash
    (synchash:client-get 'db:get-runs  "get-runs" (length keypatts) data runname #f #f keypatts)
    ;; Now can calculate the run-ids
    (let* ((run-hash (hash-table-ref/default data "get-runs" #f))
	   (run-ids (if run-hash (filter number? (hash-table-keys run-hash)) '())))



      (synchash:client-get 'db:get-tests-for-runs "get-tests-for-runs" 0 data run-ids testpatt states statuses))))

(define (newdashboard)
  (let* ((data     (make-hash-table))
	 (keys     (cdb:remote-run db:get-keys #f))
	 (runname  "%")
	 (testpatt "%")







>
>
>







379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
  (let ((run-ids '()))
    ;; count and offset => #f so not used
    ;; the synchash calls modify the "data" hash
    (synchash:client-get 'db:get-runs  "get-runs" (length keypatts) data runname #f #f keypatts)
    ;; Now can calculate the run-ids
    (let* ((run-hash (hash-table-ref/default data "get-runs" #f))
	   (run-ids (if run-hash (filter number? (hash-table-keys run-hash)) '())))
      ;; (debug:print-info 2 "run-hash-keys: " (hash-table-keys run-hash))
      ;; (debug:print-info 2 "run-hash: ")(pp (hash-table->alist run-hash))
      ;; (debug:print-info 2 "run-ids: " run-ids)
      (synchash:client-get 'db:get-tests-for-runs "get-tests-for-runs" 0 data run-ids testpatt states statuses))))

(define (newdashboard)
  (let* ((data     (make-hash-table))
	 (keys     (cdb:remote-run db:get-keys #f))
	 (runname  "%")
	 (testpatt "%")

Modified synchash.scm from [fc621c950a] to [799e727de6].

49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
64
65
66
67





68
69
70
71

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

100
101
102
103
104

105
106
107
108
109
110
    (for-each 
     (lambda (id)
       (if (not (member id found))
	   (begin
	     (set! deleted (cons id deleted))
	     (hash-table-delete! synchash id))))
     orig-keys)
    (list changed deleted)))


    
;; (cdb:remote-run db:get-keys #f)  
;; (cdb:remote-run db:get-num-runs #f "%")
;; (cdb:remote-run db:get-runs #f runnamepatt numruns *start-run-offset* keypatts)
;;
;; keynum => the field to use as the unique key (usually 0 but can be other field)
;;
(define (synchash:client-get proc synckey keynum synchash . params)
  (let* ((data   (apply cdb:remote-run synchash:server-get #f proc synckey keynum params))
	 (newdat (car data))
	 (removs (cadr data)))





    (for-each 
     (lambda (item)
       (let ((id  (car item))
	     (dat (cadr item)))

	 (hash-table-set! synchash id dat)))
     newdat)
    (for-each
     (lambda (id)
       (hash-table-delete! synchash id))
     removs)
    synchash))


(define *synchashes* (make-hash-table))

(define (synchash:server-get db proc synckey keynum . params)
  (debug:print 2 "synckey: " synckey ", keynum: " keynum ", params: " params)
  (let* ((synchash (hash-table-ref/default *synchashes* synckey #f))
	 (newdat   (apply (case proc
			    ((db:get-runs) db:get-runs)
			    ((db:get-tests-for-runs) db:get-tests-for-runs)
			    (else print))
			  db params))
	 (postdat  #f)
	 (make-indexed (lambda (x)
			 (list (vector-ref x keynum) x))))
    ;; Now process newdat based on the query type
    (set! postdat (case proc
		    ((db:get-runs)
		     (debug:print 2 "Get runs call")
		     (let ((header (vector-ref newdat 0))
			   (data   (vector-ref newdat 1)))

		       (list (list "header" header)         ;; add the header keyed by the word "header"
			     (map make-indexed data))))        ;; add each element keyed by the keynum'th val
		    (else 
		     (debug:print 2 "Non-get runs call")
		     (map make-indexed newdat))))

    (if (not synchash)
	(begin
	  (set! synchash (make-hash-table))
	  (hash-table-set! *synchashes* synckey synchash)))
    (synchash:get-delta postdat synchash)))








|
>
>










|
>
>
>
>
>




>
|



|







|












|


>
|


|

>






49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    (for-each 
     (lambda (id)
       (if (not (member id found))
	   (begin
	     (set! deleted (cons id deleted))
	     (hash-table-delete! synchash id))))
     orig-keys)
    (list changed deleted)
    ;; (list indat '()) ;; just for debugging
    ))
    
;; (cdb:remote-run db:get-keys #f)  
;; (cdb:remote-run db:get-num-runs #f "%")
;; (cdb:remote-run db:get-runs #f runnamepatt numruns *start-run-offset* keypatts)
;;
;; keynum => the field to use as the unique key (usually 0 but can be other field)
;;
(define (synchash:client-get proc synckey keynum synchash . params)
  (let* ((data   (apply cdb:remote-run synchash:server-get #f proc synckey keynum params))
	 (newdat (car data))
	 (removs (cadr data))
	 (myhash (hash-table-ref/default synchash synckey #f)))
    (if (not myhash)
	(begin
	  (set! myhash (make-hash-table))
	  (hash-table-set! synchash synckey myhash)))
    (for-each 
     (lambda (item)
       (let ((id  (car item))
	     (dat (cadr item)))
	 ;; (debug:print-info 2 "Processing item: " item)
	 (hash-table-set! myhash id dat)))
     newdat)
    (for-each
     (lambda (id)
       (hash-table-delete! myhash id))
     removs)
    synchash))


(define *synchashes* (make-hash-table))

(define (synchash:server-get db proc synckey keynum . params)
  ;; (debug:print-info 2 "synckey: " synckey ", keynum: " keynum ", params: " params)
  (let* ((synchash (hash-table-ref/default *synchashes* synckey #f))
	 (newdat   (apply (case proc
			    ((db:get-runs) db:get-runs)
			    ((db:get-tests-for-runs) db:get-tests-for-runs)
			    (else print))
			  db params))
	 (postdat  #f)
	 (make-indexed (lambda (x)
			 (list (vector-ref x keynum) x))))
    ;; Now process newdat based on the query type
    (set! postdat (case proc
		    ((db:get-runs)
		     ;; (debug:print-info 2 "Get runs call")
		     (let ((header (vector-ref newdat 0))
			   (data   (vector-ref newdat 1)))
		       ;; (debug:print-info 2 "header: " header ", data: " data)
		       (cons (list "header" header)         ;; add the header keyed by the word "header"
			     (map make-indexed data))))        ;; add each element keyed by the keynum'th val
		    (else 
		     ;; (debug:print-info 2 "Non-get runs call")
		     (map make-indexed newdat))))
    ;; (debug:print-info 2 "postdat: " postdat)
    (if (not synchash)
	(begin
	  (set! synchash (make-hash-table))
	  (hash-table-set! *synchashes* synckey synchash)))
    (synchash:get-delta postdat synchash)))