diff options
author | Bob Peterson <rpeterso@redhat.com> | 2012-10-19 08:32:51 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2012-11-07 08:31:36 -0500 |
commit | a68a0a352a0209467268dfddffe02db08b97ddb4 (patch) | |
tree | d307e08ac5f985d1e93ebf5fa0f18255a4610bd6 /fs/gfs2/rgrp.c | |
parent | 8eae1ca0034cce78a24738087a32adb1ddb66aa7 (diff) |
GFS2: Speed up gfs2_rbm_from_block
This patch is a rewrite of function gfs2_rbm_from_block. Rather than
looping to find the right bitmap, the code now does a few simple
math calculations.
I compared the performance of both algorithms side by side and the new
algorithm is noticeably faster. Sample instrumentation output from a
"fast" machine:
5 million calls: millisec spent: Orig: 166 New: 113
5 million calls: millisec spent: Orig: 189 New: 114
In addition, I ran postmark (on a somewhat slowr CPU) before the after
the new algorithm was put in place and postmark showed a decent
improvement:
Before the new algorithm:
-------------------------
Time:
645 seconds total
584 seconds of transactions (171 per second)
Files:
150087 created (232 per second)
Creation alone: 100000 files (2083 per second)
Mixed with transactions: 50087 files (85 per second)
49995 read (85 per second)
49991 appended (85 per second)
150087 deleted (232 per second)
Deletion alone: 100174 files (7705 per second)
Mixed with transactions: 49913 files (85 per second)
Data:
273.42 megabytes read (434.08 kilobytes per second)
852.13 megabytes written (1.32 megabytes per second)
With the new algorithm:
-----------------------
Time:
599 seconds total
530 seconds of transactions (188 per second)
Files:
150087 created (250 per second)
Creation alone: 100000 files (1886 per second)
Mixed with transactions: 50087 files (94 per second)
49995 read (94 per second)
49991 appended (94 per second)
150087 deleted (250 per second)
Deletion alone: 100174 files (6260 per second)
Mixed with transactions: 49913 files (94 per second)
Data:
273.42 megabytes read (467.42 kilobytes per second)
852.13 megabytes written (1.42 megabytes per second)
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/rgrp.c')
-rw-r--r-- | fs/gfs2/rgrp.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 38fe18f2f055..669b89b95ccc 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -251,22 +251,25 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len, | |||
251 | static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) | 251 | static int gfs2_rbm_from_block(struct gfs2_rbm *rbm, u64 block) |
252 | { | 252 | { |
253 | u64 rblock = block - rbm->rgd->rd_data0; | 253 | u64 rblock = block - rbm->rgd->rd_data0; |
254 | u32 goal = (u32)rblock; | 254 | u32 x; |
255 | int x; | ||
256 | 255 | ||
257 | if (WARN_ON_ONCE(rblock > UINT_MAX)) | 256 | if (WARN_ON_ONCE(rblock > UINT_MAX)) |
258 | return -EINVAL; | 257 | return -EINVAL; |
259 | if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) | 258 | if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) |
260 | return -E2BIG; | 259 | return -E2BIG; |
261 | 260 | ||
262 | for (x = 0; x < rbm->rgd->rd_length; x++) { | 261 | rbm->bi = rbm->rgd->rd_bits; |
263 | rbm->bi = rbm->rgd->rd_bits + x; | 262 | rbm->offset = (u32)(rblock); |
264 | if (goal < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) { | 263 | /* Check if the block is within the first block */ |
265 | rbm->offset = goal - (rbm->bi->bi_start * GFS2_NBBY); | 264 | if (rbm->offset < (rbm->bi->bi_start + rbm->bi->bi_len) * GFS2_NBBY) |
266 | break; | 265 | return 0; |
267 | } | ||
268 | } | ||
269 | 266 | ||
267 | /* Adjust for the size diff between gfs2_meta_header and gfs2_rgrp */ | ||
268 | rbm->offset += (sizeof(struct gfs2_rgrp) - | ||
269 | sizeof(struct gfs2_meta_header)) * GFS2_NBBY; | ||
270 | x = rbm->offset / rbm->rgd->rd_sbd->sd_blocks_per_bitmap; | ||
271 | rbm->offset -= x * rbm->rgd->rd_sbd->sd_blocks_per_bitmap; | ||
272 | rbm->bi += x; | ||
270 | return 0; | 273 | return 0; |
271 | } | 274 | } |
272 | 275 | ||