Changeset 147c9f6 in mainline


Ignore:
Timestamp:
2011-03-31T17:10:23Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd64680
Parents:
b438804
Message:

Performace optimization:

Use zsearch and isearch to store the index of the first free bit of the bitmap, not of the first block
where the free bit is found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs_balloc.c

    rb438804 r147c9f6  
    66
    77static int
    8 find_free_bit_and_set(bitchunk_t *b, const int bsize, const bool native);
     8find_free_bit_and_set(bitchunk_t *b, const int bsize,
     9                                const bool native, unsigned start_bit);
    910
    1011int
     
    6768        unsigned long nblocks;
    6869        unsigned *search, i, start_block;
     70        unsigned bits_per_block;
    6971        int r, freebit;
    7072
     
    8587                limit = sbi->ninodes;
    8688        }
     89        bits_per_block = sbi->block_size * 8;
    8790
    8891        block_t *b;
     
    9093retry:
    9194
    92         for (i = *search; i < nblocks; ++i) {
     95        for (i = *search / bits_per_block; i < nblocks; ++i) {
    9396                r = block_get(&b, inst->handle, i, BLOCK_FLAGS_NONE);
    9497
     
    97100
    98101                freebit = find_free_bit_and_set(b->data, sbi->block_size,
    99                                                 sbi->native);
     102                                                sbi->native, *search);
    100103                if (freebit == -1) {
    101104                        /*No free bit in this block*/
     
    112115                }
    113116
    114                 *search = i;
     117                *search = i * bits_per_block + *idx;
    115118                b->dirty = true;
    116119                block_put(b);
     
    135138
    136139static int
    137 find_free_bit_and_set(bitchunk_t *b, const int bsize, const bool native)
     140find_free_bit_and_set(bitchunk_t *b, const int bsize,
     141                                const bool native, unsigned start_bit)
    138142{
    139143        int r = -1;
     
    141145        bitchunk_t chunk;
    142146
    143         for (i = 0; i < bsize / sizeof(uint32_t); ++i, ++b) {
    144                 if (~*b) {
     147        for (i = start_bit; i < bsize / sizeof(uint32_t); ++i) {
     148                if (~b[i]) {
    145149                        /*No free bit in this chunk*/
    146150                        continue;
    147151                }
    148152
    149                 chunk = conv32(native, *b);
     153                chunk = conv32(native, b[i]);
    150154
    151155                for (j = 0; j < 32; ++j) {
     
    153157                                r = i * 32 + j;
    154158                                chunk |= 1 << j;
    155                                 *b = conv32(native, chunk);
     159                                b[i] = conv32(native, chunk);
    156160                                goto found;
    157161                        }
Note: See TracChangeset for help on using the changeset viewer.