aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lfalloc
diff options
context:
space:
mode:
authorasorotsky <asorotsky@yandex-team.ru>2022-02-10 16:47:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:33 +0300
commiteb540cc7a103419462d0cc870ca403966e2194c6 (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/lfalloc
parent80f0a6b4102e3b2c89f23935c7690409033ea24c (diff)
downloadydb-eb540cc7a103419462d0cc870ca403966e2194c6.tar.gz
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/lfalloc')
-rw-r--r--library/cpp/lfalloc/alloc_profiler/align_ut.cpp46
-rw-r--r--library/cpp/lfalloc/alloc_profiler/profiler.cpp2
-rw-r--r--library/cpp/lfalloc/alloc_profiler/stackcollect.cpp2
-rw-r--r--library/cpp/lfalloc/alloc_profiler/ut/ya.make2
-rw-r--r--library/cpp/lfalloc/lf_allocX64.h100
5 files changed, 76 insertions, 76 deletions
diff --git a/library/cpp/lfalloc/alloc_profiler/align_ut.cpp b/library/cpp/lfalloc/alloc_profiler/align_ut.cpp
index 1b62fe73b7..db9b17b95b 100644
--- a/library/cpp/lfalloc/alloc_profiler/align_ut.cpp
+++ b/library/cpp/lfalloc/alloc_profiler/align_ut.cpp
@@ -1,23 +1,23 @@
-#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/scope.h>
-
-Y_UNIT_TEST_SUITE(MemAlign) {
- Y_UNIT_TEST(ShouldAlign)
- {
- for (ui64 size = 8; size <= 32 * 1024; size *= 8) {
- for (ui64 align = 8; align <= 4096; align *=2) {
- void* ptr = nullptr;
-
- int res = posix_memalign(&ptr, align, size);
- UNIT_ASSERT_C(res == 0 && ptr != nullptr, "memalign failed");
-
- Y_DEFER {
- free(ptr);
- };
-
- UNIT_ASSERT_C((uintptr_t)ptr % align == 0, "non aligned memory");
- }
- }
- }
-}
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <util/generic/scope.h>
+
+Y_UNIT_TEST_SUITE(MemAlign) {
+ Y_UNIT_TEST(ShouldAlign)
+ {
+ for (ui64 size = 8; size <= 32 * 1024; size *= 8) {
+ for (ui64 align = 8; align <= 4096; align *=2) {
+ void* ptr = nullptr;
+
+ int res = posix_memalign(&ptr, align, size);
+ UNIT_ASSERT_C(res == 0 && ptr != nullptr, "memalign failed");
+
+ Y_DEFER {
+ free(ptr);
+ };
+
+ UNIT_ASSERT_C((uintptr_t)ptr % align == 0, "non aligned memory");
+ }
+ }
+ }
+}
diff --git a/library/cpp/lfalloc/alloc_profiler/profiler.cpp b/library/cpp/lfalloc/alloc_profiler/profiler.cpp
index b4f92fe0db..0e30927a5a 100644
--- a/library/cpp/lfalloc/alloc_profiler/profiler.cpp
+++ b/library/cpp/lfalloc/alloc_profiler/profiler.cpp
@@ -1,5 +1,5 @@
#include "profiler.h"
-
+
#include "stackcollect.h"
#include <util/generic/algorithm.h>
diff --git a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp
index 643fd1ccda..fded4e2fd1 100644
--- a/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp
+++ b/library/cpp/lfalloc/alloc_profiler/stackcollect.cpp
@@ -1,5 +1,5 @@
#include "stackcollect.h"
-
+
#include "profiler.h"
#include <util/generic/algorithm.h>
diff --git a/library/cpp/lfalloc/alloc_profiler/ut/ya.make b/library/cpp/lfalloc/alloc_profiler/ut/ya.make
index 9b93752823..8a7daa74af 100644
--- a/library/cpp/lfalloc/alloc_profiler/ut/ya.make
+++ b/library/cpp/lfalloc/alloc_profiler/ut/ya.make
@@ -16,7 +16,7 @@ ENDIF()
SRCS(
profiler_ut.cpp
- align_ut.cpp
+ align_ut.cpp
)
END()
diff --git a/library/cpp/lfalloc/lf_allocX64.h b/library/cpp/lfalloc/lf_allocX64.h
index 70f3758ebf..fd2a906d6f 100644
--- a/library/cpp/lfalloc/lf_allocX64.h
+++ b/library/cpp/lfalloc/lf_allocX64.h
@@ -1089,7 +1089,7 @@ struct TLocalPerTagAllocCounter {
};
static const int DBG_ALLOC_MAX_TAG = 1000;
-static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000;
+static const int DBG_ALLOC_ALIGNED_TAG = 0xF0000000;
static const int DBG_ALLOC_NUM_SIZES = 30;
static TPerTagAllocCounter GlobalPerTagAllocCounters[DBG_ALLOC_MAX_TAG][DBG_ALLOC_NUM_SIZES];
@@ -1307,25 +1307,25 @@ static void AllocThreadInfo() {
#if defined(LFALLOC_DBG)
struct TAllocHeader {
- uint64_t Size;
+ uint64_t Size;
int Tag;
int Cookie;
};
-// should be power of 2
-static_assert(sizeof(TAllocHeader) == 16);
-
+// should be power of 2
+static_assert(sizeof(TAllocHeader) == 16);
+
static inline void* GetAllocPtr(TAllocHeader* p) {
return p + 1;
}
static inline TAllocHeader* GetAllocHeader(void* p) {
- auto* header = ((TAllocHeader*)p) - 1;
- if (header->Tag == DBG_ALLOC_ALIGNED_TAG) {
- return (TAllocHeader*)header->Size;
- }
-
- return header;
+ auto* header = ((TAllocHeader*)p) - 1;
+ if (header->Tag == DBG_ALLOC_ALIGNED_TAG) {
+ return (TAllocHeader*)header->Size;
+ }
+
+ return header;
}
PERTHREAD int AllocationTag;
@@ -1882,45 +1882,45 @@ static Y_FORCE_INLINE int LFPosixMemalign(void** memptr, size_t alignment, size_
} else if (bigsize < 2 * alignment) {
bigsize = 2 * alignment;
}
-#if defined(LFALLOC_DBG)
- if (alignment > sizeof(TAllocHeader)) {
- bigsize += alignment;
- }
-#endif
-
+#if defined(LFALLOC_DBG)
+ if (alignment > sizeof(TAllocHeader)) {
+ bigsize += alignment;
+ }
+#endif
+
*memptr = LFAlloc(bigsize);
-
-#if defined(LFALLOC_DBG)
- if (alignment > sizeof(TAllocHeader)) {
- // memptr isn't aligned due to alloc header
- const auto* header = GetAllocHeader(*memptr);
- *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader));
-
- // make fake header to retrieve original header ptr on dealloc
- auto* next = GetAllocHeader(*memptr);
- next->Tag = DBG_ALLOC_ALIGNED_TAG;
- next->Size = (uint64_t)header;
- next->Cookie = 0;
- }
-#endif
-
- Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0);
+
+#if defined(LFALLOC_DBG)
+ if (alignment > sizeof(TAllocHeader)) {
+ // memptr isn't aligned due to alloc header
+ const auto* header = GetAllocHeader(*memptr);
+ *memptr = (void*)((const char*) (*memptr) + alignment - sizeof(TAllocHeader));
+
+ // make fake header to retrieve original header ptr on dealloc
+ auto* next = GetAllocHeader(*memptr);
+ next->Tag = DBG_ALLOC_ALIGNED_TAG;
+ next->Size = (uint64_t)header;
+ next->Cookie = 0;
+ }
+#endif
+
+ Y_ASSERT_NOBT((intptr_t)*memptr % alignment == 0);
return 0;
}
-
-static Y_FORCE_INLINE void* LFVAlloc(size_t size) {
- const size_t pg = N_PAGE_SIZE;
- void* p = nullptr;
-
-#if defined(LFALLOC_DBG)
- LFPosixMemalign(&p, pg, size);
-#else
- size_t bigsize = (size + pg - 1) & (~(pg - 1));
- p = LFAlloc(bigsize);
-#endif
-
- Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0);
- return p;
-}
-
-#endif
+
+static Y_FORCE_INLINE void* LFVAlloc(size_t size) {
+ const size_t pg = N_PAGE_SIZE;
+ void* p = nullptr;
+
+#if defined(LFALLOC_DBG)
+ LFPosixMemalign(&p, pg, size);
+#else
+ size_t bigsize = (size + pg - 1) & (~(pg - 1));
+ p = LFAlloc(bigsize);
+#endif
+
+ Y_ASSERT_NOBT((intptr_t)p % N_PAGE_SIZE == 0);
+ return p;
+}
+
+#endif