Messages in this thread Patch in this message |  | | From | Johnny Stenback <> | Subject | Re: patch.... | Date | Wed, 31 Jul 1996 03:15:23 +0300 (EET DST) |
| |
> > > Tiny patch to hopefully speed up get_empty_filp(). > > I claim this has an average running time of N/M where N is the number > of allocated structs, and M is the number of free structs. It's also > just plain faster which is actually find a struct because it doesn't > mess around with re-writing all the pointers, and zero'ing the entire > structure. It only zero's the parts that aren't going to get > overwritten, and saves 3 function calls to boot. > > basic idea is, starting searching from the struct after the last free > struct that was found to be free. > > Anyone see any hugely obvious errors? >
No, but one tiny thing I did notice, you check if f->f_count is 0 (if(!f->f_count)) then tou do f->f_... = ... = f->f_count = ... = 0; ie f->f_count is allready 0 so no need to set it any more, this is offcource a very small thing and might be optimized away by the compiler but it's not nessesery IMO...
> Michael. > > --- linux/fs/file_table.c.old Tue Jul 30 19:47:35 1996 > +++ linux/fs/file_table.c Tue Jul 30 19:59:41 1996 > @@ -102,7 +102,7 @@ > { > int i; > int max = max_files; > - struct file * f; > + static struct file * f = NULL; > > /* > * Reserve a few files for the super-user.. > @@ -111,15 +111,25 @@ > max -= 10; > > /* if the return is taken, we are in deep trouble */ > - if (!first_file && !grow_files()) > - return NULL; > + if (!first_file) { > + if (!grow_files()) > + return NULL; > + f = first_file; > + } > > do { > - for (f = first_file, i=0; i < nr_files; i++, f = f->f_next) > + for (f = f->next, i=0; i < nr_files; i++, f = f->f_next) > if (!f->f_count) { > +#if 1 > + f->f_mode = f->f_pos = f->f_flags = f->f_count = > + f->f_reada = f->f_ramax = f->f_raend = f->f_ralen = > + f->f_rawin = f->f_owner = 0; > + f->private_data = f->f_op = f->f_inode = NULL; > +#else > remove_file_free(f); > memset(f,0,sizeof(*f)); > put_last_free(f); > +#endif > f->f_count = 1; > f->f_version = ++event; > return f; >
-- Johnny Stenback, programmer / University of Vaasa, Computer Centre E-Mail jst@uwasa.fi, Phone +358 61 3248 387, +358 50 5575 094
|  |