Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Gamari bgamari

View GitHub Profile
View uring-test.sh
ulimit -n 32000
_build/stage1/bin/ghc -O -threaded -rtsopts EchoServer.hs -debug
./EchoServer +RTS -N4 -s -DS -RTS &
echo 'GET http://localhost:3000/' | nix run nixpkgs.vegeta -c vegeta attack -rate 4000 -body Vagrantfile >out
kill %1
nix run nixpkgs.vegeta -c vegeta report < out
@bgamari
bgamari / default.nix
Last active May 27, 2020
haskell-nix configuration for cross-compiling Hadolint
View default.nix
let
haskellNixSrc = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/a823ba4b7126d11ca272ef70b842b0ea5523fcfd.tar.gz;
haskellNix = import haskellNixSrc {};
nixpkgsSrc = haskellNix.sources.nixpkgs-2003;
nixpkgsArgs = haskellNix.nixpkgsArgs;
in
{ pkgs ? (import nixpkgsSrc nixpkgsArgs).pkgsCross.aarch64-multiplatform-musl
}:
let
hspkgs = pkgs.haskell-nix.stackProject {
View nofib-no-dsymutil.patch
diff --git a/runstdtest/runstdtest.prl b/runstdtest/runstdtest.prl
index 4ac632f..fb12099 100644
--- a/runstdtest/runstdtest.prl
+++ b/runstdtest/runstdtest.prl
@@ -209,7 +209,7 @@ if ($PostScript ne '') {
# OK, so we're gonna do the normal thing...
if ($Cachegrind eq 'yes') {
- $CachegrindPrefix = "valgrind --tool=cachegrind --log-fd=9 9>$CachegrindStats";
+ $CachegrindPrefix = "valgrind --tool=cachegrind --dsymutil=no --log-fd=9 9>$CachegrindStats";
View round.c
#include <stdint.h>
#include <fenv.h>
float hs_word2float32_old(uint64_t x) {
return (float)x;
}
float hs_word2float32_new(uint64_t x) {
int r = fegetround();
fesetround(FE_TOWARDZERO);
@bgamari
bgamari / demangle-ghc.c
Last active Dec 28, 2019
Demangler for GHC's Z encoding
View demangle-ghc.c
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/*
* See https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/symbol-names
*/
/*
* Returns number of characters decoded including NULL-terminator or zero if
View ghc-timings
CPU time, elapsed
Productivity Mutator GC
CPU elapsed CPU elapsed
------------- ----- -------- ----- --------
-j1 -A1M 83% 33.5 43.9 6.8 6.8
-j4 -A1M 56% 48.4 24.4 38.8 10.9
-j4 -A16M 60% 49.3 25.0 33.2 9.3
-j4 -A64M 80% 49.7 25.4 11.9 3.5
-j4 -A16M -qn2 77% 49.0 24.6 14.7 7.5
@bgamari
bgamari / bfd
Created Jul 26, 2019
linker timings
View bfd
0.63 4.02
0.64 3.98
0.62 3.93
0.57 3.94
0.63 3.90
0.58 3.88
0.62 3.87
0.68 4.09
0.62 4.09
0.61 4.09
View Errors.mkd
title
Rich errors messages in GHC

Pretty-printer with point annotations

See the proposal.

Pros

View stack.hs
data StackField b = PointerField b
| WordField !Word
data StackFrame b = StackFrame { infoTable :: StgInfoTable
, fields :: [StackField b]
}
data GenClosure b = ...
| StackClosure [StackFrame b]
View test.sh
#!/usr/bin/bash
set -e
rm -f *.hi *.o
args="-O -package-env -"
#args="$args -ddump-hi-diffs -ddump-hi"
cat >Z.hs <<EOF
module Z where
class Hello a where
You can’t perform that action at this time.