Changeset dba4a23 in mainline


Ignore:
Timestamp:
2010-07-28T15:22:22Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4637c72, 9a1d8ab
Parents:
6da81e0
Message:

Speed up sequential I/O by caching the "current" cluster in fat_block_get().
This improves sequentil read of a 5m file (using the cat command) by 45 seconds
(73s → 28s).

Location:
uspace/srv/fs/fat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat.h

    r6da81e0 rdba4a23  
    213213
    214214        /*
    215          * Cache of the node's last cluster to avoid some unnecessary FAT walks.
     215         * Cache of the node's last and "current" cluster to avoid some
     216         * unnecessary FAT walks.
    216217         */
    217         bool                    lastc_cached_valid;
    218         fat_cluster_t           lastc_cached_value;
     218        /* Node's last cluster in FAT. */
     219        bool            lastc_cached_valid;
     220        fat_cluster_t   lastc_cached_value;
     221        /* Node's "current" cluster, i.e. where the last I/O took place. */
     222        bool            currc_cached_valid;
     223        aoff64_t        currc_cached_bn;
     224        fat_cluster_t   currc_cached_value;
    219225} fat_node_t;
    220226
  • uspace/srv/fs/fat/fat_fat.c

    r6da81e0 rdba4a23  
    142142    aoff64_t bn, int flags)
    143143{
     144        fat_cluster_t firstc = nodep->firstc;
     145        fat_cluster_t currc;
     146        aoff64_t relbn = bn;
     147        int rc;
     148
    144149        if (!nodep->size)
    145150                return ELIMIT;
     
    158163        }
    159164
     165        if (nodep->currc_cached_valid && bn >= nodep->currc_cached_bn) {
     166                /*
     167                 * We can start with the cluster cached by the previous call to
     168                 * fat_block_get().
     169                 */
     170                firstc = nodep->currc_cached_value;
     171                relbn -= (nodep->currc_cached_bn / SPC(bs)) * SPC(bs);
     172        }
     173
    160174fall_through:
    161         return _fat_block_get(block, bs, nodep->idx->dev_handle, nodep->firstc,
    162             NULL, bn, flags);
     175        rc = _fat_block_get(block, bs, nodep->idx->dev_handle, firstc,
     176            &currc, relbn, flags);
     177        if (rc != EOK)
     178                return rc;
     179       
     180        /*
     181         * Update the "current" cluster cache.
     182         */
     183        nodep->currc_cached_valid = true;
     184        nodep->currc_cached_bn = bn;
     185        nodep->currc_cached_value = currc;
     186
     187        return rc;
    163188}
    164189
     
    567592        dev_handle_t dev_handle = nodep->idx->dev_handle;
    568593
     594        /*
     595         * Invalidate cached cluster numbers.
     596         */
    569597        nodep->lastc_cached_valid = false;
     598        if (nodep->currc_cached_value != lcl)
     599                nodep->currc_cached_valid = false;
     600
    570601        if (lcl == FAT_CLST_RES0) {
    571602                /* The node will have zero size and no clusters allocated. */
     
    597628        }
    598629
     630        /*
     631         * Update and re-enable the last cluster cache.
     632         */
    599633        nodep->lastc_cached_valid = true;
    600634        nodep->lastc_cached_value = lcl;
  • uspace/srv/fs/fat/fat_ops.c

    r6da81e0 rdba4a23  
    106106        node->lastc_cached_valid = false;
    107107        node->lastc_cached_value = FAT_CLST_LAST1;
     108        node->currc_cached_valid = false;
     109        node->currc_cached_bn = 0;
     110        node->currc_cached_value = FAT_CLST_LAST1;
    108111}
    109112
Note: See TracChangeset for help on using the changeset viewer.