All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [XTF PATCH 3/3] xtf-runner: support two modes for getting output
Date: Thu, 11 Aug 2016 11:49:29 +0100	[thread overview]
Message-ID: <22444.22585.557134.625414@mariner.uk.xensource.com> (raw)
In-Reply-To: <1470841650-30850-4-git-send-email-wei.liu2@citrix.com>

Wei Liu writes ("[XTF PATCH 3/3] xtf-runner: support two modes for getting output"):
> We need two modes for getting output:
...
> +    # Use time to generate unique stamps
> +    start_stamp = "===== XTF TEST START %s =====" % local_time
> +    end_stamp = "===== XTF TEST END %s =====" % local_time

This will go wrong if someone runs the same test very rapidly in a
loop.  It needs to be augmented, at least.

Ideally with the domid, but AFAICT that's not available here.  If you
can't think of anything else, use, in addition to the timestamp, the
pid of the xtf-runner process, plus a counter.  (The counter is
necessary in case the same xtf-runner process is used to run the same
test multiple times.)

> +    f = open(fn, "rb")
> +    output = f.readlines()
> +    f.close()
> +    lines = []
> +    found = False
> +    for line in output:
> +        if end_stamp in line:
> +            break
> +        if start_stamp in line:
> +            found = True
> +            continue
> +        if not found:
> +            continue
> +        lines.append(line)

This is accidentally quadratic in the number of test executions.
Do we care ?

If we do care, we should read the file backwards.  AFAICT "tac" can do
this in a manner that's not quadratic in the size of the logfile:

mariner:iwj> time tac v | head | sha256sum 
55748d8a2243c7a8978eccf24bb4f603091ecf4be836294e7009695426971485  -

real    0m0.019s
user    0m0.000s
sys     0m0.000s
mariner:iwj> time cat v | tail | tac | sha256sum 
55748d8a2243c7a8978eccf24bb4f603091ecf4be836294e7009695426971485  -

real    0m11.286s
user    0m0.296s
sys     0m1.096s
mariner:iwj> ll --hu v
-rw-rw-r-- 1 iwj iwj 638M Aug 11 11:42 v
mariner:iwj>

Or you could write your own implementation.  The algorithm is to read
increasingly large chunks of the tail of the file, into memory, until
you find all of the part you're looking for.

HTH.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-08-11 10:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-10 15:07 [XTF PATCH 0/3] Support getting output from either console or log file Wei Liu
2016-08-10 15:07 ` [XTF PATCH 1/3] xtf-runner: introduce get_xen_version Wei Liu
2016-08-11 10:10   ` Andrew Cooper
2016-08-11 10:12     ` Wei Liu
2016-08-11 10:14       ` Andrew Cooper
2016-08-10 15:07 ` [XTF PATCH 2/3] xtf-runner: options for different modes to get output Wei Liu
2016-08-10 15:07 ` [XTF PATCH 3/3] xtf-runner: support two modes for getting output Wei Liu
2016-08-11  8:33   ` Wei Liu
2016-08-11  9:44     ` Wei Liu
2016-08-11  9:56       ` Andrew Cooper
2016-08-11 10:05         ` Wei Liu
2016-08-11 11:08         ` Ian Jackson
2016-08-11 11:19           ` Wei Liu
2016-08-11 11:41             ` Andrew Cooper
2016-08-11 10:49   ` Ian Jackson [this message]
2016-08-11 11:03     ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22444.22585.557134.625414@mariner.uk.xensource.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.