[sheepdog] [PATCH v1] sheep/http: only read name of kv_onode when iterating
Liu Yuan
namei.unix at gmail.com
Thu Mar 6 09:19:00 CET 2014
On Thu, Mar 06, 2014 at 03:58:50PM +0800, Robin Dong wrote:
> From: root <root at localhost.localdomain>
>
> In object_iterater() it read whole length of SD_DATA_OBJ_SIZE data for
> onode which is not necessary and will hurt performance badly.
> We only need to read out the 'name' of onode.
>
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
> sheep/http/kv.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/sheep/http/kv.c b/sheep/http/kv.c
> index 7570edf..ff3bfd8 100644
> --- a/sheep/http/kv.c
> +++ b/sheep/http/kv.c
> @@ -458,15 +458,16 @@ static void object_iterater(struct sd_index *idx, void *arg, int ignore)
> {
> struct object_iterater_arg *oiarg = arg;
> struct kv_onode *onode = NULL;
> - uint64_t oid;
> + uint64_t oid, read_size;
> int ret;
>
> if (!idx->vdi_id)
> goto out;
>
> - onode = xmalloc(SD_DATA_OBJ_SIZE);
> + read_size = offsetof(struct kv_onode, name) + sizeof(onode->name);
> + onode = xmalloc(read_size);
> oid = vid_to_data_oid(idx->vdi_id, idx->idx);
> - ret = sd_read_object(oid, (char *)onode, SD_DATA_OBJ_SIZE, 0);
> + ret = sd_read_object(oid, (char *)onode, read_size, 0);
> if (ret != SD_RES_SUCCESS) {
> sd_err("Failed to read data object %"PRIx64, oid);
> goto out;
> --
> 1.7.1
>
> --
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog
Applied thanks
Yuan
More information about the sheepdog
mailing list