mirror of https://gitee.com/bigwinds/arangodb
preparation for index watermarks
This commit is contained in:
parent
902841f5c1
commit
282e13afb4
|
@ -33,7 +33,7 @@
|
|||
#include "Basics/Common.h"
|
||||
#include "Basics/AttributeNameParser.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Indexes/IndexWatermarks.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/shaped-json.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
@ -59,12 +59,10 @@ typedef struct TRI_index_search_value_s {
|
|||
}
|
||||
TRI_index_search_value_t;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct index_element
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Unified index element. Do not directly construct it.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -140,13 +138,13 @@ struct TRI_index_element_t {
|
|||
|
||||
};
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class Index
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
||||
class Index {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief index watermarks
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_INDEXES_INDEXWATERMARKS_H
|
||||
#define ARANGODB_INDEXES_INDEXWATERMARKS_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- struct IndexWatermarks
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
||||
struct IndexWatermarks {
|
||||
IndexWatermarks ()
|
||||
: initialFillFactor(0.5),
|
||||
lowWatermark(0.0),
|
||||
highWatermark(0.66) {
|
||||
}
|
||||
|
||||
double initialFillFactor;
|
||||
double lowWatermark;
|
||||
double highWatermark;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -28,6 +28,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "PathBasedIndex.h"
|
||||
#include "Basics/logging.h"
|
||||
|
||||
using namespace triagens::arango;
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "Dispatcher/Dispatcher.h"
|
||||
#include "HttpServer/ApplicationEndpointServer.h"
|
||||
#include "HttpServer/AsyncJobManager.h"
|
||||
#include "HttpServer/HttpHandlerFactory.h"
|
||||
#include "Rest/InitializeRest.h"
|
||||
#include "Rest/OperationMode.h"
|
||||
#include "Rest/Version.h"
|
||||
|
@ -379,7 +380,8 @@ ArangoServer::ArangoServer (int argc, char** argv)
|
|||
_pairForAqlHandler(nullptr),
|
||||
_pairForJobHandler(nullptr),
|
||||
_indexPool(nullptr),
|
||||
_threadAffinity(0) {
|
||||
_threadAffinity(0),
|
||||
_defaultIndexWatermarks() {
|
||||
|
||||
TRI_SetApplicationName("arangod");
|
||||
|
||||
|
@ -423,43 +425,6 @@ ArangoServer::~ArangoServer () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ArangoServer::buildApplicationServer () {
|
||||
// detect alignment settings for ARM
|
||||
{
|
||||
#ifdef __arm__
|
||||
// To change the alignment trap behavior, simply echo a number into
|
||||
// /proc/cpu/alignment. The number is made up from various bits:
|
||||
//
|
||||
// bit behavior when set
|
||||
// --- -----------------
|
||||
//
|
||||
// 0 A user process performing an unaligned memory access
|
||||
// will cause the kernel to print a message indicating
|
||||
// process name, pid, pc, instruction, address, and the
|
||||
// fault code.
|
||||
//
|
||||
// 1 The kernel will attempt to fix up the user process
|
||||
// performing the unaligned access. This is of course
|
||||
// slow (think about the floating point emulator) and
|
||||
// not recommended for production use.
|
||||
//
|
||||
// 2 The kernel will send a SIGBUS signal to the user process
|
||||
// performing the unaligned access.
|
||||
std::string const filename("/proc/cpu/alignment");
|
||||
|
||||
try {
|
||||
std::string cpuAlignment = triagens::basics::FileUtils::slurp("/proc/cpu/alignment");
|
||||
int64_t alignment = std::stol(cpuAlignment);
|
||||
if ((alignment & 2) == 0) {
|
||||
LOG_WARNING("possibly incompatible CPU alignment settings found in '%s'. this may cause arangod to abort with SIGBUS. it may be necessary to set the value of '%s' to 2");
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// ignore that we cannot detect the alignment
|
||||
LOG_TRACE("unable to detect CPU alignment settings. could not process file '%s'", filename.c_str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
_applicationServer = new ApplicationServer("arangod", "[<options>] <database-directory>", rest::Version::getDetailed());
|
||||
|
||||
string conf = TRI_BinaryName(_argv[0]) + ".conf";
|
||||
|
@ -632,6 +597,11 @@ void ArangoServer::buildApplicationServer () {
|
|||
("database.query-cache-max-results", &_queryCacheMaxResults, "maximum number of results in query cache per database")
|
||||
("database.index-threads", &_indexThreads, "threads to start for parallel background index creation")
|
||||
("database.throw-collection-not-loaded-error", &_throwCollectionNotLoadedError, "throw an error when accessing a collection that is still loading")
|
||||
/*
|
||||
("database.index-initial-fill-factor", &_defaultIndexWatermarks.initialFillFactor, "the initial fill factor for hash and edge indexes")
|
||||
("database.index-low-watermark", &_defaultIndexWatermarks.lowWatermark, "low watermark for hash and edge indexes")
|
||||
("database.index-high-watermark", &_defaultIndexWatermarks.highWatermark, "high watermark for hash and edge indexes")
|
||||
*/
|
||||
;
|
||||
|
||||
// .............................................................................
|
||||
|
@ -758,6 +728,76 @@ void ArangoServer::buildApplicationServer () {
|
|||
LOG_INFO("please use the '--database.directory' option");
|
||||
LOG_FATAL_AND_EXIT("no database path has been supplied, giving up");
|
||||
}
|
||||
|
||||
#ifdef __arm__
|
||||
// detect alignment settings for ARM
|
||||
{
|
||||
// To change the alignment trap behavior, simply echo a number into
|
||||
// /proc/cpu/alignment. The number is made up from various bits:
|
||||
//
|
||||
// bit behavior when set
|
||||
// --- -----------------
|
||||
//
|
||||
// 0 A user process performing an unaligned memory access
|
||||
// will cause the kernel to print a message indicating
|
||||
// process name, pid, pc, instruction, address, and the
|
||||
// fault code.
|
||||
//
|
||||
// 1 The kernel will attempt to fix up the user process
|
||||
// performing the unaligned access. This is of course
|
||||
// slow (think about the floating point emulator) and
|
||||
// not recommended for production use.
|
||||
//
|
||||
// 2 The kernel will send a SIGBUS signal to the user process
|
||||
// performing the unaligned access.
|
||||
bool alignmentDetected = false;
|
||||
|
||||
std::string const filename("/proc/cpu/alignment");
|
||||
try {
|
||||
std::string const cpuAlignment = triagens::basics::FileUtils::slurp(filename);
|
||||
auto start = cpuAlignment.find("User faults:");
|
||||
|
||||
if (start != std::string::npos) {
|
||||
start += strlen("User faults:");
|
||||
size_t end = start;
|
||||
while (end < cpuAlignment.size()) {
|
||||
if (cpuAlignment[end] == ' ' || cpuAlignment[end] == '\t') {
|
||||
++end;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (end < cpuAlignment.size()) {
|
||||
++end;
|
||||
if (cpuAlignment[end] < '0' || cpuAlignment[end] > '9') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t alignment = std::stol(std::string(cpuAlignment.c_str() + start, end - start));
|
||||
if ((alignment & 2) == 0) {
|
||||
LOG_WARNING("possibly incompatible CPU alignment settings found in '%s'. this may cause arangod to abort with SIGBUS. it may be necessary to set the value in '%s' to 2",
|
||||
filename.c_str(),
|
||||
filename.c_str());
|
||||
}
|
||||
|
||||
alignmentDetected = true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (...) {
|
||||
// ignore that we cannot detect the alignment
|
||||
LOG_TRACE("unable to detect CPU alignment settings. could not process file '%s'", filename.c_str());
|
||||
}
|
||||
|
||||
if (! alignmentDetected) {
|
||||
LOG_WARNING("unable to detect CPU alignment settings. could not process file '%s'. this may cause arangod to abort with SIGBUS. it may be necessary to set the value in '%s' to 2",
|
||||
filename.c_str(),
|
||||
filename.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// strip trailing separators
|
||||
_databasePath = StringUtils::rTrim(_databasePath, TRI_DIR_SEPARATOR_STR);
|
||||
|
|
|
@ -36,12 +36,11 @@
|
|||
#include "Basics/win-utils.h"
|
||||
#endif
|
||||
|
||||
#include "Aql/QueryRegistry.h"
|
||||
#include "Indexes/IndexWatermarks.h"
|
||||
#include "Rest/AnyServer.h"
|
||||
#include "Rest/OperationMode.h"
|
||||
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "HttpServer/HttpHandlerFactory.h"
|
||||
#include "Aql/QueryRegistry.h"
|
||||
|
||||
struct TRI_server_t;
|
||||
struct TRI_vocbase_defaults_s;
|
||||
|
@ -61,6 +60,7 @@ namespace triagens {
|
|||
class ApplicationScheduler;
|
||||
class AsyncJobManager;
|
||||
class Dispatcher;
|
||||
class HttpHandlerFactory;
|
||||
class HttpServer;
|
||||
class HttpsServer;
|
||||
}
|
||||
|
@ -721,6 +721,12 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t _threadAffinity;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief default watermarks for indexes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
triagens::arango::IndexWatermarks _defaultIndexWatermarks;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue