From e765daea4d3911af8ca8f9ce15b68eae8c23236f Mon Sep 17 00:00:00 2001
From: Piotr Balcer <piotr.balcer@intel.com>
Date: Tue, 21 Jan 2020 20:19:09 +0100
Subject: [PATCH] obj: remove fill ratio optimization from defrag

This patch removes a check from defrag that prevented
realloc of objects from highly filled runs to low filled runs.
This was originally done as a performance optimization to
reduce the number of realloced objects.

Turns out this has non-negligible negative impact on
effectivness of defrag.
---
 src/libpmemobj/palloc.c                          | 13 -------------
 src/test/obj_fragmentation2/obj_fragmentation2.c |  4 ++--
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/libpmemobj/palloc.c b/src/libpmemobj/palloc.c
index 7f15fbeac..0107ba028 100644
--- a/src/libpmemobj/palloc.c
+++ b/src/libpmemobj/palloc.c
@@ -1043,19 +1043,6 @@ palloc_defrag(struct palloc_heap *heap, uint64_t **objv, size_t objcnt,
 
 		uint64_t new_offset = reserve->heap.offset;
 
-		struct memory_block nm = memblock_from_offset(heap, new_offset);
-
-		mlock = nm.m_ops->get_lock(&nm);
-		os_mutex_lock(mlock);
-		unsigned new_fillpct = nm.m_ops->fill_pct(&nm);
-		os_mutex_unlock(mlock);
-
-		if (original_fillpct > new_fillpct) {
-			palloc_cancel(heap, reserve, 1);
-			VEC_POP_BACK(&actv);
-			continue;
-		}
-
 		VALGRIND_ADD_TO_TX(
 			HEAP_OFF_TO_PTR(heap, new_offset),
 			user_size);
diff --git a/src/test/obj_fragmentation2/obj_fragmentation2.c b/src/test/obj_fragmentation2/obj_fragmentation2.c
index 809e08bc1..4e3a86c50 100644
--- a/src/test/obj_fragmentation2/obj_fragmentation2.c
+++ b/src/test/obj_fragmentation2/obj_fragmentation2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2019, Intel Corporation
+ * Copyright 2017-2020, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -196,7 +196,7 @@ static float workloads_target[] = {
 };
 
 static float workloads_defrag_target[] = {
-	0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.056f, 0.1f, 0.13f, 0.01f
+	0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.05f, 0.09f, 0.13f, 0.01f
 };
 
 /* last workload operates only on huge chunks, so run stats are useless */
-- 
GitLab