continue to release span until the end of one round.

This commit is contained in:
liqingqing_1229 2021-12-30 11:58:38 +08:00
parent e6e11389e8
commit 74b2ef0f96
2 changed files with 62 additions and 10 deletions

View File

@ -0,0 +1,47 @@
From 18140cf69462a5036e46852707cadbed7156d3ca Mon Sep 17 00:00:00 2001
From: Qingqing Li <liqingqing3@huawei.com>
Date: Tue, 28 Dec 2021 08:51:54 +0800
Subject: [PATCH] Continue to release span until the end of one round. This is
also sync from the google/tcmalloc project.
upstream link: https://github.com/gperftools/gperftools/pull/1320
---
src/page_heap.cc | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/page_heap.cc b/src/page_heap.cc
index 44ad654..68c5416 100644
--- a/src/page_heap.cc
+++ b/src/page_heap.cc
@@ -483,11 +483,18 @@ Length PageHeap::ReleaseSpan(Span* s) {
Length PageHeap::ReleaseAtLeastNPages(Length num_pages) {
Length released_pages = 0;
+ Length prev_released_pages = 1;
// Round robin through the lists of free spans, releasing a
// span from each list. Stop after releasing at least num_pages
// or when there is nothing more to release.
while (released_pages < num_pages && stats_.free_bytes > 0) {
+ if (released_pages == prev_released_pages) {
+ // Last iteration of while loop made no progress.
+ break;
+ }
+ prev_released_pages = released_pages;
+
for (int i = 0; i < kMaxPages+1 && released_pages < num_pages;
i++, release_index_++) {
Span *s;
@@ -510,8 +517,6 @@ Length PageHeap::ReleaseAtLeastNPages(Length num_pages) {
// large freelist, should we carve s instead of releasing?
// the whole thing?
Length released_len = ReleaseSpan(s);
- // Some systems do not support release
- if (released_len == 0) return released_pages;
released_pages += released_len;
}
}
--
1.8.3.1

View File

@ -1,19 +1,20 @@
Name: gperftools
Version: 2.9.1
Release: 2
Release: 3
Summary: high-performance malloc and performance analysis tools
License: BSD
URL: https://github.com/gperftools/gperftools
Source0: https://github.com/gperftools/gperftools/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
patch1: gperftools-generic-dynamic-tls.patch
Patch9000: issue-1122-fix-bus-error-on-aarch64.patch
#https://github.com/gperftools/gperftools/issues/1309
Patch9001: skip-arm-in-stacktrace_unittest.patch
#https://github.com/gperftools/gperftools/issues/890
Patch9002: skip-heapchecker-in-arm-arch.patch
Patch9003: avoid-exceed-int-range.patch
Patch9004: skip-tcm_asserts_unittest.patch
Patch1: gperftools-generic-dynamic-tls.patch
Patch9000: issue-1122-fix-bus-error-on-aarch64.patch
Patch9001: skip-arm-in-stacktrace_unittest.patch
Patch9002: skip-heapchecker-in-arm-arch.patch
Patch9003: avoid-exceed-int-range.patch
Patch9004: skip-tcm_asserts_unittest.patch
Patch9005: Continue-to-release-span-until-the-end-of-one-round.patch
BuildRequires: autoconf automake gcc-c++
BuildRequires: libtool libunwind-devel perl-generators
@ -76,7 +77,7 @@ CXXFLAGS=`echo $RPM_OPT_FLAGS -fno-strict-aliasing -Wno-unused-local-typedefs -D
%disable_rpath
make
make %{?_smp_mflags}
%check
LD_LIBRARY_PATH=./.libs make check
@ -108,6 +109,10 @@ LD_LIBRARY_PATH=./.libs make check
%{_mandir}/man1/*.1.gz
%changelog
* Tue Jan 11 2021 QingqingLi <liqingqing3@huawei.com> - 2.9.1-3
- continue to release span until the end of one round
- use %{?_smp_mflags} to build
* Mon Jan 10 2021 zhangyiru <zhangyiru3@huawei.com> - 2.9.1-2
- skip stacktrace_unittest & tcm_asserts_unittest