Browse Source

Merge remote-tracking branch 'upstream/master' into servlet3-cass

Conflicts:
	toolset/setup/linux/installer.py
	toolset/setup/linux/prerequisites.sh
marko asplund 10 years ago
parent
commit
05971d8c39

+ 1 - 0
deployment/vagrant-common/bootstrap.sh

@@ -90,6 +90,7 @@ if [ ! -e "~/.firstboot" ]; then
 
   # Install prerequisite tools
   echo "Installing prerequisites"
+  sudo apt-get update
   sudo apt-get install -y git
   sudo apt-get install -y python-pip
 

+ 13 - 1
deployment/vagrant-virtualbox/README.md

@@ -9,4 +9,16 @@ that modify how TFB launches your Virtuabox virtual machines.
 | `TFB_VB_SHOW`                    | `true,false`        | Show the VM in a window when running? Default is false
 | `TFB_VB_ARCH`                    | `64,32`             | Used to force TFB to run a 32-bit virtual machine. This is unsupported, as many of the framework binaries we download are 64-bit only and will not launch. If you cannot run a 64-bit VM, then we recommend using the Amazon AWS provider instead of using this variable
 | `TFB_VB_MEM`                     | `<number>` e.g. `2048` | Size of VM's RAM in MB. Default is `2048`
