Patchwork [3/3] buildstats: use TaskBase time for elapsed time

login
register
mail settings
Submitter Alexandru DAMIAN
Date March 17, 2014, 3:04 p.m.
Message ID <6f3acb92219b832f847d4e59342c8c4582ac5b78.1395068545.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/68745/
State New
Headers show

Comments

Alexandru DAMIAN - March 17, 2014, 3:04 p.m.
From: Marius Avram <marius.avram@intel.com>

To avoid any further inconsistencies between buildstats and buildinfohelper
from toaster, buildstats will measure task duration using the time field
from within the TaskBase events: TaskStarted and TaskSucceeded/TaskFailed.

Signed-off-by: Marius Avram <marius.avram@intel.com>
---
 meta/classes/buildstats.bbclass | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
Saul Wold - March 18, 2014, 10:28 p.m.
On 03/17/2014 08:04 AM, Alex DAMIAN wrote:
> From: Marius Avram <marius.avram@intel.com>
>
> To avoid any further inconsistencies between buildstats and buildinfohelper
> from toaster, buildstats will measure task duration using the time field
> from within the TaskBase events: TaskStarted and TaskSucceeded/TaskFailed.
>

This patch seems to be causing some problems:

> ERROR: Execution of event handler 'run_buildstats' failed
> Traceback (most recent call last):
>   File "run_buildstats(e)", line 72, in run_buildstats(e=<bb.build.TaskStarted object at 0x6e45590>)
> AttributeError: 'TaskStarted' object has no attribute 'time'
>
> ERROR: Execution of event handler 'run_buildstats' failed
> Traceback (most recent call last):
>   File "run_buildstats(e)", line 88, in run_buildstats(e=<bb.build.TaskSucceeded object at 0x6e40190>)
>   File "buildstats.bbclass", line 5, in write_task_data(status='passed', logfile='/home/sgw/yocto/builds/world/tmp/buildstats/linux-yocto-qemux86-64/201403181525/linux-yocto-3.10.32+gitAUTOINC+7b3b87d4d5_78afd3095c-r0/do_clean', dev='sda5', e=<bb.build.TaskSucceeded object at 0x6e40190>)
> IOError: [Errno 2] No such file or directory: '/home/sgw/yocto/builds/world/tmp/buildstats/linux-yocto-qemux86-64/201403181525/linux-yocto-3.10.32+gitAUTOINC+7b3b87d4d5_78afd3095c-r0/do_clean'
>
> ERROR: Execution of event handler 'run_buildstats' failed
> Traceback (most recent call last):
>   File "run_buildstats(e)", line 72, in run_buildstats(e=<bb.build.TaskStarted object at 0x74f59d0>)
> AttributeError: 'TaskStarted' object has no attribute 'time'
>
> ERROR: Execution of event handler 'run_buildstats' failed
> Traceback (most recent call last):
>   File "run_buildstats(e)", line 88, in run_buildstats(e=<bb.build.TaskSucceeded object at 0x6e48dd0>)
>   File "buildstats.bbclass", line 5, in write_task_data(status='passed', logfile='/home/sgw/yocto/builds/world/tmp/buildstats/linux-yocto-qemux86-64/201403181525/linux-yocto-3.10.32+gitAUTOINC+7b3b87d4d5_78afd3095c-r0/do_cleansstate', dev='sda5', e=<bb.build.TaskSucceeded object at 0x6e48dd0>)



Sau!


