Skip to content

Instantly share code, notes, and snippets.

@larskuhtz
larskuhtz / README.md
Last active August 29, 2015 14:13
performance: http-client versus http-streams

Performance of http-streams and http-client

We compare the performance of the http-streams and the http-client libraries. The focus is on making a large number of small concurrent requests. This typically occurs in services that use HTTP to connect to backend services, such as a database, message queue, or log-message sink. Often those backend services use relatively small JSON encoded messages.

@larskuhtz
larskuhtz / AsyncExc.hs
Last active August 29, 2015 14:20
Throwing asynchronous exceptions on threads with finalizers
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnicodeSyntax #-}
-- | The tools for forking and managing threads from 'Control.Concurrent' and
-- 'Control.Concurrent.Async' don't guarantee that finalizers or exception
-- handlers on the thread are executed when an exception is raised on the
@larskuhtz
larskuhtz / GadtsAndClosedTypeFamilies.hs
Last active April 1, 2016 01:34
GADTs and Close Type Families
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
module GadtClosedFamilyTest where
-- -------------------------------------------------------------------------- --
-- type level peano numbers
data Nat = Z | S Nat
@larskuhtz
larskuhtz / RandomByteString.hs
Created April 26, 2017 16:15
Efficiently Generate Random Haskell ByteString
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE BangPatterns #-}
module RandomByteString
( random
, randomGen
) where
import Control.Exception (bracketOnError)
@larskuhtz
larskuhtz / Clock.hs
Last active October 19, 2017 22:23
A shared clock for DejaFu
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UnicodeSyntax #-}
-- |
@larskuhtz
larskuhtz / Main.hs
Last active June 10, 2019 21:53
Microbenchmarks for comparing time and thyme packages
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UnicodeSyntax #-}
-- |
-- Module: Main
-- Copyright: Copyright © 2018 Kadena LLC.
@larskuhtz
larskuhtz / script.sh
Created October 2, 2018 16:56
Demonstrate incompatibility of Haskell packages cryptonite and blake2
#!/bin/bash
# The Haskell packages cryptonite and blake2 both include a version
# of the C sources of the blake2 reference implementation. Linking
# both packages into the same Haskell binary can result in a broken
# binary that produces unsound results.
TDIR=$(mktemp -d "${TMPDIR:-/tmp/}$(basename $0).XXXXXXXXXXXX")
trap "{ rm -rf "$TDIR"; }" EXIT
@larskuhtz
larskuhtz / WrappedException.hs
Last active October 16, 2018 20:53
Safely Wrapping Exception in Haskell
{-# LANGUAGE ScopedTypeVariables #-}
module WrappedException
( main
) where
import Control.Concurrent
import Control.Exception (SomeAsyncException(..))
import Control.Monad.Catch
@larskuhtz
larskuhtz / README.md
Last active December 4, 2018 23:05
Haskell Benchmarks for Concurrent Transactions with Many Shared Variables

Setup

This gist contains benchmarks for read-only concurrent transaction that involve many shared variables. The test data is a mutable single-linked list where individual list "cells" are linked via mutable shared variables. The goal is to measure the overhead of different transaction types and variables in read-only transactions when there are no concurrent writes.

The input to a benchmark run is a list of a of successive Int values. The benchmark code runs a number of concurrent threads that each fold over the list and each compute the sum of all entries. The list isn't mutated during the benchmarks.

@larskuhtz
larskuhtz / README.md
Last active April 9, 2020 00:03
Chainweb Performance Numbers

Updated Results [2020-04-08]

transfers (tx/min) orphan rate (%) block time (s) pact validation (ms) cut processing (ms) pending tx CPU (cores) Mem (MB) Git Rev
12,000 5% 40 (target 30) 1500-2000 1500-2000 - - - -
15,000 6-7% 40 (target 30) 2000 1500-2000 - - - -

Results