Pino Toscano
2016-May-26 11:45 UTC
[Libguestfs] [PATCH] customize: random_seed: avoid one file checking for existing files
When the random-seed file is found, then avoid checking its existance again. --- customize/random_seed.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/customize/random_seed.ml b/customize/random_seed.ml index e4c955e..1633aed 100644 --- a/customize/random_seed.ml +++ b/customize/random_seed.ml @@ -35,7 +35,7 @@ let rec set_random_seed (g : Guestfs.guestfs) root List.iter ( fun file -> if g#is_file file then ( - make_random_seed_file g file; + make_random_seed_file g file ~exists:true; created := true ) ) files; @@ -71,8 +71,11 @@ let rec set_random_seed (g : Guestfs.guestfs) root !created -and make_random_seed_file g file - let file_exists = g#is_file file in +and make_random_seed_file ?exists g file + let file_exists + match exists with + | None -> g#is_file file + | Some b -> b in let n if file_exists then ( let n = Int64.to_int (g#filesize file) in -- 2.5.5
Richard W.M. Jones
2016-May-26 14:23 UTC
Re: [Libguestfs] [PATCH] customize: random_seed: avoid one file checking for existing files
On Thu, May 26, 2016 at 01:45:05PM +0200, Pino Toscano wrote:> When the random-seed file is found, then avoid checking its existance > again. > --- > customize/random_seed.ml | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/customize/random_seed.ml b/customize/random_seed.ml > index e4c955e..1633aed 100644 > --- a/customize/random_seed.ml > +++ b/customize/random_seed.ml > @@ -35,7 +35,7 @@ let rec set_random_seed (g : Guestfs.guestfs) root > List.iter ( > fun file -> > if g#is_file file then ( > - make_random_seed_file g file; > + make_random_seed_file g file ~exists:true; > created := true > ) > ) files; > @@ -71,8 +71,11 @@ let rec set_random_seed (g : Guestfs.guestfs) root > > !created > > -and make_random_seed_file g file > - let file_exists = g#is_file file in > +and make_random_seed_file ?exists g file > + let file_exists > + match exists with > + | None -> g#is_file file > + | Some b -> b in > let n > if file_exists then ( > let n = Int64.to_int (g#filesize file) inSeems to be quite a detailed optimization, but sure, ACK. What was the problem this was trying to address? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Pino Toscano
2016-May-26 14:33 UTC
Re: [Libguestfs] [PATCH] customize: random_seed: avoid one file checking for existing files
On Thursday 26 May 2016 15:23:53 Richard W.M. Jones wrote:> On Thu, May 26, 2016 at 01:45:05PM +0200, Pino Toscano wrote: > > When the random-seed file is found, then avoid checking its existance > > again. > > --- > > customize/random_seed.ml | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/customize/random_seed.ml b/customize/random_seed.ml > > index e4c955e..1633aed 100644 > > --- a/customize/random_seed.ml > > +++ b/customize/random_seed.ml > > @@ -35,7 +35,7 @@ let rec set_random_seed (g : Guestfs.guestfs) root > > List.iter ( > > fun file -> > > if g#is_file file then ( > > - make_random_seed_file g file; > > + make_random_seed_file g file ~exists:true; > > created := true > > ) > > ) files; > > @@ -71,8 +71,11 @@ let rec set_random_seed (g : Guestfs.guestfs) root > > > > !created > > > > -and make_random_seed_file g file > > - let file_exists = g#is_file file in > > +and make_random_seed_file ?exists g file > > + let file_exists > > + match exists with > > + | None -> g#is_file file > > + | Some b -> b in > > let n > > if file_exists then ( > > let n = Int64.to_int (g#filesize file) in > > Seems to be quite a detailed optimization, but sure, ACK. What was > the problem this was trying to address?Not a problem at all -- while reading a verbose+trace log of virt-customize, I noticed two g#is_file done (one right after the other) for the existing random-seed file of the guest. -- Pino Toscano
Possibly Parallel Threads
- Re: [PATCH] customize: random_seed: avoid one file checking for existing files
- [PATCH] customize: random_seed: add CirrOS location
- [PATCH] customize: Move virt-customize-related code to a separate
- [PATCH] inspect: recognize the Kali Linux distribution (RHBZ#1544227)
- [PATCH] customize, sysprep, v2v: handle Kali Linux as Debian