> Signed-off-by: Marius Avram <marius.avram@intel.com>
> ---
>   meta/classes/buildstats.bbclass | 23 +++++++++++++++--------
>   1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
> index 72fff11..89ae72c 100644
> --- a/meta/classes/buildstats.bbclass
> +++ b/meta/classes/buildstats.bbclass
> @@ -109,14 +109,17 @@ def get_diskdata(var, dev, data):
>           diskdata["End"+key] = str(int(newdiskdata[key]))
>       return diskdata
>
> -def set_timedata(var, data):
> +def set_timedata(var, data, server_time=None):
>       import time
> -    time = time.time()
> +    if server_time:
> +        time = server_time
> +    else:
> +        time = time.time()
>       cputime = get_cputime()
>       proctime = get_process_cputime(os.getpid())
>       data.setVar(var, (time, cputime, proctime))
>
> -def get_timedata(var, data):
> +def get_timedata(var, data, server_time=None):
>       import time
>       timedata = data.getVar(var, False)
>       if timedata is None:
> @@ -124,7 +127,11 @@ def get_timedata(var, data):
>       oldtime, oldcpu, oldproc = timedata
>       procdiff = get_process_cputime(os.getpid()) - oldproc
>       cpudiff = get_cputime() - oldcpu
> -    timediff = time.time() - oldtime
> +    if server_time:
> +        end_time = server_time
> +    else:
> +        end_time = time.time()
> +    timediff = end_time - oldtime
>       if cpudiff > 0:
>           cpuperc = float(procdiff) * 100 / cpudiff
>       else:
> @@ -136,7 +143,7 @@ def write_task_data(status, logfile, dev, e):
>       bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
>       taskdir = os.path.join(bsdir, e.data.expand("${PF}"))
>       file = open(os.path.join(logfile), "a")
> -    timedata = get_timedata("__timedata_task", e.data)
> +    timedata = get_timedata("__timedata_task", e.data, e.time)
>       if timedata:
>           elapsedtime, cpu = timedata
>           file.write(bb.data.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" %
> @@ -160,7 +167,7 @@ def write_task_data(status, logfile, dev, e):
>   	    file.write("Status: PASSED \n")
>       else:
>           file.write("Status: FAILED \n")
> -    file.write("Ended: %0.2f \n" % time.time())
> +    file.write("Ended: %0.2f \n" % e.time)
>       file.close()
>
>   python run_buildstats () {
> @@ -234,7 +241,7 @@ python run_buildstats () {
>           taskdir = os.path.join(bsdir, e.data.expand("${PF}"))
>           if device != "NoLogicalDevice":
>               set_diskdata("__diskdata_task", device, e.data)
> -        set_timedata("__timedata_task", e.data)
> +        set_timedata("__timedata_task", e.data, e.time)
>           try:
>               bb.utils.mkdirhier(taskdir)
>           except:
> @@ -242,7 +249,7 @@ python run_buildstats () {
>           # write into the task event file the name and start time
>           file = open(os.path.join(taskdir, e.task), "a")
>           file.write("Event: %s \n" % bb.event.getName(e))
> -        file.write("Started: %0.2f \n" % time.time())
> +        file.write("Started: %0.2f \n" % e.time)
>           file.close()
>
>       elif isinstance(e, bb.build.TaskSucceeded):
>
Richard Purdie - March 18, 2014, 11:15 p.m.
On Tue, 2014-03-18 at 15:28 -0700, Saul Wold wrote:
> On 03/17/2014 08:04 AM, Alex DAMIAN wrote:
> > From: Marius Avram <marius.avram@intel.com>
> >
> > To avoid any further inconsistencies between buildstats and buildinfohelper
> > from toaster, buildstats will measure task duration using the time field
> > from within the TaskBase events: TaskStarted and TaskSucceeded/TaskFailed.
> >
> 
> This patch seems to be causing some problems:

I suspect this is dependent on a bitbake change...

Cheers,

Richard
Alexandru DAMIAN - March 19, 2014, 9:34 a.m.
Yep, there is a counterpart change submitted to bitbake.

Alex


On Tue, Mar 18, 2014 at 11:15 PM, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Tue, 2014-03-18 at 15:28 -0700, Saul Wold wrote:
> > On 03/17/2014 08:04 AM, Alex DAMIAN wrote:
> > > From: Marius Avram <marius.avram@intel.com>
> > >
> > > To avoid any further inconsistencies between buildstats and
> buildinfohelper
> > > from toaster, buildstats will measure task duration using the time
> field
> > > from within the TaskBase events: TaskStarted and
> TaskSucceeded/TaskFailed.
> > >
> >
> > This patch seems to be causing some problems:
>
> I suspect this is dependent on a bitbake change...
>
> Cheers,
>
> Richard
>
>

Patch

diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 72fff11..89ae72c 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -109,14 +109,17 @@  def get_diskdata(var, dev, data):
         diskdata["End"+key] = str(int(newdiskdata[key]))    
     return diskdata
     
-def set_timedata(var, data):
+def set_timedata(var, data, server_time=None):
     import time
-    time = time.time()
+    if server_time:
+        time = server_time
+    else:
+        time = time.time()
     cputime = get_cputime()
     proctime = get_process_cputime(os.getpid())
     data.setVar(var, (time, cputime, proctime))
 
-def get_timedata(var, data):
+def get_timedata(var, data, server_time=None):
     import time
     timedata = data.getVar(var, False)
     if timedata is None:
@@ -124,7 +127,11 @@  def get_timedata(var, data):
     oldtime, oldcpu, oldproc = timedata
     procdiff = get_process_cputime(os.getpid()) - oldproc
     cpudiff = get_cputime() - oldcpu
-    timediff = time.time() - oldtime
+    if server_time:
+        end_time = server_time
+    else:
+        end_time = time.time()
+    timediff = end_time - oldtime
     if cpudiff > 0:
         cpuperc = float(procdiff) * 100 / cpudiff
     else:
@@ -136,7 +143,7 @@  def write_task_data(status, logfile, dev, e):
     bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
     taskdir = os.path.join(bsdir, e.data.expand("${PF}"))
     file = open(os.path.join(logfile), "a")
-    timedata = get_timedata("__timedata_task", e.data)
+    timedata = get_timedata("__timedata_task", e.data, e.time)
     if timedata:
         elapsedtime, cpu = timedata
         file.write(bb.data.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" %
@@ -160,7 +167,7 @@  def write_task_data(status, logfile, dev, e):
 	    file.write("Status: PASSED \n")
     else:
         file.write("Status: FAILED \n")
-    file.write("Ended: %0.2f \n" % time.time())
+    file.write("Ended: %0.2f \n" % e.time)
     file.close()
 
 python run_buildstats () {
@@ -234,7 +241,7 @@  python run_buildstats () {
         taskdir = os.path.join(bsdir, e.data.expand("${PF}"))
         if device != "NoLogicalDevice":
             set_diskdata("__diskdata_task", device, e.data)
-        set_timedata("__timedata_task", e.data)
+        set_timedata("__timedata_task", e.data, e.time)
         try:
             bb.utils.mkdirhier(taskdir)
         except:
@@ -242,7 +249,7 @@  python run_buildstats () {
         # write into the task event file the name and start time
         file = open(os.path.join(taskdir, e.task), "a")
         file.write("Event: %s \n" % bb.event.getName(e))
-        file.write("Started: %0.2f \n" % time.time())
+        file.write("Started: %0.2f \n" % e.time)
         file.close()
 
     elif isinstance(e, bb.build.TaskSucceeded):