From bbf6f360e153cf98d091afdaa31717448cde21e9 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sun, 18 Mar 2012 12:12:23 -0400 Subject: [PATCH] bugfix in caching --- bgzf.c | 10 +++++----- sam_view.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bgzf.c b/bgzf.c index 281aac0..9de2fc3 100644 --- a/bgzf.c +++ b/bgzf.c @@ -267,7 +267,7 @@ static int load_block_from_cache(BGZF *fp, int64_t block_address) if (fp->block_length != 0) fp->block_offset = 0; fp->block_address = block_address; fp->block_length = p->size; - memcpy(fp->uncompressed_block, p->block, BGZF_BLOCK_SIZE); + memcpy(fp->uncompressed_block, p->block, BGZF_MAX_BLOCK_SIZE); _bgzf_seek((_bgzf_file_t)fp->fp, p->end_offset, SEEK_SET); return p->size; } @@ -278,8 +278,8 @@ static void cache_block(BGZF *fp, int size) khint_t k; cache_t *p; khash_t(cache) *h = (khash_t(cache)*)fp->cache; - if (BGZF_BLOCK_SIZE >= fp->cache_size) return; - if ((kh_size(h) + 1) * BGZF_BLOCK_SIZE > fp->cache_size) { + if (BGZF_MAX_BLOCK_SIZE >= fp->cache_size) return; + if ((kh_size(h) + 1) * BGZF_MAX_BLOCK_SIZE > fp->cache_size) { /* A better way would be to remove the oldest block in the * cache, but here we remove a random one for simplicity. This * should not have a big impact on performance. */ @@ -295,8 +295,8 @@ static void cache_block(BGZF *fp, int size) p = &kh_val(h, k); p->size = fp->block_length; p->end_offset = fp->block_address + size; - p->block = malloc(BGZF_BLOCK_SIZE); - memcpy(kh_val(h, k).block, fp->uncompressed_block, BGZF_BLOCK_SIZE); + p->block = malloc(BGZF_MAX_BLOCK_SIZE); + memcpy(kh_val(h, k).block, fp->uncompressed_block, BGZF_MAX_BLOCK_SIZE); } #else static void free_cache(BGZF *fp) {} diff --git a/sam_view.c b/sam_view.c index b9bde44..f198591 100644 --- a/sam_view.c +++ b/sam_view.c @@ -209,7 +209,7 @@ int main_samview(int argc, char *argv[]) ret = 1; goto view_end; } - if (n_threads > 1) samthreads(out, n_threads, 16); + if (n_threads > 1) samthreads(out, n_threads, 256); if (is_header_only) goto view_end; // no need to print alignments if (argc == optind + 1) { // convert/print the entire file -- 2.39.2