Browse Source

Haskell/* Remove TE dependencies (#3524)

* [ci lang-only Haskell]

* [ci lang-only Haskell]

* [ci lang-only Haskell]

* try to speed up yesod [ci fw-only Haskell/yesod]

* one more shot [ci fw-only Haskell/yesod]

* removing postgres (broken/worst performer) for build time [ci fw-only Haskell/yesod]
Nate 7 years ago
parent
commit
6d4f5dea0f

+ 5 - 2
frameworks/Haskell/servant/servant.dockerfile

@@ -1,6 +1,9 @@
-FROM techempower/haskell:0.1
+FROM haskell:8.2.1
 
-COPY ./ ./
+RUN apt update -yqq && apt install -yqq xz-utils make libpq-dev
+
+ADD ./ /servant
+WORKDIR /servant
 
 RUN stack --allow-different-user setup
 RUN stack --allow-different-user build

+ 6 - 2
frameworks/Haskell/snap/snap.dockerfile

@@ -1,7 +1,11 @@
-FROM techempower/haskell:0.1
+FROM haskell:8.2.1
 
-COPY ./bench ./
+RUN apt update -yqq && apt install -yqq xz-utils make libmysqlclient-dev pkg-config libpcre3 libpcre3-dev
 
+COPY ./bench /snap
+WORKDIR /snap
+
+RUN stack upgrade
 RUN stack --allow-different-user build --install-ghc
 
 CMD stack --allow-different-user exec snap-bench -- +RTS -A4M -N -qg2 -I0 -G2

+ 5 - 2
frameworks/Haskell/spock/spock.dockerfile

@@ -1,6 +1,9 @@
-FROM techempower/haskell:0.1
+FROM haskell:8.2.1
 
-COPY ./ ./
+RUN apt update -yqq && apt install -yqq xz-utils make libpq-dev
+
+ADD ./ /spock
+WORKDIR spock
 
 RUN stack --allow-different-user build --install-ghc
 

+ 7 - 2
frameworks/Haskell/wai/wai.dockerfile

@@ -1,6 +1,11 @@
-FROM techempower/haskell:0.1
+FROM haskell:8.2.1
 
-COPY ./ ./
+RUN apt update -yqq && apt install -yqq xz-utils make
+
+ADD ./ /wai
+WORKDIR /wai
+
+RUN stack upgrade
 
 RUN cd bench && stack --allow-different-user build --install-ghc
 

+ 0 - 22
frameworks/Haskell/yesod/benchmark_config.json

@@ -42,28 +42,6 @@
       "display_name": "yesod-mongo",
       "notes": "",
       "versus": "wai"
-    },
-    "postgres": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "db_url": "/db",
-      "query_url": "/queries/",
-      "fortune_url": "/fortunes",
-      "update_url": "/updates/",
-      "port": 8000,
-      "approach": "Realistic",
-      "classification": "Fullstack",
-      "database": "Postgres",
-      "framework": "yesod",
-      "language": "Haskell",
-      "orm": "Raw",
-      "platform": "Wai",
-      "webserver": "Warp",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "yesod-postgres",
-      "notes": "",
-      "versus": "wai"
     }
   }]
 }

+ 0 - 5
frameworks/Haskell/yesod/yesod-mongodb-base.dockerfile

@@ -1,5 +0,0 @@
-FROM techempower/haskell:0.1
-
-COPY ./yesod-mysql-mongo ./
-
-RUN stack --allow-different-user build --install-ghc

+ 7 - 1
frameworks/Haskell/yesod/yesod-mongodb-raw.dockerfile

@@ -1,3 +1,9 @@
-FROM techempower/yesod-mongodb-base:0.1
+FROM haskell:7.10.3
+
+RUN apt update -yqq && apt install -yqq xz-utils make libpq-dev libmysqlclient-dev pkg-config libpcre3 libpcre3-dev
+
+COPY ./yesod-mysql-mongo ./
+
+RUN stack build -j$(nproc) --skip-ghc-check --no-terminal
 
 CMD stack --allow-different-user exec yesod-mysql-mongo -- $(nproc) tfb-database +RTS -A32m -N$(nproc)

+ 0 - 1
frameworks/Haskell/yesod/yesod-mysql-mongo/yesod-mysql-mongo.cabal

@@ -28,7 +28,6 @@ executable         yesod-mysql-mongo
                  , auto-update
                  , primitive
                  , mwc-random
-                 , resource-pool
                  , network
                  , mongoDB
                  , monad-logger

+ 0 - 7
frameworks/Haskell/yesod/yesod-postgres.dockerfile

@@ -1,7 +0,0 @@
-FROM techempower/haskell:0.1
-
-COPY ./yesod-postgres ./
-
-RUN stack --allow-different-user build --install-ghc
-
-CMD stack --allow-different-user exec yesod-postgres -- $(nproc) tfb-database +RTS -A32m -N$(nproc)

+ 0 - 194
frameworks/Haskell/yesod/yesod-postgres/src/Main.hs

@@ -1,194 +0,0 @@
-{-# 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               #-}
-{-# LANGUAGE LambdaCase                 #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# OPTIONS_GHC -fno-warn-orphans #-}
-module Main (main, resourcesApp, Widget, WorldId) where
-import           Control.Concurrent            (runInUnboundThread)
-import           Control.Monad                 (forM)
-import           Control.Monad.Logger          (runNoLoggingT)
-import           Control.Monad.Primitive       (PrimState)
-import           Control.Monad.Trans.Resource  (InternalState)
-import qualified Data.ByteString.Char8 as C8
-import           Data.Pool                     (Pool)
-import           Data.IORef                    (newIORef)
-import           Data.Function                 (on)
-import           Data.List                     (sortBy)
-import           Data.Text                     (Text)
-import           Database.Persist             
-import qualified Database.Persist.Postgresql    as Pg
-import Database.Persist.Sql
-import           Database.Persist.TH           (mkPersist, mpsGeneric,
-                                                persistLowerCase, sqlSettings)
-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 Text.Blaze.Html
-import           Yesod
-import Data.Maybe (fromJust)
-
-mkPersist sqlSettings { mpsGeneric = True } [persistLowerCase|
-World sql=world
-    randomNumber Int sql=randomnumber
-|]
-
-mkPersist sqlSettings { mpsGeneric = True } [persistLowerCase|
-Fortune sql=fortune
-    message Text sql=message
-|]
-
-instance ToJSON (Entity World) where
-  toJSON (Entity wId wRow) = object [
-    "id" .= wId
-    ,"randomNumber" .= (worldRandomNumber wRow)
-    ]
-
-instance ToMarkup FortuneId where
-  toMarkup = toMarkup . fromSqlKey
-
-data App = App
-    { appGen      :: !(R.Gen (PrimState IO))
-    , appDbPool   :: !(Pool Pg.SqlBackend)
-    }
-
-
-mkYesod "App" [parseRoutes|
-/json               JsonR     GET
-/plaintext          PlaintextR   GET
-/db                 DbR          GET
-
-/queries/#Int       QueriesR     GET
-!/queries/#Text      DefaultQueriesR     GET
-
-/fortunes           FortunesR    GET
-
-/updates/#Int       UpdatesR     GET
-!/updates/#Text     DefaultUpdatesR 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
-    {-# INLINE yesodMiddleware #-}
-    cleanPath _ = Right
-    {-# INLINE cleanPath #-}
-    yesodWithInternalState _ _ = ($ fakeInternalState)
-    {-# INLINE yesodWithInternalState #-}
-    maximumContentLength _ _ = Nothing
-    {-# INLINE maximumContentLength #-}
-
-getJsonR :: Handler Value
-getJsonR = returnJson $ object ["message" .= ("Hello, World!" :: Text)]
-
-runPg dbAction = do
-  app <- getYesod
-  runSqlPool dbAction (appDbPool app)
-
-getRandomRow = do
-  app <- getYesod
-  randomNumber <- liftIO $ ((R.uniformR (1, 10000) (appGen app)) :: IO Int)
-  let wId = (toSqlKey $ fromIntegral randomNumber) :: WorldId
-  get wId >>= \case
-    Nothing -> return Nothing
-    Just x -> return $ Just (Entity wId x)
-
-getDbR :: Handler Value
-getDbR = do
-  (runPg getRandomRow) >>= \case
-    -- TODO: Throw appropriate HTTP response
-    Nothing -> error "This shouldn't be happening"
-    Just worldE -> returnJson worldE
-
-getQueriesR :: Int -> Handler Value
-getQueriesR cnt = do
-  result <- (runPg $ forM [1..sanitizedCnt] (\_ -> fmap fromJust getRandomRow))
-  returnJson result
-  where
-    sanitizedCnt
-      | cnt<1 = 1
-      | cnt>500 = 500
-      | otherwise = cnt
-
-getDefaultQueriesR :: Text -> Handler Value
-getDefaultQueriesR _ = getQueriesR 1
-
-getFortunesR :: Handler Html
-getFortunesR = do
-  fortunesFromDb <- runPg $ selectList [] []
-  let fortunes = sortBy (compare `on` fortuneMessage . entityVal) $ (Entity (toSqlKey 0) Fortune{fortuneMessage="Additional fortune added at request time."}):fortunesFromDb
-  defaultLayout $ do
-      setTitle "Fortunes"
-      [whamlet|
-              <table>
-                <tr>
-                  <th>id
-                  <th>message
-                $forall fortune <- fortunes
-                  <tr>
-                    <td>#{entityKey fortune}
-                    <td>#{fortuneMessage $ entityVal fortune}
-                    |]
-
-getUpdatesR :: Int -> Handler Value
-getUpdatesR cnt = do
-  worldRows <- runPg $ forM [1..sanitizedCount] (\_ -> fmap fromJust getRandomRow)
-  app <- getYesod
-  updatedWorldRows <- runPg $ mapM (replaceWorldRow app) worldRows
-  returnJson updatedWorldRows
-  where
-    sanitizedCount
-      | cnt<1 = 1
-      | cnt>500 = 500
-      | otherwise = cnt
-
-    replaceWorldRow app (Entity wId wRow) = do
-      randomNumber <- liftIO $ ((R.uniformR (1, 10000) (appGen app)) :: IO Int)
-      -- TODO: Should I be using replace, or update, or updateGet -- which is
-      -- idiomatic Yesod code for this operation?
-      let newRow = wRow{worldRandomNumber=randomNumber}
-      replace wId newRow
-      return (Entity wId newRow)
-
-
-getDefaultUpdatesR :: Text -> Handler Value
-getDefaultUpdatesR _ = getUpdatesR 1
-
-getPlaintextR :: Handler Text
-getPlaintextR = return "Hello, World!"
-
-main :: IO ()
-main = R.withSystemRandom $ \gen -> do
-    [cores, host] <- getArgs
-    let connString = ("host=" ++ host ++ " port=5432 user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world") 
-    dbPool <- runNoLoggingT $ Pg.createPostgresqlPool (C8.pack connString) 256
-    app <- toWaiAppPlain App
-        { appGen = gen
-        , appDbPool = dbPool
-        }
-
-    runInUnboundThread $ Warp.runSettings
-        ( Warp.setPort 8000
-        $ Warp.setHost "*"
-        $ Warp.setOnException (\_ _ -> return ())
-          Warp.defaultSettings
-        ) app
-

+ 0 - 5
frameworks/Haskell/yesod/yesod-postgres/stack.yaml

@@ -1,5 +0,0 @@
-flags: {}
-packages:
-- '.'
-extra-deps: []
-resolver: lts-6.3

+ 0 - 43
frameworks/Haskell/yesod/yesod-postgres/yesod-postgres.cabal

@@ -1,43 +0,0 @@
-name:              yesod-postgres
-version:           0.0.0
-cabal-version:     >= 1.8
-build-type:        Simple
-
-executable         yesod-postgres
-    main-is:           Main.hs
-    hs-source-dirs:    src
-
-    ghc-options:       -Wall -threaded -O2 -rtsopts
-
-    extensions: TemplateHaskell
-                QuasiQuotes
-                OverloadedStrings
-                MultiParamTypeClasses
-                TypeFamilies
-                GADTs
-                EmptyDataDecls
-                CPP
-
-    build-depends: base
-                 , yesod
-                 , text
-                 , persistent
-                 , persistent-postgresql
-                 , persistent-template
-                 , warp
-                 , auto-update
-                 , primitive
-                 , mwc-random
-                 , resource-pool
-                 , network
-                 , monad-logger
-                 , mtl
-                 , wai
-                 , http-types
-                 , aeson
-                 , blaze-builder
-                 , blaze-html
-                 , bytestring
-                 , resource-pool
-                 , resourcet
-                 , shakespeare

+ 8 - 2
frameworks/Haskell/yesod/yesod.dockerfile

@@ -1,3 +1,9 @@
-FROM techempower/yesod-mongodb-base:0.1
+FROM haskell:7.10.3
 
-CMD stack --allow-different-user exec yesod-mysql-mongo -- $(nproc) tfb-database +RTS -A32m -N$(nproc)
+RUN apt update -yqq && apt install -yqq xz-utils make libpq-dev libmysqlclient-dev pkg-config libpcre3 libpcre3-dev
+
+COPY ./yesod-mysql-mongo ./
+
+RUN stack build -j$(nproc) --skip-ghc-check --no-terminal
+
+CMD stack exec yesod-mysql-mongo -- $(nproc) tfb-database +RTS -A32m -N$(nproc)

+ 0 - 3
toolset/setup/docker/languages/haskell.dockerfile

@@ -1,3 +0,0 @@
-FROM techempower/base:0.1
-
-RUN curl -sSL https://get.haskellstack.org/ | sh