Compare commits

..

3 Commits

Author SHA1 Message Date
d200c3bccf docs: Updated README.md 2026-06-22 08:47:56 -04:00
80f163dcde build: added flake files. 2026-06-20 17:56:50 -04:00
3492ff1dad chore: Added TODOs. 2026-06-18 09:13:08 -04:00
6 changed files with 318 additions and 7 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
.direnv
/findr
/findr-prof
*.spall

75
README.md Normal file
View File

@@ -0,0 +1,75 @@
# findr
A partial port of [fd](https://github.com/sharkdp/fd) to
[Odin](https://odin-lang.org/)
Only the `-H`, `-I`, and `-E` flags are supported.
`findr` runs faster than fd on my machine, but feel free to check out the
results for yourself:
```markdown
=== findr benchmark suite ===
Target: /home/spencer
=== File counts ===
fd -a -E .jj . : 460921
findr -E .jj : 460838
fd -a -E .git -E .jj -H . : 3593254
findr -E .git -E .jj -H : 3593254
fd -a -E .git -E .jj -HI . : 4142964
findr -E .git -E .jj -HI : 4142964
fd -a -E .git -E .jj . : 460921
findr -E .git -E .jj : 460838
=== Benchmarks (hyperfine, 5 runs, 2 warmups) ===
Benchmark 1: fd -a -E .jj . "/home/spencer" > /dev/null
Time (mean ± σ): 150.7 ms ± 5.0 ms [User: 1279.9 ms, System: 855.6 ms]
Range (min … max): 147.0 ms … 159.3 ms 5 runs
Benchmark 2: /home/spencer/github.com/findr/findr -E .jj "/home/spencer" > /dev/null
Time (mean ± σ): 97.4 ms ± 0.9 ms [User: 466.5 ms, System: 924.5 ms]
Range (min … max): 96.3 ms … 98.2 ms 5 runs
Benchmark 3: fd -a -E .git -E .jj -H . "/home/spencer" > /dev/null
Time (mean ± σ): 776.1 ms ± 25.9 ms [User: 7444.3 ms, System: 4268.7 ms]
Range (min … max): 745.5 ms … 815.3 ms 5 runs
Benchmark 4: /home/spencer/github.com/findr/findr -E .git -E .jj -H "/home/spencer" > /dev/null
Time (mean ± σ): 437.1 ms ± 5.4 ms [User: 1674.3 ms, System: 4566.7 ms]
Range (min … max): 430.0 ms … 442.4 ms 5 runs
Benchmark 5: fd -a -E .git -E .jj -HI . "/home/spencer" > /dev/null
Time (mean ± σ): 704.1 ms ± 12.9 ms [User: 7049.0 ms, System: 3537.1 ms]
Range (min … max): 687.6 ms … 721.9 ms 5 runs
Benchmark 6: /home/spencer/github.com/findr/findr -E .git -E .jj -HI "/home/spencer" > /dev/null
Time (mean ± σ): 387.3 ms ± 24.9 ms [User: 1828.2 ms, System: 3414.5 ms]
Range (min … max): 363.3 ms … 427.7 ms 5 runs
Benchmark 7: fd -a -E .git -E .jj . "/home/spencer" > /dev/null
Time (mean ± σ): 170.3 ms ± 1.6 ms [User: 1505.3 ms, System: 996.8 ms]
Range (min … max): 169.3 ms … 173.1 ms 5 runs
Benchmark 8: /home/spencer/github.com/findr/findr -E .git -E .jj "/home/spencer" > /dev/null
Time (mean ± σ): 105.5 ms ± 1.2 ms [User: 524.9 ms, System: 1011.0 ms]
Range (min … max): 103.7 ms … 106.9 ms 5 runs
Summary
/home/spencer/github.com/findr/findr -E .jj "/home/spencer" > /dev/null ran
1.08 ± 0.02 times faster than /home/spencer/github.com/findr/findr -E .git -E .jj "/home/spencer" > /dev/null
1.55 ± 0.05 times faster than fd -a -E .jj . "/home/spencer" > /dev/null
1.75 ± 0.02 times faster than fd -a -E .git -E .jj . "/home/spencer" > /dev/null
3.98 ± 0.26 times faster than /home/spencer/github.com/findr/findr -E .git -E .jj -HI "/home/spencer" > /dev/null
4.49 ± 0.07 times faster than /home/spencer/github.com/findr/findr -E .git -E .jj -H "/home/spencer" > /dev/null
7.23 ± 0.15 times faster than fd -a -E .git -E .jj -HI . "/home/spencer" > /dev/null
7.97 ± 0.28 times faster than fd -a -E .git -E .jj -H . "/home/spencer" > /dev/null
=== Results written to /home/spencer/github.com/findr/bench-results.md ===
```

99
flake.lock generated Normal file
View File

@@ -0,0 +1,99 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1778716662,
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1767313136,
"narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1777168982,
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1781173989,
"narHash": "sha256-fnzKKPvS+oieI/pTzotA5tkoM47EB1NpaBcgk4R97hE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8c91a71d13451abc40eb9dae8910f972f979852f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1780220602,
"narHash": "sha256-eynAfOmbmxJnkp7YewvCEbShNnnYJ9gLLqkzsYtBPeM=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "db947814a175b7ca6ded66e21383d938df01c227",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

127
flake.nix Normal file
View File

@@ -0,0 +1,127 @@
{
description = "Manage your .env files.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{
flake-parts,
nixpkgs,
nixpkgs-unstable,
self,
treefmt-nix,
}:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.treefmt-nix.flakeModule
];
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{
pkgs,
system,
inputs',
...
}:
let
mysqlite = pkgs.sqlite.overrideAttrs (old: {
configureFlags = (old.configureFlags or [ ]) ++ [ "--enable-deserialize" ];
});
in
{
_module.args.pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
(_final: _prev: { unstable = inputs'.nixpkgs-unstable.legacyPackages; })
];
};
treefmt = {
projectRootFile = "flake.nix";
settings.global.excludes = [
".direnv/**"
".jj/**"
".env"
".envrc"
".env.local"
];
programs.nixpkgs-fmt.enable = true;
};
packages.default = pkgs.stdenv.mkDerivation rec {
pname = "envr";
version = "0.3.0";
src = ./.;
nativeBuildInputs = [
pkgs.unstable.odin
pkgs.pkg-config
];
buildInputs = [
pkgs.libsodium
mysqlite
];
doCheck = true;
checkPhase = ''
runHook preCheck
odin test . -all-packages
runHook postCheck
'';
buildPhase = ''
runHook preBuild
echo '${version}' > version.txt
odin build . -o:speed -out:${pname}
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 ${pname} $out/bin/${pname}
runHook postInstall
'';
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nushell
libsodium
mysqlite
unstable.odin
unstable.ols
# Build tools
zip
# Helper tools
delta
hyperfine
# IDE
unstable.helix
typescript-language-server
vscode-langservers-extracted
];
};
};
};
}

View File

@@ -1,5 +1,6 @@
package findr
import "core:bytes"
import "core:fmt"
import "core:os"
import "core:strings"
@@ -180,15 +181,22 @@ collect_worker :: proc(t: ^thread.Thread) {
batch, ok := chan.recv(data.ch)
if !ok do break
start := 0
for i in 0 ..< len(batch) {
if batch[i] == '\n' {
for {
remaining: []u8
#no_bounds_check {remaining = batch[start:]}
idx := bytes.index_byte(remaining, '\n')
if idx < 0 do break
i := start + idx
if i > start {
s, _ := strings.clone(string(batch[start:i]))
segment: []u8
#no_bounds_check {segment = batch[start:i]}
s, _ := strings.clone(string(segment))
append(data.results, s)
}
start = i + 1
}
}
delete(batch)
}
}