Re: Speeding up FAT operations

Vojtech Pavlik (vojtech-lists@twilight.ucw.cz)
Wed, 16 Sep 1998 12:40:21 +0200


On Tue, Sep 15, 1998 at 07:57:38PM +0300, Jukka Tapani Santala wrote:
> I'm using egcs-1.0.3 release and Linux 2.1.120 kernel on Pentium II at the
> moment. Every now and then I feel the need to hunt for the most obiviously
> inefficient bit of code in Linux kernel, which usually falls within the
> domain of FAT filesystem drivers... which, I guess, isn't all Linux's
> fault ;) However, my current pet-peewe is the fat_smap() function in
> fs/fat/cache.c - caches are supposed to speed up things, but with lines
> like...
>
> cluster = sector/sb->cluster_size;
> offset = sector % sb->cluster_size;
>
> ...my computer seems to be wasting most of it's time doing integer divide
> on numbers that my recollection from the FAT days should be replaceable
> by simple bit-operations (Okay, this may have something to do with the
> fact that the FPU is otherwise pre-occupied). Geeze, even int
> i=sb->cluster_size>>1; cluster=sector; while(i>>1) cluster=cluster>>1;
> offset=sector&(sb->cluster_size-1); yields better result. I'm probably
> missing a technique to do away with that loop entirely, but taking the
> shift-value ahead of time into a static variable in appropriate place is
> the real trick...

Well, since the cluster size on FAT filesystems is as far as I know
always a 2^n sectors, if the value of sb->cluster_size was everywhere
replaced by the n instead of being 2^n, you could do just the shifting.

I wonder why it is not done that way. There might be a reason.

Vojtech

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/