• Dilemma

    From Branimir Maksimovic@21:1/5 to All on Sat Sep 25 12:19:37 2021
    Let’s compare:
    1000 parallel connections 100k requests

    yesod :
    7658 recs/sec
    Errors 85808
    Timeouted 0

    Mine::
    12699 recs/sec
    Errors 0
    Timeouted 0

    10k connections, 100k requests:
    yesod:
    5205 recs/sec
    Errors 81152
    Timeouted 3842

    Mine:
    8160 recs/sec
    Errors 0
    Timeouted 46

    Sources:
    Yesod:
    / HomeR GET
    |]

    instance Yesod HelloWorld

    getHomeR :: Handler ()
    getHomeR = do
    number <- liftIO (randomIO :: IO Float)
    let txt = pack $ "hello world " ++ show number
    sendResponse (txt:: Text)

    main :: IO ()
    main = warp 3838 HelloWorld

    Mine:
    import Sockets
    import Foreign.C.String
    import Data.IORef
    import Control.Concurrent

    main = do
    ref <- newIORef 1
    s <- socket defaultCallbacks {
    constructor = \ci -> set_cb ci defaultCallbacks {
    done_connected = binded ref,
    done_reading = process
    }
    }
    pl <- epoll 1000
    pl1 <- epoll 1000
    pl2 <- epoll 1000
    pl3 <- epoll 1000
    listen s "8080"
    pl_accept pl s
    pl_accept pl1 s
    pl_accept pl2 s
    pl_accept pl3 s
    let run pl = do forkIO $
    run_loop pl (-1)
    run pl
    run pl1
    run pl2
    run_loop pl3 (-1)

    binded ref pl s = do
    i <- readIORef ref
    putStrLn $ "connection nr:"++show i
    writeIORef ref (i+1)
    pl_read pl s
    return 0

    process pl s buf len = do
    str <- peekCStringLen (buf,fromIntegral len)
    ip <- client s
    str1 <- peekCString ip
    putStrLn $ "from "++str1++" \ngot "++str
    write pl s "Hello World!!!\r\n"
    return 0

    if using -threaded performance is *worse*.

    Dilemma:
    It is mine lib for https://www.volomp.com
    I work now here https://www.rt-rk.com
    on this http://www.vti.mod.gov.rs/index.php?view=actuality&type=projects&category=1&id=72

    I guess that if I port it to Haskell purely from CPP, I won’t have problems with copyright?

    Greetings, Branimir




    --
    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter@21:1/5 to Branimir Maksimovic on Sat Sep 25 19:39:33 2021
    Branimir Maksimovic wrote:
    [...]

    Dilemma:

    You need to be told what a dilemma is. If you must take one of two
    courses of action and both of them bring an unpleasant consequence, then
    you face a dilemma. "Dilemma" _doesn't_ mean "problem in some vague
    sense". I've even come across "dilemma" being used as if it just means "question".

    It is mine lib for https://www.volomp.com
    I work now here https://www.rt-rk.com
    on this http://www.vti.mod.gov.rs/index.php?view=actuality&type=projects&category=1&id=72

    I guess that if I port it to Haskell purely from CPP, I won’t have problems with copyright?

    Greetings, Branimir






    --
    The world will little note, nor long remember what we say here
    Abraham Lincoln at Gettysburg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Branimir Maksimovic@21:1/5 to Peter on Sat Sep 25 19:16:21 2021
    On 2021-09-25, Peter <peterxpercival@hotmail.com> wrote:
    Branimir Maksimovic wrote:
    [...]

    Dilemma:

    You need to be told what a dilemma is. If you must take one of two
    courses of action and both of them bring an unpleasant consequence, then
    you face a dilemma. "Dilemma" _doesn't_ mean "problem in some vague
    sense". I've even come across "dilemma" being used as if it just means "question".


    Question, yes.
    But I already released it in public in Rust form :P https://github.com/bmaxa/web_server_rust
    :P
    It's just that I want to port it to several languages.
    Full web server can anyone complete :p


    --

    7-77-777
    Evil Sinner!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)