-| `TFB_VB_CPU`                     | `<number>` e.g. `2` | Number of host CPUs that the VM can access
+| `TFB_VB_CPU`                     | `<number>` e.g. `2` | Number of host CPUs that the VM can access
+
+# Tips and Tricks
+
+**Use Snapshots To Speed Development**
+
+There is an excellent Vagrant plugin to perform  
+snapshots [here](https://github.com/scalefactory/vagrant-multiprovider-snap). 
+Another alternative is [here](https://github.com/dergachev/vagrant-vbox-snapshot).
+My standard workflow is to do `vagrant up` and immediately 
+do a `vagrant snap` to preserve the initial state. Then I can
+install things, work on pull requests, etc, and roll back to the 
+initial state each time to avoid interference. 

+ 4 - 4
frameworks/Dart/dart/README.md

@@ -4,12 +4,12 @@ This is the dart portion of a [benchmarking test suite](../) comparing a variety
 
 ## Versions
 
-* [Dart SDK version >=1.3.0](http://www.dartlang.org/)
-* [Dart args version 0.11.0+1](http://pub.dartlang.org/packages/args)
+* [Dart SDK version >=1.6.0](http://www.dartlang.org/)
+* [Dart args version 0.12.0+2](http://pub.dartlang.org/packages/args)
 * [Dart crypto version 0.9.0](http://pub.dartlang.org/packages/crypto)
 * [Dart mustache version 0.1.8](http://pub.dartlang.org/packages/mustache)
-* [Dart postgresql version 0.2.13](http://pub.dartlang.org/packages/postgresql)
-* [Dart yaml version 0.9.0](http://pub.dartlang.org/packages/yaml)
+* [Dart postgresql version 0.2.14](http://pub.dartlang.org/packages/postgresql)
+* [Dart yaml version 2.0.1+1](http://pub.dartlang.org/packages/yaml)
 
 ## Test URLs
 

+ 1 - 1
frameworks/Dart/dart/benchmark_config

@@ -17,7 +17,7 @@
       "language": "Dart",
       "orm": "Raw",
       "platform": "Dart",
-      "webserver": "nginx",
+      "webserver": "None",
       "os": "Linux",
       "database_os": "Linux",
       "display_name": "dart",

+ 1 - 1
frameworks/Dart/dart/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends dart nginx
+fw_depends dart

+ 4 - 4
frameworks/Dart/dart/pubspec.yaml

@@ -1,10 +1,10 @@
 name: dartbenchmark
 description: A benchmark of dart
 environment:
-  sdk: ">=1.3.0 <2.0.0"
+  sdk: '>=1.6.0 <2.0.0'
 dependencies:
-  args: 0.11.0+1
+  args: 0.12.0+2
   crypto: 0.9.0
   mustache: 0.1.8
-  postgresql: 0.2.13
-  yaml: 0.9.0
+  postgresql: 0.2.14
+  yaml: 2.0.1+1

+ 53 - 45
frameworks/Dart/dart/server.dart

@@ -1,6 +1,7 @@
 import 'dart:async' show Future;
-import 'dart:io';
 import 'dart:convert';
+import 'dart:io';
+import 'dart:isolate';
 import 'dart:math' show Random;
 import 'package:args/args.dart' show ArgParser;
 import 'package:mustache/mustache.dart' as mustache;
@@ -17,11 +18,26 @@ main(List<String> args) {
   parser.addOption('address', abbr: 'a', defaultsTo: '0.0.0.0');
   parser.addOption('port', abbr: 'p', defaultsTo: '8080');
   parser.addOption('dbconnections', abbr: 'd', defaultsTo: '256');
+  parser.addOption('isolates', abbr: 'i', defaultsTo: '1');
   var arguments = parser.parse(args);
-  _startServer(
-      arguments['address'],
-      int.parse(arguments['port']),
-      int.parse(arguments['dbconnections']));
+  var isolates = int.parse(arguments['isolates']);
+  var dbConnections = int.parse(arguments['dbconnections']) ~/ isolates;
+  ServerSocket.bind(arguments['address'], int.parse(arguments['port']))
+      .then((server) {
+        var ref = server.reference;
+        for (int i = 1; i < isolates; i++) {
+          Isolate.spawn(startInIsolate, [ref, dbConnections]);
+        }
+        _startServer(server, dbConnections);
+      });
+}
+
+void startInIsolate(args) {
+  var ref = args[0];
+  var dbConnections = args[1];
+  ref.create().then((server) {
+    _startServer(server, dbConnections);
+  });
 }
 
 /// The entity used in the database query and update tests.
@@ -51,15 +67,6 @@ const _WORLD_TABLE_SIZE = 10000;
 /// A random number generator.
 final _RANDOM = new Random();
 
-/// The 'text/html; charset=utf-8' content type.
-final _TYPE_HTML = new ContentType('text', 'html', charset: 'utf-8');
-
-/// The 'application/json' content type.
-final _TYPE_JSON = new ContentType('application', 'json');
-
-/// The 'text/html; charset=utf-8' content type.
-final _TYPE_TEXT = new ContentType('text', 'plain', charset: 'utf-8');
-
 /// The PostgreSQL connection pool used by all the tests that require database
 /// connectivity.
 var _connectionPool;
@@ -70,7 +77,7 @@ var _fortunesTemplate;
 /// Starts a benchmark server, which listens for connections from
 /// '[address] : [port]' and maintains [dbConnections] connections to the
 /// database.
-_startServer(address, port, dbConnections) {
+_startServer(serverSocket, dbConnections) {
   Future.wait([
     new File('postgresql.yaml').readAsString().then((config) {
       _connectionPool = new pgpool.Pool(
@@ -83,33 +90,33 @@ _startServer(address, port, dbConnections) {
       _fortunesTemplate = mustache.parse(template);
     })
   ]).then((_) {
-    HttpServer.bind(address, port).then((server) {
-      server.serverHeader = 'dart';
-      server.listen((request) {
-        switch (request.uri.path) {
-          case '/json':
-            _jsonTest(request);
-            break;
-          case '/db':
-            _dbTest(request);
-            break;
-          case '/queries':
-            _queriesTest(request);
-            break;
-          case '/fortunes':
-            _fortunesTest(request);
-            break;
-          case '/updates':
-            _updatesTest(request);
-            break;
-          case '/plaintext':
-            _plaintextTest(request);
-            break;
-          default:
-            _sendResponse(request, HttpStatus.NOT_FOUND);
-            break;
-        }
-      });
+    var server = new HttpServer.listenOn(serverSocket);
+    server.defaultResponseHeaders.clear();
+    server.serverHeader = 'dart';
+    server.listen((request) {
+      switch (request.uri.path) {
+        case '/json':
+          _jsonTest(request);
+          break;
+        case '/db':
+          _dbTest(request);
+          break;
+        case '/queries':
+          _queriesTest(request);
+          break;
+        case '/fortunes':
+          _fortunesTest(request);
+          break;
+        case '/updates':
+          _updatesTest(request);
+          break;
+        case '/plaintext':
+          _plaintextTest(request);
+          break;
+        default:
+          _sendResponse(request, HttpStatus.NOT_FOUND);
+          break;
+      }
     });
   });
 }
@@ -140,17 +147,18 @@ _sendResponse(request, statusCode, [ type, response ]) {
 
 /// Completes the given [request] by writing the [response] as HTML.
 _sendHtml(request, response) {
-  _sendResponse(request, HttpStatus.OK, _TYPE_HTML, response);
+  _sendResponse(request, HttpStatus.OK, ContentType.HTML, response);
 }
 
 /// Completes the given [request] by writing the [response] as JSON.
 _sendJson(request, response) {
-  _sendResponse(request, HttpStatus.OK, _TYPE_JSON, JSON.encode(response));
+  _sendResponse(
+      request, HttpStatus.OK, ContentType.JSON, JSON.encode(response));
 }
 
 /// Completes the given [request] by writing the [response] as plain text.
 _sendText(request, response) {
-  _sendResponse(request, HttpStatus.OK, _TYPE_TEXT, response);
+  _sendResponse(request, HttpStatus.OK, ContentType.TEXT, response);
 }
 
 /// Responds with the JSON test to the [request].

+ 1 - 44
frameworks/Dart/dart/setup.py

@@ -13,55 +13,12 @@ def start(args, logfile, errfile):
     #
     # start dart servers
     #
-    for port in range(9001, 9001 + args.max_threads):
-      subprocess.Popen('dart server.dart -a 127.0.0.1 -p ' + str(port) + ' -d ' + str(args.max_concurrency / args.max_threads), shell=True, cwd='dart', stderr=errfile, stdout=logfile)
-    #
-    # create nginx configuration
-    #
-    conf = []
-    conf.append('worker_processes ' + str(args.max_threads) + ';')
-    conf.append('error_log stderr error;')
-    conf.append('events {')
-    conf.append('    worker_connections 1024;')
-    conf.append('}')
-    conf.append('http {')
-    conf.append('    access_log off;')
-    conf.append('    include /usr/local/nginx/conf/mime.types;')
-    conf.append('    default_type application/octet-stream;')
-    conf.append('    sendfile on;')
-    conf.append('    upstream dart_cluster {')
-    for port in range(9001, 9001 + args.max_threads):
-      conf.append('        server 127.0.0.1:' + str(port) + ';')
-    conf.append('        keepalive ' + str(args.max_concurrency / args.max_threads) + ';')
-    conf.append('    }')
-    conf.append('    server {')
-    conf.append('        listen 8080;')
-    conf.append('        location / {')
-    conf.append('            proxy_pass http://dart_cluster;')
-    conf.append('            proxy_http_version 1.1;')
-    conf.append('            proxy_set_header Connection "";')
-    conf.append('        }')
-    conf.append('    }')
-    conf.append('}')
-    #
-    # write nginx configuration to disk
-    #
-    with open('dart/nginx.conf', 'w') as f:
-      f.write('\n'.join(conf))
-    #
-    # start nginx
-    #
-    subprocess.Popen('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf', shell=True, cwd='dart', stderr=errfile, stdout=logfile);
+    subprocess.Popen('dart server.dart -a 0.0.0.0 -p 8080 -d ' + str(args.max_concurrency) + ' -i ' + str(args.max_threads), shell=True, cwd='dart', stderr=errfile, stdout=logfile)
     return 0
   except subprocess.CalledProcessError:
     return 1
 
 def stop(logfile, errfile):
-  #
-  # stop nginx
-  #
-  subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c $TROOT/nginx.conf -s stop', shell=True, cwd='dart', stderr=errfile, stdout=logfile)
-  os.remove('dart/nginx.conf')
   #
   # stop dart servers
   #

+ 3 - 0
frameworks/Haskell/wai/bash_profile.sh

@@ -0,0 +1,3 @@
+# Where to find the ghc and cabal executables
+export PATH="/opt/ghc/7.8.3/bin:/opt/cabal/1.20/bin:$PATH"
+export LANG=en_US.UTF-8

+ 3 - 3
frameworks/Haskell/wai/bench/bench.cabal

@@ -11,12 +11,12 @@ executable         bench
 
     extensions: OverloadedStrings
 
-    build-depends: base                          >= 4          && < 5
+    build-depends: base                          >= 4.7        && < 5
                  , aeson                         >= 0.6.1.0
-                 , conduit-extra                 >= 1.1
                  , http-types
                  , network                       >= 2.4
-                 , streaming-commons
                  , text                          >= 1.0
                  , wai                           >= 3.0
                  , warp                          >= 3.0
+                 , blaze-builder
+                 , bytestring                    >= 0.10

+ 12 - 8
frameworks/Haskell/wai/bench/wai.hs

@@ -1,20 +1,24 @@
 {-# LANGUAGE OverloadedStrings, BangPatterns #-}
 
+import Blaze.ByteString.Builder (copyByteString)
 import Control.Concurrent (runInUnboundThread)
 import Data.Aeson ((.=), object, encode)
-import Data.Streaming.Network (bindPortTCP)
+import qualified Data.ByteString.Lazy as L
 import Data.Text (Text)
 import Network.HTTP.Types (status200)
-import Network.Wai (responseLBS)
+import Network.Wai (responseBuilder)
 import qualified Network.Wai.Handler.Warp as W
 
 main :: IO ()
-main = runInUnboundThread $ do
-    s <- bindPortTCP 8000 "*"
-    W.runSettingsSocket settings s app
+main =
+    runInUnboundThread $ W.runSettings settings app
   where
-    settings = W.setOnException (\_ _ -> return ()) W.defaultSettings
+    settings = W.setPort 8000
+             $ W.setOnException (\_ _ -> return ()) W.defaultSettings
     app _ respond = respond response
-    !response = responseLBS status200 ct json
+    !response = responseBuilder status200 ct json
     ct = [("Content-Type", "application/json")]
-    !json = encode $ object ["message" .= ("Hello, World!" :: Text)]
+    !json = copyByteString
+          $ L.toStrict
+          $ encode
+          $ object ["message" .= ("Hello, World!" :: Text)]

+ 1 - 1
frameworks/Haskell/wai/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends haskell
+fw_depends haskell78

+ 2 - 4
frameworks/Haskell/wai/setup.py

@@ -6,13 +6,11 @@ import os
 
 def start(args, logfile, errfile):
   subprocess.check_call("cabal update", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal install --only-dependencies", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal configure", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal build", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
+  subprocess.check_call("cabal install", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
 
   db_host = args.database_host
   threads = str(args.max_threads)
-  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A32m -N", shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
+  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A32m -N" + threads, shell=True, cwd="wai/bench", stderr=errfile, stdout=logfile)
   return 0
 
 def stop(logfile, errfile):

+ 3 - 0
frameworks/Haskell/yesod/bash_profile.sh

@@ -0,0 +1,3 @@
+# Where to find the ghc and cabal executables
+export PATH="/opt/ghc/7.8.3/bin:/opt/cabal/1.20/bin:$PATH"
+export LANG=en_US.UTF-8

+ 17 - 10
frameworks/Haskell/yesod/bench/bench.cabal

@@ -16,20 +16,27 @@ executable         bench
                 TypeFamilies
                 GADTs
                 EmptyDataDecls
+                CPP
 
-    build-depends: base                          >= 4          && < 5
-                 , yesod                         == 1.2.2
-                 , yesod-core                    == 1.2.4
-                 , text                          >= 0.11       && < 0.12
-                 , persistent                    >= 1.2        && < 1.3
-                 , persistent-mysql              >= 1.2        && < 1.3
-                 , persistent-mongoDB            >= 1.2        && < 1.3
-                 , warp                          >= 1.3        && < 1.4
-                 , unix                          >= 2.5
-                 , network-conduit               >= 1.0
+    build-depends: base                          >= 4.7        && < 5
+                 , yesod-core                    >= 1.4.2      && < 1.5
+                 , text                          >= 0.11       && < 1.3
+                 , persistent                    >= 2.1        && < 2.2
+                 , persistent-mysql              >= 2.1        && < 2.2
+                 , persistent-template           >= 2.1        && < 2.2
+                 , warp                          >= 3.0.2.2    && < 3.1
+                 , auto-update                   >= 0.1.1.4    && < 0.2
                  , primitive                     >= 0.5
                  , mwc-random                    >= 0.12
                  , pool-conduit                  >= 0.1.2
                  , network
                  , mongoDB
+                 , monad-logger
+                 , mtl
+                 , wai
+                 , http-types
                  , aeson
+                 , blaze-builder
+                 , bytestring                    >= 0.10
+                 , resource-pool
+                 , resourcet

+ 106 - 64
frameworks/Haskell/yesod/bench/src/yesod.hs

@@ -1,35 +1,58 @@
-{-# LANGUAGE QuasiQuotes, TemplateHaskell, TypeFamilies, MultiParamTypeClasses, OverloadedStrings #-}
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE EmptyDataDecls #-}
-{-# LANGUAGE RankNTypes #-}
-import Yesod hiding (Field)
-import System.Environment (getArgs)
-import qualified Network.Wai.Handler.Warp as Warp
-import Data.Text (Text)
-import Data.Conduit.Pool (Pool)
-import qualified Database.Persist.MySQL as My
-import qualified Database.Persist.MongoDB as Mongo
-import qualified Database.MongoDB as Mongo
-import Database.MongoDB ((=:), Field((:=)))
-import qualified System.Random.MWC as R
-import Control.Monad.Primitive (PrimState)
-import Control.Monad (replicateM)
-import Data.Conduit.Network (bindPort)
-import System.Posix.Process (forkProcess)
-import Control.Monad (replicateM_)
-import Network (PortID (PortNumber))
-import Data.Int (Int64)
-
-mkPersist sqlSettings [persistLowerCase|
+{-# LANGUAGE EmptyDataDecls             #-}
+{-# LANGUAGE FlexibleContexts           #-}
+{-# LANGUAGE FlexibleInstances          #-}
+{-# LANGUAGE GADTs                      #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MultiParamTypeClasses      #-}
+{-# LANGUAGE OverloadedStrings          #-}
+{-# LANGUAGE QuasiQuotes                #-}
+{-# LANGUAGE RankNTypes                 #-}
+{-# LANGUAGE RecordWildCards            #-}
+{-# LANGUAGE TemplateHaskell            #-}
+{-# LANGUAGE TypeFamilies               #-}
+{-# LANGUAGE ViewPatterns               #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+module Main (main, resourcesApp, Widget, WorldId) where
+import           Blaze.ByteString.Builder
+import           Control.Concurrent           (runInUnboundThread)
+import           Control.Monad                (replicateM)
+import           Control.Monad.Logger         (runNoLoggingT)
+import           Control.Monad.Primitive      (PrimState)
+import           Control.Monad.Reader         (ReaderT)
+import           Control.Monad.Trans.Resource (InternalState)
+import           Data.Aeson                   (encode)
+import qualified Data.ByteString.Lazy         as L
+import           Data.Conduit.Pool            (Pool, createPool)
+import           Data.Int                     (Int64)
+import           Data.IORef                   (newIORef)
+import           Data.Pool                    (withResource)
+import           Data.Text                    (Text)
+import           Database.MongoDB             (Field ((:=)), (=:))
+import qualified Database.MongoDB             as Mongo
+import           Database.Persist             (Key, PersistEntity,
+                                               PersistEntityBackend,
+                                               PersistStore, get)
+import qualified Database.Persist.MySQL       as My
+import           Database.Persist.TH          (mkPersist, mpsGeneric,
+                                               persistLowerCase, sqlSettings)
+import           Network                      (PortID (PortNumber))
+import           Network.HTTP.Types
+import           Network.Wai
+import qualified Network.Wai.Handler.Warp     as Warp
+import           System.Environment           (getArgs)
+import           System.IO.Unsafe             (unsafePerformIO)
+import qualified System.Random.MWC            as R
+import           Yesod.Core
+
+mkPersist sqlSettings { mpsGeneric = True } [persistLowerCase|
 World sql=World
     randomNumber Int sql=randomNumber
 |]
 
 data App = App
-    { appGen :: R.Gen (PrimState IO)
-    , mySqlPool :: Pool My.Connection
-    , mongoDBPool :: Pool Mongo.Connection
+    { appGen      :: !(R.Gen (PrimState IO))
+    , mySqlPool   :: !(Pool My.SqlBackend)
+    , mongoDBPool :: !(Pool Mongo.Pipe)
     }
 
 -- | Not actually using the non-raw mongoDB.
@@ -40,27 +63,41 @@ mkYesod "App" [parseRoutes|
 /db                 DbR       GET
 /dbs/#Int           DbsR      GET
 
-/mongo/db           MongoDbR  GET
-/mongo/dbs/#Int     MongoDbsR GET
-
 /mongo/raw/db       MongoRawDbR  GET
 /mongo/raw/dbs/#Int MongoRawDbsR GET
 |]
 
+fakeInternalState :: InternalState
+fakeInternalState = unsafePerformIO $ newIORef $ error "fakeInternalState forced"
+{-# NOINLINE fakeInternalState #-}
+
 instance Yesod App where
     makeSessionBackend _ = return Nothing
+    {-# INLINE makeSessionBackend #-}
     shouldLog _ _ _ = False
+    {-# INLINE shouldLog #-}
     yesodMiddleware = id
-
-getJsonR :: Handler Value
-getJsonR = return $ object ["message" .= ("Hello, World!" :: Text)]
+    {-# INLINE yesodMiddleware #-}
+    cleanPath _ = Right
+    {-# INLINE cleanPath #-}
+    yesodWithInternalState _ _ = ($ fakeInternalState)
+    {-# INLINE yesodWithInternalState #-}
+    maximumContentLength _ _ = Nothing
+    {-# INLINE maximumContentLength #-}
+
+getJsonR :: Handler ()
+getJsonR = sendWaiResponse
+         $ responseBuilder
+            status200
+            [("Content-Type", typeJson)]
+         $ copyByteString
+         $ L.toStrict
+         $ encode
+         $ object ["message" .= ("Hello, World!" :: Text)]
 
 
 getDbR :: Handler Value
-getDbR = getDb (intQuery runMySQL )
-
-getMongoDbR :: Handler Value
-getMongoDbR = getDb (intQuery runMongoDB )
+getDbR = getDb (intQuery runMySQL My.toSqlKey)
 
 getMongoRawDbR :: Handler Value
 getMongoRawDbR = getDb rawMongoIntQuery
@@ -68,10 +105,7 @@ getMongoRawDbR = getDb rawMongoIntQuery
 getDbsR :: Int -> Handler Value
 getDbsR cnt = do
     App {..} <- getYesod
-    multiRandomHandler (intQuery runMySQL) cnt
-
-getMongoDbsR :: Int -> Handler Value
-getMongoDbsR cnt = multiRandomHandler (intQuery runMongoDB) cnt
+    multiRandomHandler (intQuery runMySQL My.toSqlKey) cnt
 
 getMongoRawDbsR :: Int -> Handler Value
 getMongoRawDbsR cnt = multiRandomHandler rawMongoIntQuery cnt
@@ -84,26 +118,35 @@ getDb :: (Int64 -> Handler Value) -> Handler Value
 getDb query = do
     app <- getYesod
     i <- liftIO (randomNumber (appGen app))
-    query i
+    value <- query i
+    sendWaiResponse
+        $ responseBuilder
+            status200
+            [("Content-Type", typeJson)]
+        $ copyByteString
+        $ L.toStrict
+        $ encode value
 
 
 runMongoDB :: Mongo.Action Handler b -> Handler b
 runMongoDB f = do
   App {..} <- getYesod
-  Mongo.runMongoDBPoolDef f mongoDBPool
+  withResource mongoDBPool $ \pipe ->
+    Mongo.access pipe Mongo.ReadStaleOk "hello_world" f
 
 runMySQL :: My.SqlPersistT Handler b -> Handler b
 runMySQL f = do
   App {..} <- getYesod
   My.runSqlPool f mySqlPool
 
-intQuery :: forall (m :: * -> *) (m1 :: * -> *) val backend.
-           (Monad m, PersistEntity val, PersistStore m1,
-            PersistEntityBackend val ~ PersistMonadBackend m1) =>
-           (m1 (Maybe val) -> m (Maybe (WorldGeneric backend)))
+intQuery :: (MonadIO m, PersistEntity val, PersistStore backend
+            , backend ~ PersistEntityBackend val
+            ) =>
+           (ReaderT backend m (Maybe val) -> m (Maybe (WorldGeneric backend)))
+           -> (Int64 -> Key val)
            -> Int64 -> m Value
-intQuery db i = do
-    Just x <- db $ get (Key $ PersistInt64 i)
+intQuery db toKey i = do
+    Just x <- db $ get $ toKey i
     return $ jsonResult (worldRandomNumber x)
   where
     jsonResult :: Int -> Value
@@ -111,7 +154,7 @@ intQuery db i = do
 
 rawMongoIntQuery :: Mongo.Val v => v -> Handler Value
 rawMongoIntQuery i = do
-    Just x <- runMongoDB $ Mongo.findOne (Mongo.select ["id" =: i] "world")
+    Just x <- runMongoDB $ Mongo.findOne (Mongo.select ["id" =: i] "World")
     return $ documentToJson x
 
 multiRandomHandler :: ToJSON a
@@ -141,30 +184,29 @@ instance ToJSON Mongo.Value where
 
 main :: IO ()
 main = R.withSystemRandom $ \gen -> do
-    socket <- bindPort 8000 "*"
     [cores, host] <- getArgs
-    myPool <- My.createMySQLPool My.defaultConnectInfo
+    myPool <- runNoLoggingT $ My.createMySQLPool My.defaultConnectInfo
         { My.connectUser = "benchmarkdbuser"
         , My.connectPassword = "benchmarkdbpass"
         , My.connectDatabase = "hello_world"
         , My.connectHost = host
         } 1000
 
-    mongoPool <- Mongo.createMongoDBPool "hello_world" host (PortNumber 27017)
-        (Just (Mongo.MongoAuth "benchmarkdbuser" "benchmarkdbpass"))
-           1  -- what is the optimal stripe count? 1 is said to be a good default
-           1000
-           3  -- 3 second timeout
+    mongoPool <- createPool
+        (Mongo.connect $ Mongo.Host host $ PortNumber 27017)
+        Mongo.close
+        (read cores) -- what is the optimal stripe count? 1 is said to be a good default
+        3  -- 3 second timeout
+        1000
 
     app <- toWaiAppPlain App
         { appGen = gen
         , mySqlPool = myPool
         , mongoDBPool = mongoPool
         }
-    let run = Warp.runSettingsSocket Warp.defaultSettings
-                { Warp.settingsPort = 8000
-                , Warp.settingsHost = "*"
-                , Warp.settingsOnException = const $ return ()
-                } socket app
-    replicateM_ (read cores - 1) $ forkProcess run
-    run
+    runInUnboundThread $ Warp.runSettings
+        ( Warp.setPort 8000
+        $ Warp.setHost "*"
+        $ Warp.setOnException (\_ _ -> return ())
+          Warp.defaultSettings
+        ) app

+ 1 - 1
frameworks/Haskell/yesod/install.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-fw_depends yesod haskell
+fw_depends haskell78

+ 1 - 5
frameworks/Haskell/yesod/setup.py

@@ -5,16 +5,12 @@ import setup_util
 import os
 
 def start(args, logfile, errfile):
-  #setup_util.replace_text("yesod/bench/config/mysql.yml", "host: .*", "host: " + args.database_host)
-  
   subprocess.check_call("cabal update", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   subprocess.check_call("cabal install", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal configure", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
-  subprocess.check_call("cabal build", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
 
   db_host = args.database_host
   threads = str(args.max_threads)
-  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A4M -N -qg2 -I0 -G2", shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
+  subprocess.Popen("dist/build/bench/bench " + threads + " " + db_host + " +RTS -A32M -N" + threads, shell=True, cwd="yesod/bench", stderr=errfile, stdout=logfile)
   return 0
 
 def stop(logfile, errfile):

+ 1 - 1
frameworks/Java/curacao/README.md

@@ -4,7 +4,7 @@ Curacao is an open-source toolkit for building REST/HTTP-based integration layer
 
 ## Versions
 
-Curacao 2.6.2
+Curacao 2.6.3
 https://github.com/markkolich/curacao
 
 ## Tests

+ 3 - 3
frameworks/Java/curacao/build.sbt

@@ -13,9 +13,9 @@ resolvers ++= Seq(
 )
 
 libraryDependencies ++= Seq(
-  "com.kolich.curacao" % "curacao" % "2.6.2" % "compile",
-  "com.kolich.curacao" % "curacao-gson" % "2.6.2" % "compile",
-  "org.eclipse.jetty" % "jetty-webapp" % "9.2.0.v20140526" % "compile",
+  "com.kolich.curacao" % "curacao" % "2.6.3" % "compile",
+  "com.kolich.curacao" % "curacao-gson" % "2.6.3" % "compile",
+  "org.eclipse.jetty" % "jetty-webapp" % "9.2.3.v20140905" % "compile",
   "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided",
   "org.slf4j" % "slf4j-api" % "1.7.2" % "compile",
   "ch.qos.logback" % "logback-core" % "1.0.7" % "compile",

+ 7 - 4
frameworks/Lua/lapis/config.lua

@@ -3,12 +3,15 @@ do
   local _obj_0 = require("lapis.config")
   config = _obj_0.config
 end
-config("development", function()
-  return postgresql_url("postgres://benchmarkdbuser:[email protected]/hello_world")
-end)
+config("development", function() end)
 return config("production", function()
   port(80)
   num_workers(4)
   lua_code_cache("on")
-  return postgresql_url("postgres://benchmarkdbuser:[email protected]/hello_world")
+  return postgres({
+    backend = "pgmoon",
+    database = "hello_world",
+    user = "postgres",
+    host = "DBHOSTNAME"
+  })
 end)

+ 6 - 2
frameworks/Lua/lapis/config.moon

@@ -1,10 +1,14 @@
 import config from require "lapis.config"
 
 config "development", ->
-  postgresql_url "postgres://benchmarkdbuser:[email protected]/hello_world"
 
 config "production", ->
   port 80
   num_workers 4
   lua_code_cache "on"
-  postgresql_url "postgres://benchmarkdbuser:[email protected]/hello_world"
+  postgres {
+    backend: "pgmoon"
+    database: "hello_world"
+    user: "postgres"
+    host: "DBHOSTNAME"
+  }

+ 1 - 0
frameworks/Lua/lapis/setup.py

@@ -4,6 +4,7 @@ import setup_util
 import os
 
 def start(args, logfile, errfile):
+  setup_util.replace_text("lapis/config.lua", "DBHOSTNAME", args.database_host)
   setup_util.replace_text("lapis/nginx.conf", "DBHOSTNAME", args.database_host)
   #subprocess.Popen('/usr/local/openresty/nginx/sbin/nginx -c `pwd`/nginx.conf -g "worker_processes ' + str((args.max_threads)) + ';"', shell=True, cwd="lapis", stderr=errfile, stdout=logfile)
   subprocess.Popen('lapis server production', shell=True, cwd="lapis", stderr=errfile, stdout=logfile)

+ 4 - 3
frameworks/Lua/lapis/web.lua

@@ -23,8 +23,7 @@ end
 local min, random
 do
   local _obj_0 = math
-  min = _obj_0.min
-  random = _obj_0.random
+  min, random = _obj_0.min, _obj_0.random
 end
 local Fortune
 do
@@ -117,6 +116,7 @@ do
         }
       end
       local worlds = { }
+      num_queries = min(500, num_queries)
       for i = 1, num_queries do
         local w = World:find(random(1, 10000))
         insert(worlds, {
@@ -178,7 +178,8 @@ do
         num_queries = 1
       end
       local worlds = { }
-      for i = 1, min(500, num_queries) do
+      num_queries = min(500, num_queries)
+      for i = 1, num_queries do
         local wid = random(1, 10000)
         local world = World:find(wid)
         world.randomnumber = random(1, 10000)

+ 3 - 1
frameworks/Lua/lapis/web.moon

@@ -21,6 +21,7 @@ class Benchmark extends lapis.Application
       return json: {id:w.id,randomNumber:w.randomnumber}
 
     worlds = {}
+    num_queries = min(500, num_queries)
     for i = 1, num_queries
       w = World\find random(1, 10000)
       insert worlds, {id:w.id,randomNumber:w.randomnumber} 
@@ -55,7 +56,8 @@ class Benchmark extends lapis.Application
     if num_queries == 0
       num_queries = 1
     worlds = {}
-    for i = 1, min(500, num_queries)
+    num_queries = min(500, num_queries)
+    for i = 1, num_queries
       wid = random(1, 10000)
       world = World\find wid
       world.randomnumber = random(1, 10000)

+ 2 - 0
frameworks/Lua/openresty/app.lua

@@ -2,6 +2,7 @@ local mysql = mysql
 
 local encode = encode
 local random = math.random
+local min = math.min
 
 local mysqlconn = {
 	host = "DBHOSTNAME",
@@ -23,6 +24,7 @@ return function(ngx)
 		ngx.print(encode(db:query('SELECT * FROM World WHERE id = '..random(1,10000))[1]))
 	else
 		local worlds = {}
+		num_queries = min(500, num_queries)
 		for i=1, num_queries do
 			worlds[#worlds+1] = db:query('SELECT * FROM World WHERE id = '..random(1,10000))[1]
 		end

+ 0 - 6
toolset/setup/linux/frameworks/yesod.sh

@@ -1,6 +0,0 @@
-#!/bin/bash
-
-fw_depends haskell
-
-cabal update
-cabal install yesod persistent-mysql

+ 10 - 9
toolset/setup/linux/installer.py

@@ -201,6 +201,7 @@ class Installer:
     sudo service mongod stop
     sudo mv /etc/mongodb.conf /etc/mongodb.conf.orig
     sudo mv mongodb.conf /etc/mongodb.conf
+    sudo mv mongodb.conf /etc/mongod.conf
     sudo cp -R -p /var/lib/mongodb /ssd/
     sudo cp -R -p /var/log/mongodb /ssd/log/
     sudo service mongod start
@@ -220,19 +221,19 @@ class Installer:
     rm -rf /ssd/cassandra /ssd/log/cassandra
     mkdir -p /ssd/cassandra /ssd/log/cassandra
     
-    sed -i "s/^.*seeds:.*/          - seeds: \"%s\"/" cassandra/cassandra.yaml
-    sed -i "s/^listen_address:.*/listen_address: %s/" cassandra/cassandra.yaml
-    sed -i "s/^rpc_address:.*/rpc_address: %s/" cassandra/cassandra.yaml
+    sed -i "s/^.*seeds:.*/          - seeds: \"{database_host}\"/" cassandra/cassandra.yaml
+    sed -i "s/^listen_address:.*/listen_address: {database_host}/" cassandra/cassandra.yaml
+    sed -i "s/^rpc_address:.*/rpc_address: {database_host}/" cassandra/cassandra.yaml
     
     mv cassandra/cassandra.yaml apache-cassandra-$CASS_V/conf
     mv cassandra/log4j-server.properties apache-cassandra-$CASS_V/conf
-    apache-cassandra-$CASS_V/bin/cassandra -p /ssd/cassandra/c.pid > /ssd/cassandra/boot.log
+    nohup apache-cassandra-$CASS_V/bin/cassandra -p c.pid > cassandra.log
 
-    until nc -z localhost 9160 ; do echo Waiting for Cassandra; sleep 1; done
-    cat cassandra/cleanup-keyspace.cql | apache-cassandra-$CASS_V/bin/cqlsh localhost
+    until nc -z {database_host} 9160 ; do echo Waiting for Cassandra; sleep 1; done
+    cat cassandra/cleanup-keyspace.cql | apache-cassandra-$CASS_V/bin/cqlsh {database_host}
     python cassandra/db-data-gen.py > cassandra/tfb-data.cql
-    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/create-keyspace.cql localhost
-    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/tfb-data.cql localhost
+    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/create-keyspace.cql {database_host}
+    apache-cassandra-$CASS_V/bin/cqlsh -f cassandra/tfb-data.cql {database_host}
     rm -rf apache-cassandra-*-bin.tar.gz cassandra
 
     ##############################
@@ -245,7 +246,7 @@ class Installer:
     sudo service redis-server start
     bash create-redis.sh
     rm create-redis.sh
-    """ % (self.benchmarker.database_host, self.benchmarker.database_host, self.benchmarker.database_host)
+    """.format(database_host=self.benchmarker.database_host)
     
     print("\nINSTALL: %s" % self.benchmarker.database_ssh_string)
     p = subprocess.Popen(self.benchmarker.database_ssh_string.split(" ") + ["bash"], stdin=subprocess.PIPE)

+ 13 - 0
toolset/setup/linux/languages/haskell78.sh

@@ -0,0 +1,13 @@
+#!/bin/bash -ex
+
+RETCODE=$(fw_exists /opt/ghc/7.8.3/bin/ghc)
+[ ! "$RETCODE" == 0 ] || { return 0; }
+
+lsb_release -a
+env
+
+export LANG=en_US.UTF-8
+
+sudo add-apt-repository -y ppa:hvr/ghc
+sudo apt-get update
+sudo apt-get install -y ghc-7.8.3 cabal-install-1.20 libpcre3-dev

+ 5 - 2
toolset/setup/linux/prerequisites.sh

@@ -1,5 +1,8 @@
 #!/bin/bash
 
+set -x
+export DEBIAN_FRONTEND=noninteractive
+
 RETCODE=$(fw_exists fwbm_prereqs_installed)
 [ ! "$RETCODE" == 0 ] || { \
   echo "Prerequisites installed!"; 
@@ -12,10 +15,10 @@ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
 echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
 
 sudo apt-get -y update
-sudo apt-get -y -o Dpkg::Options::="--force-confnew" upgrade
+sudo apt-get -y upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
 
 # WARNING: DONT PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK
-sudo apt-get -y install \
+sudo apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
   cmake build-essential automake    `# Needed for building code` \
   curl wget unzip                   `# Common tools` \
   software-properties-common        `# Needed for add-apt-repository` \

+ 5 - 5
toolset/setup/linux/webservers/openresty.sh

@@ -5,12 +5,12 @@ RETCODE=$(fw_exists openresty.installed)
 
 fw_depends nginx lua
 
-fw_get http://openresty.org/download/ngx_openresty-1.5.12.1.tar.gz
-fw_untar ngx_openresty-1.5.12.1.tar.gz
+fw_get http://openresty.org/download/ngx_openresty-1.7.4.1.tar.gz
+fw_untar ngx_openresty-1.7.4.1.tar.gz
 
-cd ngx_openresty-1.5.12.1
-./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-cc-opt=-O2 --with-http_postgres_module -j4
+cd ngx_openresty-1.7.4.1
+./configure --with-luajit-xcflags=-DLUAJIT_NUMMODE=2 --with-http_postgres_module -j4
 make -j4
 sudo make install
 
-touch $IROOT/openresty.installed
+touch $IROOT/openresty.installed