hiperf部件不合规修改

Signed-off-by: mashaohua7 <mashaohua7@huawei.com>
This commit is contained in:
mashaohua7 2023-05-24 14:23:29 +08:00
parent 29d5062be4
commit d97462fc4d
4 changed files with 26 additions and 5 deletions

View File

@ -326,11 +326,6 @@ public:
static constexpr uint64_t DEFAULT_SAMPLE_PERIOD = 1;
static constexpr uint64_t DEFAULT_TIMEOUT = 10 * 1000;
static constexpr size_t MIN_BUFFER_SIZE = 64 * 1024 * 1024;
#ifdef LITTLE_MEMORY
static constexpr size_t MAX_BUFFER_SIZE = 128 * 1024 * 1024;
#else
static constexpr size_t MAX_BUFFER_SIZE = 256 * 1024 * 1024;
#endif
static constexpr size_t BUFFER_LOW_LEVEL = 10 * 1024 * 1024;
static constexpr size_t BUFFER_CRITICAL_LEVEL = 5 * 1024 * 1024;

View File

@ -73,6 +73,9 @@ constexpr const int HUNDREDS = 100;
constexpr const int DEFAULT_STRING_BUF_SIZE = 4096;
constexpr const int FIVE_THOUSANDS = 5000;
constexpr const int DATA_MAX_SIZE = 1001;
constexpr const int LITTLE_MEMORY_SIZE = 1;
constexpr const int MULTIPLE_SIZE = 1024;
#if !is_mingw
#ifndef O_BINARY
#define O_BINARY 0
@ -209,6 +212,8 @@ bool IsDir(const std::string &path);
bool IsPath(const std::string &fileName);
bool LittleMemory();
#if is_mingw
const char PATH_SEPARATOR = '\\';
#else

View File

@ -1096,6 +1096,13 @@ std::vector<AttrWithId> PerfEvents::GetAttrWithId() const
size_t PerfEvents::CalcBufferSize()
{
static int MAX_BUFFER_SIZE;
if (LittleMemory()) {
MAX_BUFFER_SIZE = 128 * 1024 * 1024;
}else {
MAX_BUFFER_SIZE = 256 * 1024 * 1024;
}
size_t bufferSize = MAX_BUFFER_SIZE;
if (!systemTarget_) {
// suppose ring buffer is 4 times as much as mmap

View File

@ -670,6 +670,20 @@ const std::string GetUserType()
#endif
}
bool LittleMemory() {
std::ifstream file("/proc/meminfo");
std::string line;
while (getline(file, line)) {
if (line.find("MemTotal:") != std::string::npos) {
int memSize = stoi(line.substr(line.find(":") + 1));
if (memSize < (LITTLE_MEMORY_SIZE * MULTIPLE_SIZE * MULTIPLE_SIZE)) {
return true;
}
}
}
return false;
}
// only for domestic beta
bool IsBeta()
{