commit 8731afe374414c9a24c6aa0f599ed1bbbf2be3f6
parent fb63457f2e894eda28250dfe65d0fcd1d195ac2f
Author: Jared Tobin <jared@jtobin.io>
Date: Sun, 28 Dec 2025 11:31:12 -0330
lib: patch version, ghc, llvm bump
Diffstat:
5 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
@@ -39,17 +39,18 @@ Current benchmark figures on 1kb inputs on a relatively-beefy NixOS VPS look
like (use `cabal bench` to run the benchmark suite):
```
- benchmarking encode/ppad-base16
- time 7.634 μs (7.543 μs .. 7.749 μs)
- 0.999 R² (0.998 R² .. 0.999 R²)
- mean 7.693 μs (7.622 μs .. 7.768 μs)
- std dev 240.6 ns (196.5 ns .. 324.8 ns)
+ benchmarking ppad-base16
+ time 2.997 μs (2.988 μs .. 3.009 μs)
+ 1.000 R² (1.000 R² .. 1.000 R²)
+ mean 3.024 μs (3.012 μs .. 3.035 μs)
+ std dev 39.14 ns (36.12 ns .. 42.87 ns)
+ variance introduced by outliers: 11% (moderately inflated)
benchmarking ppad-base16
- time 1.893 μs (1.871 μs .. 1.919 μs)
- 0.998 R² (0.998 R² .. 0.999 R²)
- mean 1.897 μs (1.871 μs .. 1.924 μs)
- std dev 91.64 ns (74.26 ns .. 118.2 ns)
+ time 599.0 ns (597.3 ns .. 601.3 ns)
+ 1.000 R² (1.000 R² .. 1.000 R²)
+ mean 597.3 ns (596.3 ns .. 598.5 ns)
+ std dev 3.493 ns (2.623 ns .. 5.111 ns)
```
## Security
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -1,4 +1,5 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
@@ -17,11 +18,16 @@ main = defaultMain [
]
minimal_encode :: Benchmark
-minimal_encode = bench "ppad-base16" $ nf B16.encode (BS.replicate 1024 0x00)
+minimal_encode =
+ let !a = BS.replicate 1024 0x00
+ in bench "ppad-base16/encode" $
+ nf B16.encode a
minimal_decode :: Benchmark
-minimal_decode = bench "ppad-base16" $ nf B16.decode
- (B16.encode (BS.replicate 512 0x00))
+minimal_decode =
+ let !a = B16.encode (BS.replicate 512 0x00)
+ in bench "ppad-base16/decode" $
+ nf B16.decode a
encode :: Benchmark
encode = bgroup "encode" [
diff --git a/flake.lock b/flake.lock
@@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
- "lastModified": 1710146030,
- "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1725910328,
- "narHash": "sha256-n9pCtzGZ0httmTwMuEbi5E78UQ4ZbQMr1pzi5N0LAG8=",
+ "lastModified": 1766840161,
+ "narHash": "sha256-Ss/LHpJJsng8vz1Pe33RSGIWUOcqM1fjrehjUkdrWio=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "5775c2583f1801df7b790bf7f7d710a19bac66f4",
+ "rev": "3edc4a30ed3903fdf6f90c837f961fa6b49582d1",
"type": "github"
},
"original": {
@@ -40,11 +40,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
- "lastModified": 1737297101,
- "narHash": "sha256-EnXnq+JLflbWt+DvaGGnY2gfAqsGNOm5vPgHh3hkfwQ=",
+ "lastModified": 1766932084,
+ "narHash": "sha256-GvVsbTfW+B7IQ9K/QP2xcXJAm1lhBin1jYZWNjOzT+o=",
"ref": "master",
- "rev": "f29823875250bc99b3891f7373535ccde9a29a44",
- "revCount": 1,
+ "rev": "353e61763b959b960a55321a85423501e3e9ed7a",
+ "revCount": 2,
"type": "git",
"url": "git://git.ppad.tech/nixpkgs.git"
},
diff --git a/flake.nix b/flake.nix
@@ -18,8 +18,9 @@
pkgs = import nixpkgs { inherit system; };
hlib = pkgs.haskell.lib;
+ llvm = pkgs.llvmPackages_19.llvm;
- hpkgs = pkgs.haskell.packages.ghc981.extend (new: old: {
+ hpkgs = pkgs.haskell.packages.ghc910.extend (new: old: {
${lib} = old.callCabal2nixWithOptions lib ./. "--enable-profiling" {};
});
@@ -38,10 +39,9 @@
buildInputs = [
cabal
cc
+ llvm
];
- inputsFrom = builtins.attrValues self.packages.${system};
-
doBenchmark = true;
shellHook = ''
@@ -50,6 +50,7 @@
echo "cc: $(${cc}/bin/cc --version)"
echo "ghc: $(${ghc}/bin/ghc --version)"
echo "cabal: $(${cabal}/bin/cabal --version)"
+ echo "llc: $(${llvm}/bin/llc --version | head -2 | tail -1)"
'';
};
}
diff --git a/ppad-base16.cabal b/ppad-base16.cabal
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: ppad-base16
-version: 0.2.0
+version: 0.2.1
synopsis: Pure base16 encoding and decoding on bytestrings.
license: MIT
license-file: LICENSE
@@ -8,11 +8,16 @@ author: Jared Tobin
maintainer: jared@ppad.tech
category: Cryptography
build-type: Simple
-tested-with: GHC == 9.8.1
+tested-with: GHC == { 9.10.3 }
extra-doc-files: CHANGELOG
description:
Pure base16 (hexadecimal) encoding and decoding on bytestrings.
+flag llvm
+ description: Use GHC's LLVM backend.
+ default: False
+ manual: True
+
source-repository head
type: git
location: git.ppad.tech/base16.git
@@ -22,6 +27,8 @@ library
hs-source-dirs: lib
ghc-options:
-Wall
+ if flag(llvm)
+ ghc-options: -fllvm -O2
exposed-modules:
Data.ByteString.Base16
build-depends: