Possibly a Haskell MongoDB driver

After upgrading from ghc 7.4 to ghc 7.6, I noticed a 40x slowdown in some of my database calls. To research, I wrote something simple to check, and my code is basically:

timeFetch :: Pipe -> UUID.UUID -> IO ()
timeFetch pipe uuid' = do
  lrResult <- access pipe master "MyDB" $ (findOne (select ["uid" =: ["$in" =: [(uuidToBUUID uuid')]]] "uidCollection") :: Action IO (Maybe Document))
  case lrResult of
    Right _ -> do
      printCrntTm "Right has result"
      timeFetch pipe uuid'
    Left _  -> printCrntTm "Left err"

printCrntTmjust prints the current time with a description line, but uuidToBUUIDbecause Data.UUID is another type of type Mongo Data.Bson UUID. Itself timeFetchrecursively calls itself infinitely.

So, in GHC 7.6, I see:

2013-12-09 09:35:52.307008 UTC Right has result
2013-12-09 09:35:52.348027 UTC Right has result
2013-12-09 09:35:52.389047 UTC Right has result
2013-12-09 09:35:52.430041 UTC Right has result
2013-12-09 09:35:52.471031 UTC Right has result
2013-12-09 09:35:52.512061 UTC Right has result
2013-12-09 09:35:52.553043 UTC Right has result

But in GHC 7.4, I see:

2013-12-09 09:36:38.109144 UTC Right has result
2013-12-09 09:36:38.110297 UTC Right has result
2013-12-09 09:36:38.111248 UTC Right has result
2013-12-09 09:36:38.112398 UTC Right has result
2013-12-09 09:36:38.113185 UTC Right has result
2013-12-09 09:36:38.114248 UTC Right has result

This is approximately 1 ms versus 40 ms !!! I should also mention that there was one time for version 7.6, I got: *** Exception: thread blocked indefinitely in an MVar operation(but never again), and this brings me to my main question.

I reached out a bit and I wonder if these lines of code in Database.MongoDB were guilty:

newCursor :: (MonadIO m, MonadBaseControl IO m) => Database -> Collection -> BatchSize -> DelayedBatch -> Action m Cursor
-- ^ Create new cursor. If you don't read all results then close it. Cursor will be closed automatically when all results are read from it or when eventually garbage collected.
newCursor db col batchSize dBatch = do
    var <- newMVar dBatch
    let cursor = Cursor (db <.> col) batchSize var
    mkWeakMVar var (closeCursor cursor)
    return cursor
#if !MIN_VERSION_base(4,6,0)
  where mkWeakMVar = addMVarFinalizer
#endif

base GHC 7.6 4.6.x.x, GHC 7.4. 4.5.x.x.

Haskell ; - , 40- , ? Database.MongoDB? !

+4
1

MongoDB . , , , , , .

+1

All Articles