packages feed

mongoDB 2.0.6 → 2.0.7

raw patch · 5 files changed

+71/−15 lines, 5 filesdep +criteriondep ~basedep ~mtlPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: criterion

Dependency ranges changed: base, mtl

API changes (from Hackage documentation)

- Database.MongoDB.Internal.Connection: writeLazy :: Connection -> ByteString -> IO ()

Files

+ Benchmark.hs view
@@ -0,0 +1,26 @@+import Criterion.Main++import Control.Monad (forM_, void)+import qualified Database.MongoDB as M+import Data.Bson (Document, Field(..), Label, Val, Value(String, Doc, Bool),+                  Javascript, at, valueAt, lookup, look, genObjectId, (=:),+                  (=?))++import Database.MongoDB.Query++import qualified Data.Text as T++main = defaultMain [+    bgroup "insert" [ bench "100" $ nfIO doInserts ]+  ]++doInserts = do+    let docs = (flip map) [0..100] $ \i ->+            ["name" M.=: (T.pack $ "name " ++ (show i))]++    pipe <- M.connect (M.host "127.0.0.1")++    forM_ docs $ \doc -> do+      void $ M.access pipe M.master "mongodb-haskell-test" $ M.insert "bigCollection" doc++    M.close pipe
CHANGELOG.md view
@@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Package Versioning Policy](https://wiki.haskell.org/Package_versioning_policy). +## [2.0.7] - 2015-09-04++### Fixed+- Slow requests to the database server.+ ## [2.0.6] - 2015-08-02  ### Added
Database/MongoDB/Internal/Connection.hs view
@@ -5,7 +5,6 @@ module Database.MongoDB.Internal.Connection (     Connection(..),     readExactly,-    writeLazy,     fromHandle, ) where @@ -51,9 +50,6 @@       else go (acc <> Lazy.ByteString.fromStrict chunk) (n - len)   eof = mkIOError eofErrorType "Database.MongoDB.Internal.Connection"                   Nothing Nothing--writeLazy :: Connection -> Lazy.ByteString -> IO ()-writeLazy conn = mapM_ (write conn) . Lazy.ByteString.toChunks  fromHandle :: Handle -> IO Connection -- ^ Make connection form handle
Database/MongoDB/Internal/Protocol.hs view
@@ -26,7 +26,7 @@ import Control.Applicative ((<$>)) #endif import Control.Arrow ((***))-import Control.Monad (forM_, replicateM, unless)+import Control.Monad (forM, replicateM, unless) import Data.Binary.Get (Get, runGet) import Data.Binary.Put (Put, runPut) import Data.Bits (bit, testBit)@@ -34,6 +34,7 @@ import Data.IORef (IORef, newIORef, atomicModifyIORef) import System.IO (Handle) import System.IO.Unsafe (unsafePerformIO)+import Data.Maybe (maybeToList)  import qualified Data.ByteString.Lazy as L @@ -93,16 +94,20 @@ writeMessage :: Connection -> Message -> IO () -- ^ Write message to connection writeMessage conn (notices, mRequest) = do-    forM_ notices $ \n -> writeReq . (Left n,) =<< genRequestId-    whenJust mRequest $ writeReq . (Right *** id)+    noticeStrings <- forM notices $ \n -> do+          requestId <- genRequestId+          let s = runPut $ putNotice n requestId+          return $ (lenBytes s) `L.append` s++    let requestString = do+          (request, requestId) <- mRequest+          let s = runPut $ putRequest request requestId+          return $ (lenBytes s) `L.append` s++    Connection.write conn $ L.toStrict $ L.concat $ noticeStrings ++ (maybeToList requestString)     Connection.flush conn  where-    writeReq (e, requestId) = do-        Connection.writeLazy conn lenBytes-        Connection.writeLazy conn bytes-     where-        bytes = runPut $ (either putNotice putRequest e) requestId-        lenBytes = encodeSize . toEnum . fromEnum $ L.length bytes+    lenBytes bytes = encodeSize . toEnum . fromEnum $ L.length bytes     encodeSize = runPut . putInt32 . (+ 4)  type Response = (ResponseTo, Reply)
mongoDB.cabal view
@@ -1,5 +1,5 @@ Name:           mongoDB-Version:        2.0.6+Version:        2.0.7 Synopsis:       Driver (client) for MongoDB, a free, scalable, fast, document                 DBMS Description:    This package lets you connect to MongoDB servers and@@ -58,7 +58,7 @@ test-suite test   hs-source-dirs: test   main-is: Spec.hs-  ghc-options:       -Wall+  ghc-options:       -Wall -with-rtsopts "-K32m"   type: exitcode-stdio-1.0   build-depends:   mongoDB                  , base@@ -71,5 +71,29 @@                  , text                  , time +  default-language: Haskell2010+  default-extensions: OverloadedStrings++Benchmark bench+  main-is:            Benchmark.hs+  type:               exitcode-stdio-1.0+  Build-depends:      array -any+                    , base < 5+                    , binary -any+                    , bson >= 0.3 && < 0.4+                    , text+                    , bytestring -any+                    , containers -any+                    , mtl >= 2+                    , cryptohash -any+                    , network -any+                    , parsec -any+                    , random -any+                    , random-shuffle -any+                    , monad-control >= 0.3.1+                    , lifted-base >= 0.1.0.3+                    , transformers-base >= 0.4.1+                    , hashtables >= 1.1.2.0+                    , criterion   default-language: Haskell2010   default-extensions: OverloadedStrings