8000 Implement memory detection override. by neunhoef · Pull Request #11268 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Implement memory detection override. #11268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
devel
-----


* Allow to override the detected total amount of memory via an environment
variable ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY.

* `splice-subqueries` optimization is not limited by any type of operation within the
subquery any more. It can now be applied on every subquery and will be by default.
However they may be a performance impact on some queries where splice-subqueries
Expand Down
9 changes: 9 additions & 0 deletions 10000 lib/ApplicationFeatures/EnvironmentFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ void EnvironmentFeature::prepare() {
// file not found or value not convertible into integer
}

// Report memory found:
uint64_t ram = PhysicalMemory::getValue();
std::string overriddenmsg;
if (PhysicalMemory::overridden()) {
overriddenmsg = " (overridden by environment variable)";
}
LOG_TOPIC("25362", INFO, Logger::MEMORY)
<< "Available physical memory: " << ram << overriddenmsg;

// test local ipv6 support
try {
if (!basics::FileUtils::exists("/proc/net/if_inet6")) {
Expand Down
35 changes: 32 additions & 3 deletions lib/Basics/PhysicalMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "Basics/operating-system.h"

#include "Basics/PhysicalMemory.h"
#include "Basics/StringUtils.h"
#include "Basics/files.h"

#ifdef TRI_HAVE_UNISTD_H
#include <unistd.h>
Expand Down Expand Up @@ -90,10 +92,32 @@ uint64_t physicalMemoryImpl() {
#endif
#endif


struct PhysicalMemoryCache {
PhysicalMemoryCache() : cachedValue(physicalMemoryImpl()) {}
uint64_t const cachedValue;
PhysicalMemoryCache() : cachedValue(physicalMemoryImpl()), overridden(false) {
std::string value;
if (TRI_GETENV("ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY", value)) {
if (!value.empty()) {
uint64_t multiplier = 1;
if (value.back() == 'G' || value.back() == 'g') {
multiplier = 1024*1024*1024;
value.pop_back();
} else if (value.back() == 'M' || value.back() == 'm') {
multiplier = 1024 * 1024;
value.pop_back();
} else if (value.back() == 'K' || value.back() == 'k') {
multiplier = 1024;
value.pop_back();
}
uint64_t v = arangodb::basics::StringUtils::uint64(value) * multiplier;
if (v != 0) {
cachedValue = v;
overridden = true;
}
}
}
}
uint64_t cachedValue;
bool overridden;
};

PhysicalMemoryCache const cache;
FF30 Expand All @@ -104,3 +128,8 @@ PhysicalMemoryCache const cache;
uint64_t arangodb::PhysicalMemory::getValue() {
return ::cache.cachedValue;
}

/// @brief return if physical memory size was overridden
bool arangodb::PhysicalMemory::overridden() {
return ::cache.overridden;
}
1 change: 1 addition & 0 deletions lib/Basics/PhysicalMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace PhysicalMemory {

/// @brief return system's physical memory
uint64_t getValue();
bool overridden();

}
} // namespace arangodb
Expand Down
2 changes: 1 addition & 1 deletion lib/Logger/LogTopic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ LogTopic Logger::GRAPHS("graphs", LogLevel::INFO);
LogTopic Logger::HEARTBEAT("heartbeat", LogLevel::INFO);
LogTopic Logger::HTTPCLIENT("httpclient", LogLevel::WARN);
LogTopic Logger::MAINTENANCE("maintenance", LogLevel::WARN);
LogTopic Logger::MEMORY("memory", LogLevel::WARN);
LogTopic Logger::MEMORY("memory", LogLevel::INFO);
LogTopic Logger::MMAP("mmap");
LogTopic Logger::PERFORMANCE("performance", LogLevel::WARN);
LogTopic Logger::PREGEL("pregel", LogLevel::INFO);
Expand Down
0