Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [small] Revert "Free all slabs on region reset"
@ 2020-01-29  8:06 Alexander Turenko
  2020-01-29  9:59 ` Kirill Yukhin
  2020-01-29 21:41 ` Konstantin Osipov
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Turenko @ 2020-01-29  8:06 UTC (permalink / raw)
  To: Kirill Yukhin; +Cc: tarantool-patches

This reverts commit 67d7ab44ab09df3356929e3692a03321b31f3ebb.

The goal of the reverted commit was to fix flaky fails of tarantool
tests that checks amount of memory used by a fiber:

 | fiber.info()[fiber.self().id()].memory.used

It also attempts to overcome the situation when a fiber holds some
amount of memory, which is not used in any way. The high limit of such
memory is controlled by a threshold in fiber_gc() tarantool's function
(128 KiB at the moment):

 | void
 | fiber_gc(void)
 | {
 |         if (region_used(&fiber()->gc) < 128 * 1024) {
 |                 region_reset(&fiber()->gc);
 |                 return;
 |         }
 |
 |         region_free(&fiber()->gc);
 | }

The reverted commit, however, leads to significant performance
degradation on certain workloads (see #4736). So the revertion fixes the
performance degradation and opens the problem with tests, which is
tracked in #4750.

Related to #12
Related to https://github.com/tarantool/tarantool/issues/4750
Fixes https://github.com/tarantool/tarantool/issues/4736
---

https://github.com/tarantool/small/tree/Totktonada/gh-4736-revert-region-reset

 small/region.h | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/small/region.h b/small/region.h
index d9be176..bea88c6 100644
--- a/small/region.h
+++ b/small/region.h
@@ -156,16 +156,6 @@ region_reserve(struct region *region, size_t size)
 						       slab.next_in_list);
 		if (size <= rslab_unused(slab))
 			return (char *) rslab_data(slab) + slab->used;
-		/* Try to get a slab from the region cache. */
-		slab = rlist_last_entry(&region->slabs.slabs,
-					struct rslab,
-					slab.next_in_list);
-		if (slab->used == 0 && size <= rslab_unused(slab)) {
-			/* Move this slab to the head. */
-			slab_list_del(&region->slabs, &slab->slab, next_in_list);
-			slab_list_add(&region->slabs, &slab->slab, next_in_list);
-			return (char *) rslab_data(slab);
-		}
 	}
 	return region_reserve_slow(region, size);
 }
@@ -222,14 +212,14 @@ region_aligned_alloc(struct region *region, size_t size, size_t alignment)
 
 /**
  * Mark region as empty, but keep the blocks.
- * Do not change the first slab and use previous slabs as a cache to
- * use for future allocations.
  */
 static inline void
 region_reset(struct region *region)
 {
-	struct rslab *slab;
-	rlist_foreach_entry(slab, &region->slabs.slabs, slab.next_in_list) {
+	if (! rlist_empty(&region->slabs.slabs)) {
+		struct rslab *slab = rlist_first_entry(&region->slabs.slabs,
+						       struct rslab,
+						       slab.next_in_list);
 		region->slabs.stats.used -= slab->used;
 		slab->used = 0;
 	}
-- 
2.22.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-30 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29  8:06 [Tarantool-patches] [small] Revert "Free all slabs on region reset" Alexander Turenko
2020-01-29  9:59 ` Kirill Yukhin
2020-01-29 21:41 ` Konstantin Osipov
2020-01-30  7:23   ` Alexander Turenko
2020-01-30  8:21     ` Konstantin Osipov
2020-01-30 11:03       ` Alexander Turenko
2020-01-30 12:16         ` Konstantin Osipov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox