Skip to content

Commit

Permalink
*: Support generating adhoc heap profiling in svg format (pingcap#9273)…
Browse files Browse the repository at this point in the history
… (pingcap#252)

Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo authored Aug 1, 2024
1 parent 5c231da commit a69bcfc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbms/src/Storages/KVStore/tests/gtest_async_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ TEST(AsyncTasksTest, AsyncTasksCommon)
auto async_tasks = std::make_unique<TestAsyncTasks>(1, 1, 2);

int total = 5;
int max_steps = 10;
int max_steps = 15;
int current_step = 0;
std::vector<bool> f(total, false);
std::vector<bool> s(total, false);
Expand Down
10 changes: 10 additions & 0 deletions dbms/src/Storages/Page/V3/Universal/UniversalWriteBatchImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR;
} // namespace ErrorCodes

namespace tests
{
class UniPageStorageIdTest;
}

class UniversalWriteBatch : private boost::noncopyable
{
private:
Expand Down Expand Up @@ -266,6 +271,7 @@ class UniversalWriteBatch : private boost::noncopyable
void merge(UniversalWriteBatch & rhs)
{
writes.reserve(writes.size() + rhs.writes.size());
PS::PageStorageMemorySummary::universal_write_count.fetch_add(rhs.writes.size());
for (const auto & r : rhs.writes)
{
writes.emplace_back(r);
Expand All @@ -276,6 +282,7 @@ class UniversalWriteBatch : private boost::noncopyable

[[clang::reinitializes]] void clear()
{
PS::PageStorageMemorySummary::universal_write_count.fetch_sub(writes.size());
Writes tmp;
writes.swap(tmp);
total_data_size = 0;
Expand All @@ -302,6 +309,9 @@ class UniversalWriteBatch : private boost::noncopyable
std::swap(remote_lock_disabled, o.remote_lock_disabled);
}

private:
friend class UniPageStorageIdTest;

private:
String prefix;
Writes writes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,50 @@ TEST(UniPageStorageIdTest, UniversalWriteBatchMemory)
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 1);
}
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 0);
{
UniversalWriteBatch wb;
wb.putPage(
UniversalPageIdFormat::toFullPageId(prefix, 0),
tag,
std::make_shared<ReadBufferFromMemory>(c_buff, buf_sz),
buf_sz);
UniversalWriteBatch wb2;
wb2.merge(wb);
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 2);
}
{
UniversalWriteBatch wb;
wb.putPage(
UniversalPageIdFormat::toFullPageId(prefix, 0),
tag,
std::make_shared<ReadBufferFromMemory>(c_buff, buf_sz),
buf_sz);
wb.clear();
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 0);
}
{
UniversalWriteBatch wb;
wb.putPage(
UniversalPageIdFormat::toFullPageId(prefix, 0),
tag,
std::make_shared<ReadBufferFromMemory>(c_buff, buf_sz),
buf_sz);
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 1);
UniversalWriteBatch wb2;
wb.putPage(
UniversalPageIdFormat::toFullPageId(prefix, 1),
tag,
std::make_shared<ReadBufferFromMemory>(c_buff, buf_sz),
buf_sz);
wb.putPage(
UniversalPageIdFormat::toFullPageId(prefix, 2),
tag,
std::make_shared<ReadBufferFromMemory>(c_buff, buf_sz),
buf_sz);
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 3);
wb.swap(wb2);
ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 3);
}
}

} // namespace PS::universal::tests
Expand Down

0 comments on commit a69bcfc

Please sign in to comment.