From 1ae150d90a9b4ec71bc927eb3a39813720f9d244 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Sat, 1 Nov 2014 21:02:00 +0100 Subject: [PATCH 1/3] control number of v8 contexts independently from number of server threads added command-line option `--javascript.v8-contexts` to control the number of V8 contexts created in arangod. Previously, the number of V8 contexts was equal to the number of server threads (as specified by option `--server.threads`). However, it may be sensible to create different amounts of threads and V8 contexts. If the option is not specified, the number of V8 contexts created will be equal to the number of server threads. Thus no change in configuration is required to keep the old behavior. --- CHANGELOG | 10 ++++++++++ arangod/RestServer/ArangoServer.cpp | 24 ++++++++++++++++++------ arangod/RestServer/ArangoServer.h | 23 +++++++++++++++++++---- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2821033608..29062a0961 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ v2.3.0 (XXXX-XX-XX) ------------------- +* added command-line option `--javascript.v8-contexts` to control the number of + V8 contexts created in arangod. + + Previously, the number of V8 contexts was equal to the number of server threads + (as specified by option `--server.threads`). However, it may be sensible to + create different amounts of threads and V8 contexts. If the option is not + specified, the number of V8 contexts created will be equal to the number of + server threads. Thus no change in configuration is required to keep the old + behavior. + * removed bitarray indexes * removed internal "_admin/modules/flush" in order to fix requireApp diff --git a/arangod/RestServer/ArangoServer.cpp b/arangod/RestServer/ArangoServer.cpp index 8830ff2fc9..ed7282a19f 100644 --- a/arangod/RestServer/ArangoServer.cpp +++ b/arangod/RestServer/ArangoServer.cpp @@ -281,6 +281,7 @@ ArangoServer::ArangoServer (int argc, char** argv) _disableAuthenticationUnixSockets(false), _dispatcherThreads(8), _dispatcherQueueSize(8192), + _v8Contexts(8), _databasePath(), _defaultMaximalSize(TRI_JOURNAL_DEFAULT_MAXIMAL_SIZE), _defaultWaitForSync(false), @@ -560,6 +561,7 @@ void ArangoServer::buildApplicationServer () { additional["THREAD Options:help-admin"] ("server.threads", &_dispatcherThreads, "number of threads for basic operations") + ("javascript.v8-contexts", &_v8Contexts, "number of V8 contexts that are created for executing JavaScript actions") ; additional["Server Options:help-extended"] @@ -795,25 +797,35 @@ int ArangoServer::startupServer () { TRI_ASSERT(vocbase != nullptr); + // initialise V8 - size_t concurrency = _dispatcherThreads; + if (! _applicationServer->programOptions().has("javascript.v8-contexts")) { + // the option was added recently so it's not always set + // the behavior in older ArangoDB was to create one V8 context per dispatcher thread + _v8Contexts = _dispatcherThreads; + } + + if (_v8Contexts < 1) { + _v8Contexts = 1; + } if (mode == OperationMode::MODE_CONSOLE) { // one V8 instance is taken by the console if (startServer) { - ++concurrency; + ++_v8Contexts; } } else if (mode == OperationMode::MODE_UNITTESTS || mode == OperationMode::MODE_SCRIPT) { - if (concurrency == 1) { - // at least two to allow the test-runner and the scheduler to use a V8 - concurrency = 2; + if (_v8Contexts == 1) { + // at least two to allow both the test-runner and the scheduler to use a V8 instance + _v8Contexts = 2; } } _applicationV8->setVocbase(vocbase); - _applicationV8->setConcurrency(concurrency); + _applicationV8->setConcurrency(_v8Contexts); _applicationV8->defineDouble("DISPATCHER_THREADS", _dispatcherThreads); + _applicationV8->defineDouble("V8_CONTEXTS", _v8Contexts); // ............................................................................. // prepare everything diff --git a/arangod/RestServer/ArangoServer.h b/arangod/RestServer/ArangoServer.h index 3bff12ac35..bd8d3dcc8a 100644 --- a/arangod/RestServer/ArangoServer.h +++ b/arangod/RestServer/ArangoServer.h @@ -317,12 +317,12 @@ namespace triagens { bool _disableAuthenticationUnixSockets; //////////////////////////////////////////////////////////////////////////////// -/// @brief number of dispatcher threads for non-database worker +/// @brief number of dispatcher threads /// @startDocuBlock serverThreads /// `--server.threads number` /// -/// Specifies the *number* of threads that are spawned to handle action -/// requests using Rest, JavaScript, or Ruby. +/// Specifies the *number* of threads that are spawned to handle HTTP REST +/// requests. /// @endDocuBlock //////////////////////////////////////////////////////////////////////////////// @@ -330,7 +330,7 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// /// @brief maximum size of the dispatcher queue for asynchronous requests -/// @startDocuBlock serverAuthenticationDisable +/// @startDocuBlock schedulerMaximalQueueSize /// `--scheduler.maximal-queue-size size` /// /// Specifies the maximum *size* of the dispatcher queue for asynchronous @@ -343,6 +343,21 @@ namespace triagens { int _dispatcherQueueSize; +//////////////////////////////////////////////////////////////////////////////// +/// @brief number of V8 contexts for executing JavaScript actions +/// @startDocuBlock v8Contexts +/// `--server.v8-contexts number` +/// +/// Specifies the *number* of V8 contexts that are created for executing +/// JavaScript code. More contexts allow execute more JavaScript actions in +/// parallel, provided that there are also enough threads available. Please +/// note that each V8 context will use a substantial amount of memory and +/// requires periodic CPU processing time for garbage collection. +/// @endDocuBlock +//////////////////////////////////////////////////////////////////////////////// + + int _v8Contexts; + //////////////////////////////////////////////////////////////////////////////// /// @brief path to the database /// @startDocuBlock DatabaseDirectory From 432430632e4851564c0a1e36eedac67539066999 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Sat, 1 Nov 2014 21:03:30 +0100 Subject: [PATCH 2/3] documentation fixes --- .../Books/Users/Arangosh/Configuration.mdpp | 4 ++-- .../Books/Users/ConfigureArango/Arangod.mdpp | 12 ++++++++-- .../Users/ConfigureArango/Communication.mdpp | 8 +++---- .../ConfigureArango/EmergencyConsole.mdpp | 16 ++++++------- .../Users/ConfigureArango/RandomNumbers.mdpp | 4 ---- Documentation/Books/Users/SUMMARY.md | 3 +-- README.md | 24 ++++++++++++------- 7 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 Documentation/Books/Users/ConfigureArango/RandomNumbers.mdpp diff --git a/Documentation/Books/Users/Arangosh/Configuration.mdpp b/Documentation/Books/Users/Arangosh/Configuration.mdpp index 976f10ba10..4050395acf 100644 --- a/Documentation/Books/Users/Arangosh/Configuration.mdpp +++ b/Documentation/Books/Users/Arangosh/Configuration.mdpp @@ -8,7 +8,7 @@ You can use this to define your own extra variables and functions that you need For example, you could put the following into the *.arangosh.rc* file in your home directory: -``` +```js // var keyword omitted intentionally, // otherwise "timed" would not survive the scope of this script timed = function (cb) { @@ -23,7 +23,7 @@ This will make a function named *timed* available in _arangosh_ in the global sc You can now start _arangosh_ and invoke the function like this: -``` +```js timed(function () { for (var i = 0; i < 1000; ++i) { db.test.save({ value: i }); diff --git a/Documentation/Books/Users/ConfigureArango/Arangod.mdpp b/Documentation/Books/Users/ConfigureArango/Arangod.mdpp index 072076c76c..d33ca8409a 100644 --- a/Documentation/Books/Users/ConfigureArango/Arangod.mdpp +++ b/Documentation/Books/Users/ConfigureArango/Arangod.mdpp @@ -36,6 +36,10 @@ @startDocuBlock serverAllowMethod +!SUBSECTION Server threads +@startDocuBlock serverThreads + + !SUBSECTION Keyfile @startDocuBlock serverKeyfile @@ -64,12 +68,12 @@ @startDocuBlock serverBacklog -!SUBSECTION Disable statics +!SUBSECTION Disable statistics `--disable-statistics value` If this option is *value* is *true*, then ArangoDB's statistics gathering -is turned off. Statistics gathering causes constant CPU activity so using this +is turned off. Statistics gathering causes regular CPU activity so using this option to turn it off might relieve heavy-loaded instances. Note: this option is only available when ArangoDB has not been compiled with the option *--disable-figures*. @@ -90,6 +94,10 @@ the option *--disable-figures*. @startDocuBlock databaseForceSyncProperties +!SUBSECTION V8 Contexts +@startDocuBlock v8Contexts + + !SUBSECTION Frequency @startDocuBlock jsGcFrequency diff --git a/Documentation/Books/Users/ConfigureArango/Communication.mdpp b/Documentation/Books/Users/ConfigureArango/Communication.mdpp index 1bf5775e01..0e72ff7986 100644 --- a/Documentation/Books/Users/ConfigureArango/Communication.mdpp +++ b/Documentation/Books/Users/ConfigureArango/Communication.mdpp @@ -1,17 +1,17 @@ !CHAPTER Command-Line Options for Communication !SUBSECTION Scheduler threads - @startDocuBlock schedulerThreads + !SUBSECTION Scheduler maximal queue size - -@startDocuBlock serverAuthenticationDisable +@startDocuBlock schedulerMaximalQueueSize + !SUBSECTION Scheduler backend - @startDocuBlock schedulerBackend + !SUBSECTION Io backends `--show-io-backends` diff --git a/Documentation/Books/Users/ConfigureArango/EmergencyConsole.mdpp b/Documentation/Books/Users/ConfigureArango/EmergencyConsole.mdpp index ec661d2f1d..ee35ef7020 100644 --- a/Documentation/Books/Users/ConfigureArango/EmergencyConsole.mdpp +++ b/Documentation/Books/Users/ConfigureArango/EmergencyConsole.mdpp @@ -2,7 +2,7 @@ !SUBSECTION In Case Of Disaster -The following command starts a emergency console. +The following command starts an emergency console. **Note**: Never start the emergency console for a database which also has a server attached to it. In general the ArangoDB shell is what you want. @@ -14,18 +14,16 @@ ArangoDB shell [V8 version 3.9.4, DB version 1.x.y] arango> 1 + 2; 3 -arango> db.geo.count(); +arango> var db = require("org/arangodb").db; db.geo.count(); 703 ``` -The emergency console disables the HTTP interface of the server and -opens a JavaScript console on standard output instead. This allows you -to debug and examine collections and documents without interference -from the outside. In most respects the emergency console behaves like -the normal ArangoDB shell - but with exclusive access and no -client/server communication. +The emergency console provides a JavaScript console directly running in the +arangod server process. This allows to debug and examine collections and +documents as with the normal ArangoDB shell, but without client/server +communication. -However, it is very likely that you never need the emergency console +However, it is very likely that you will never need the emergency console unless you are an ArangoDB developer. diff --git a/Documentation/Books/Users/ConfigureArango/RandomNumbers.mdpp b/Documentation/Books/Users/ConfigureArango/RandomNumbers.mdpp deleted file mode 100644 index cbf474e783..0000000000 --- a/Documentation/Books/Users/ConfigureArango/RandomNumbers.mdpp +++ /dev/null @@ -1,4 +0,0 @@ -!SUBSECTION Command-Line Options for Random Numbers - - -@startDocuBlock randomGenerator \ No newline at end of file diff --git a/Documentation/Books/Users/SUMMARY.md b/Documentation/Books/Users/SUMMARY.md index 423a011f73..06821f0c0a 100644 --- a/Documentation/Books/Users/SUMMARY.md +++ b/Documentation/Books/Users/SUMMARY.md @@ -138,14 +138,13 @@ * [Authentication](Sharding/Authentication.md) * [Firewall setup](Sharding/FirewallSetup.md) -* [Configure ArangoDB](ConfigureArango/README.md) +* [Server Configuration](ConfigureArango/README.md) * [Arangod options](ConfigureArango/Arangod.md) * [Write-ahead log options](ConfigureArango/Wal.md) * [Endpoints options](ConfigureArango/Endpoint.md) * [Cluster options](ConfigureArango/Cluster.md) * [Logging options](ConfigureArango/Logging.md) * [Communication options](ConfigureArango/Communication.md) - * [Random numbers](ConfigureArango/RandomNumbers.md) * [Authentication](ConfigureArango/Authentication.md) * [Emergency Console](ConfigureArango/EmergencyConsole.md) diff --git a/README.md b/README.md index 8ab2d295de..8d8908d111 100644 --- a/README.md +++ b/README.md @@ -40,22 +40,28 @@ For Mac OSX users: execute For Windows and Linux users: use the installer script or distribution package from our [download page](http://www.arangodb.com/download). -If the package manager has not already started the ArangoDB server, use +If the package manager has not already started the ArangoDB server, use the +following command to start it. unix> /path/to/sbin/arangod 2012-03-30T12:54:19Z [11794] INFO ArangoDB (version 2.x.y) is ready for business 2012-03-30T12:54:19Z [11794] INFO Have Fun! -`/path/to/sbin` is OS dependent. It will normally by either `/usr/sbin` or `/user/local/sbin`. Point your browser to +`/path/to/sbin` is OS dependent. It will normally be either `/usr/sbin` or `/user/local/sbin`. + +To access ArangoDB in your browser, open the following URL http://localhost:8529/ -and select `Tools / JS Shell`. You can now use the Arango shell from within your browser. Alternative, it is available as command-line tool _arangosh_. +and select `Tools / JS Shell`. You can now use the Arango shell from within your browser. + +Alternatively, a scriptable shell is available as a command-line tool _arangosh_. arangosh> db._create("hello"); arangosh> db.hello.save({ world: "earth" }); -Congratulations! You have created your first collection called `hello` and your first document. To verify your achievements, type: +Congratulations! You have created your first collection named `hello` and your first document. +To verify your achievements, type: arangosh> db.hello.toArray(); @@ -64,15 +70,15 @@ More Information ---------------- Please check the -[Installation Manual](http://www.arangodb.com/manuals/current/InstallManual.html) +[Installation Manual](https://www.arangodb.com/Installing/README.html) for installation and compilation instructions. The -[User Manual](http://www.arangodb.com/manuals/current/UserManual.html) +[User Manual](https://www.arangodb.com/FirstSteps/README.html) has an introductory chapter showing the basic operations of ArangoDB. Or you can use the -[online tutorial](http://www.arangodb.com/try) +[online tutorial](https://www.arangodb.com/tryitout) to play with ArangoDB without installing it locally. @@ -86,7 +92,7 @@ you report them: You can use the Google group for improvements, feature requests, comments -[http://www.arangodb.com/community](http://www.arangodb.com/community) +[http://www.arangodb.com/community](https://www.arangodb.com/community) Citing ArangoDB @@ -96,7 +102,7 @@ Please kindly cite ArangoDB in your publications if it helps your research: ```bibtex @misc{ArangoDB2014, Author = {ArangoDB}, - Title = { {ArangoDB 2.2}: An Open Source multi-purpose database supporting flexible data models for documents, graphs, and key-values.}, + Title = { {ArangoDB 2.3}: An Open source, multi-purpose database supporting flexible data models for documents, graphs, and key-values.}, Year = {2014}, Howpublished = {\url{http://arangodb.com/} } From 749a0aa4088876f246f290219f989bb0b3f101f9 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Sat, 1 Nov 2014 21:52:17 +0100 Subject: [PATCH 3/3] fixed cloning of AST nodes --- arangod/Aql/Ast.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arangod/Aql/Ast.cpp b/arangod/Aql/Ast.cpp index ad8f33214f..e28bccae3e 100644 --- a/arangod/Aql/Ast.cpp +++ b/arangod/Aql/Ast.cpp @@ -1018,20 +1018,25 @@ AstNode* Ast::clone (AstNode const* node) { } else if (type == NODE_TYPE_VALUE) { switch (node->value.type) { + case VALUE_TYPE_NULL: + copy->value.type = VALUE_TYPE_NULL; + break; case VALUE_TYPE_BOOL: + copy->value.type = VALUE_TYPE_BOOL; copy->setBoolValue(node->getBoolValue()); break; case VALUE_TYPE_INT: + copy->value.type = VALUE_TYPE_INT; copy->setIntValue(node->getIntValue()); break; case VALUE_TYPE_DOUBLE: + copy->value.type = VALUE_TYPE_DOUBLE; copy->setDoubleValue(node->getDoubleValue()); break; case VALUE_TYPE_STRING: + copy->value.type = VALUE_TYPE_STRING; copy->setStringValue(node->getStringValue()); break; - default: { - } } }