Skip to content

Commit

Permalink
WIP: Enable TCP_NODELAY
Browse files Browse the repository at this point in the history
This should be optional; for now we're just testing if this works at all.
  • Loading branch information
edsko committed Jul 4, 2024
1 parent 1d38f88 commit 0982c75
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 33 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.19.20240608
# version: 0.19.20240702
#
# REGENDATA ("0.19.20240608",["github","cabal.project.ci"])
# REGENDATA ("0.19.20240702",["github","cabal.project.ci"])
#
name: Haskell-CI
on:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
apt-get update
apt-get install -y libsnappy-dev
env:
Expand All @@ -88,7 +88,7 @@ jobs:
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -175,6 +175,16 @@ jobs:
allow-newer: proto-lens:base
allow-newer: proto-lens-runtime:base
source-repository-package
type: git
location: https://github.com/edsko/network-run
tag: 70211ef61ebbf178d6681ec37d3293d720ec9030
source-repository-package
type: git
location: https://github.com/edsko/http2-tls
tag: 53d8b7a0d2a044606de0906e5b66a1f2bce549bd
package grapesy
tests: True
benchmarks: True
Expand Down
10 changes: 10 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ package grapesy
benchmarks: True
flags: +build-demo +build-stress-test +snappy

source-repository-package
type: git
location: https://github.com/edsko/network-run
tag: 70211ef61ebbf178d6681ec37d3293d720ec9030

source-repository-package
type: git
location: https://github.com/edsko/http2-tls
tag: 53d8b7a0d2a044606de0906e5b66a1f2bce549bd

--
-- ghc 9.10
--
Expand Down
10 changes: 10 additions & 0 deletions cabal.project.ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ package grapesy
flags: +build-demo +build-stress-test +snappy +strace
ghc-options: -Werror

source-repository-package
type: git
location: https://github.com/edsko/network-run
tag: 70211ef61ebbf178d6681ec37d3293d720ec9030

source-repository-package
type: git
location: https://github.com/edsko/http2-tls
tag: 53d8b7a0d2a044606de0906e5b66a1f2bce549bd

--
-- ghc 9.10
--
Expand Down
31 changes: 7 additions & 24 deletions grapesy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,29 @@ library
, case-insensitive >= 1.2 && < 1.3
, conduit >= 1.3 && < 1.4
, containers >= 0.6 && < 0.8
, crypton-x509 >= 1.7 && < 1.8
, crypton-x509-store >= 1.6 && < 1.7
, crypton-x509-system >= 1.6 && < 1.7
, data-default >= 0.7 && < 0.8
, deepseq >= 1.4 && < 1.6
, exceptions >= 0.10 && < 0.11
, hashable >= 1.3 && < 1.5
, http-types >= 0.12 && < 0.13
, http2 >= 5.2.4 && < 5.3
, http2-tls >= 0.2.11 && < 0.3
, http2-tls >= 0.3.1 && < 0.4
, lens >= 5.0 && < 5.4
, mtl >= 2.2 && < 2.4
, network >= 3.1 && < 3.3
, network-byte-order >= 0.1 && < 0.2
, network-run >= 0.2.7 && < 0.3
, network-run >= 0.3.2 && < 0.4
, proto-lens >= 0.7 && < 0.8
, proto-lens-runtime >= 0.7 && < 0.8
, random >= 1.2 && < 1.3
, record-hasfield >= 1.0 && < 1.1
, stm >= 2.5 && < 2.6
, text >= 1.2 && < 2.2
, time-manager >= 0.1 && < 0.2
, tls >= 2.1 && < 2.2
, unbounded-delays >= 0.1.1 && < 0.2
, unordered-containers >= 0.2 && < 0.3
, utf8-string >= 1.0 && < 1.1
Expand All @@ -238,22 +242,6 @@ library
build-depends:
, snappy-c >= 0.1 && < 0.2

-- tls 1.7 starts using Kazu's forked versions of x509-* packages
if flag(crypton)
-- Lower bounds are the first version of these packages after forking.
build-depends:
, tls >= 1.7 && < 2.1
, crypton-x509 >= 1.7 && < 1.8
, crypton-x509-store >= 1.6 && < 1.7
, crypton-x509-system >= 1.6 && < 1.7
else
-- Upper bounds are the final version of these packages before forking.
build-depends:
, tls >= 1.5 && < 1.7
, x509 >= 1.7 && < 1.8
, x509-store >= 1.6 && < 1.7
, x509-system >= 1.6 && < 1.7

test-suite test-record-dot
import:
, lang
Expand Down Expand Up @@ -362,7 +350,7 @@ test-suite test-grapesy
, tasty-hunit >= 0.10 && < 0.11
, tasty-quickcheck >= 0.10 && < 0.11
, text >= 1.2 && < 2.2
, tls >= 1.5 && < 2.1
, tls >= 2.1 && < 2.2
, tree-diff >= 0.3 && < 0.4

executable demo-client
Expand Down Expand Up @@ -617,11 +605,6 @@ Flag build-stress-test
default: False
manual: True

Flag crypton
description: Use the crypton-x509-* package family instead of x509-*
default: True
manual: False

Flag snappy
description: Enable snappy compression capabilities
default: True
Expand Down
17 changes: 13 additions & 4 deletions src/Network/GRPC/Client/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ connectSecure connParams attempt validation sslKeyLog addr = do
case validation of
ValidateServer _ -> True
NoServerValidation -> False
, HTTP2.TLS.Client.settingsCAStore = caStore
, HTTP2.TLS.Client.settingsKeyLogger = keyLogger
, HTTP2.TLS.Client.settingsAddrInfoFlags = []

, HTTP2.TLS.Client.settingsCAStore = caStore
, HTTP2.TLS.Client.settingsKeyLogger = keyLogger
, HTTP2.TLS.Client.settingsAddrInfoFlags = []
, HTTP2.TLS.Client.settingsOpenClientSocket = openClientSocket

, HTTP2.TLS.Client.settingsConcurrentStreams =
fromIntegral $
Expand Down Expand Up @@ -626,7 +628,14 @@ overridePingRateLimit connParams clientConfig = clientConfig {

runTCPClient :: Address -> (Socket -> IO a) -> IO a
runTCPClient Address{addressHost, addressPort} =
Run.runTCPClient addressHost (show addressPort)
Run.runTCPClientWithSocket openClientSocket addressHost (show addressPort)

openClientSocket :: AddrInfo -> IO Socket
openClientSocket =
Run.openClientSocketWithOptions socketOptions
where
socketOptions :: [(SocketOption, Int)]
socketOptions = [(NoDelay, 1)]

-- | Write-buffer size
--
Expand Down
5 changes: 4 additions & 1 deletion src/Network/GRPC/Server/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,12 @@ disableTimeout =

openServerSocket :: TMVar Socket -> AddrInfo -> IO Socket
openServerSocket socketTMVar addr = do
sock <- Run.openServerSocket addr
sock <- Run.openServerSocketWithOptions socketOptions addr
atomically $ putTMVar socketTMVar sock
return sock
where
socketOptions :: [(SocketOption, Int)]
socketOptions = [(NoDelay, 1)]

writeBufferSize :: BufferSize
writeBufferSize = 4096

0 comments on commit 0982c75

Please sign in to comment.