[PATCH] Improve small message size performance by 40%

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



inc and dec operations in icmap were retrieving the key then setting it.
As part of this process there was a memcpy operation and some extra
operations that are not necessary when executing an increment
operation.

This patch gets the key's value and then modifies it directly.

Signed-off-by: Steven Dake <sdake@xxxxxxxxxx>
---
 exec/icmap.c |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/exec/icmap.c b/exec/icmap.c
index 14390d4..fdd6e49 100644
--- a/exec/icmap.c
+++ b/exec/icmap.c
@@ -630,10 +630,10 @@ cs_error_t icmap_adjust_int(
 	int32_t step)
 {
 	struct icmap_item *item;
-	uint8_t u8;
-	uint16_t u16;
-	uint32_t u32;
-	uint64_t u64;
+	uint8_t *u8;
+	uint16_t *u16;
+	uint32_t *u32;
+	uint64_t *u64;
 	cs_error_t err = CS_OK;
 
 	if (key_name == NULL) {
@@ -648,27 +648,23 @@ cs_error_t icmap_adjust_int(
 	switch (item->type) {
 	case ICMAP_VALUETYPE_INT8:
 	case ICMAP_VALUETYPE_UINT8:
-		memcpy(&u8, item->value, sizeof(u8));
-		u8 += step;
-		err = icmap_set(key_name, &u8, sizeof(u8), item->type);
+		u8 = (uint8_t *)item->value;
+		*u8 += step;
 		break;
 	case ICMAP_VALUETYPE_INT16:
 	case ICMAP_VALUETYPE_UINT16:
-		memcpy(&u16, item->value, sizeof(u16));
-		u16 += step;
-		err = icmap_set(key_name, &u16, sizeof(u16), item->type);
+		u16 = (uint16_t *)item->value;
+		*u16 += step;
 		break;
 	case ICMAP_VALUETYPE_INT32:
 	case ICMAP_VALUETYPE_UINT32:
-		memcpy(&u32, item->value, sizeof(u32));
-		u32 += step;
-		err = icmap_set(key_name, &u32, sizeof(u32), item->type);
+		u32 = (uint32_t *)item->value;
+		*u32 += step;
 		break;
 	case ICMAP_VALUETYPE_INT64:
 	case ICMAP_VALUETYPE_UINT64:
-		memcpy(&u64, item->value, sizeof(u64));
-		u64 += step;
-		err = icmap_set(key_name, &u64, sizeof(u64), item->type);
+		u64 = (uint64_t *)item->value;
+		*u64 += step;
 		break;
 	case ICMAP_VALUETYPE_FLOAT:
 	case ICMAP_VALUETYPE_DOUBLE:
-- 
1.7.7.4

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux