Skip to content
TKTail

Purpose-built scripts and the TKTail workflow - the source

README.md

SHA-256 (LF line endings, as in the source ZIP): 05d0f9affcf0fc5db7e2d46f52b0b64ce33a6d4866128af87053a2d70b87f09b · MIT license (the benchmark suite only)

# TKTail competitive benchmark (competitive-bench-v1)

How long do common production-log questions take - and how much data has to move - with TKTail, and with
competent PowerShell, C# and Python scripts that answer the same questions on the same bytes?

This folder is the complete, reproducible suite: the scenario definitions, every compared implementation, the
deterministic dataset generator, the orchestration that checks and measures them, and the summary tools. It is
published unchanged as `TKTail-Competitive-Benchmarks-competitive-bench-v1.zip`; the numbers on tktail.dev were
produced by exactly this source.

The comparison is between **these concrete implementations, for these tasks, on the measured machine** - not between
programming languages. Every implementation must first produce the generator's ground truth, or it is not timed.

## The questions (scenarios)

| Scenario | Data | Task |
|---|---|---|
| `literal-error` | application log | lines containing `ERROR` (case-sensitive) |
| `elapsed-ge-1000` | application log | records whose `elapsed: <number>ms` is 1000 or more (the number read exactly) |
| `count-5xx` | IIS W3C | requests with `sc-status` 500 or higher |
| `count-slow` | IIS W3C | requests with `time-taken` 1000 or more |
| `top-ip-5xx` | IIS W3C | the 10 client addresses (`c-ip`) with the most 5xx requests |
| `top-uri-5xx` | IIS W3C | the 10 URL paths (`cs-uri-stem`) with the most 5xx requests |
| `per-minute-5xx` | IIS W3C | 5xx requests per minute (UTC), in time order |
| `top-ip-503-post` | IIS W3C | the 10 client addresses with the most POST requests answered 503 |

Plus two workflow scenarios: **payload** (what an AI client receives to answer "the top 10 clients" - every record,
projected result pages, or TKTail's aggregation) and **session** (five questions of one investigation in a row).
Definitions in code: `scripts/scenarios.py`. Method: [methodology/METHODOLOGY.md](methodology/METHODOLOGY.md).

## The implementations

| Name | What | Source |
|---|---|---|
| `tktail` | TKTail through its interface for AI clients (MCP over stdio): `tktail_search`, with `aggregate` for top / histogram questions | `tktail/tktail_driver.py` |
| `csharp` | .NET 10, Release, x64; 1 MB blocks as byte spans, vectorized `IndexOf`, `Utf8Parser`, no string per line | `csharp/Program.cs` |
| `python` | CPython, standard library only; binary line iteration, `bytes.find`, `split`, dict counting | `python/bench.py` |
| `pwsh7`, `ps51` | PowerShell 7 and Windows PowerShell 5.1, optimized streaming: `StreamReader.ReadLine`, ordinal `Contains` / `IndexOf`, `Split`, a generic `Dictionary` | `powershell/bench.ps1` |
| `pwsh7-idiomatic` | a convenience baseline - the cmdlets an administrator types: `Select-String`, `Get-Content | ConvertFrom-Csv | Group-Object` | `powershell/idiomatic.ps1` |

All are single-threaded. The scripts read the input and write only their results (no system change, no
administrator rights). Inspect them before you run them.

## Requirements

- Windows 10 or 11 / Windows Server 2016 or later, x64; about 3 GB of free disk for the 1 GB datasets.
- **TKTail** 1.1.0 or later (`TKTail.exe` from <https://tktail.dev/download/>) - a copy of it runs in its own data
  folder and instance family; your TKTail and its settings are not touched.
- **.NET SDK** 10.0 (`dotnet --version`; `csharp/global.json` rolls forward within 10.0). Tested: SDK 10.0.403.
- **Python**, CPython, the standard library only - no packages to install. Tested: 3.13.0 (the code uses nothing
  newer than Python 3.8).
- **PowerShell 7** (`pwsh`) and Windows PowerShell 5.1 (built into Windows). Tested: 7.6.9 and 5.1.26100. Either
  can be left out with `--skip pwsh7` / `--skip ps51`.

The versions of a run are recorded in its `environment.json`.

## Reproduce

```
cd TKTail-Competitive-Benchmarks-competitive-bench-v1

# 1. the datasets (deterministic: the same seed gives the same bytes; the configs hold the expected SHA-256)
python datasets\generate.py --config datasets\configs\applog-1gb.json --out D:\bench\data
python datasets\generate.py --config datasets\configs\iis-1gb.json --out D:\bench\data
python datasets\generate.py --config datasets\configs\iis-100mb.json --out D:\bench\data

# 2. correctness first, then the measurements (builds the C# baseline itself: dotnet build -c Release)
python scripts\run.py --tktail C:\Tools\TKTail\TKTail.exe --data D:\bench\data --out D:\bench\results --size 1gb

# only the correctness check (minutes, not hours)
python scripts\run.py --tktail C:\Tools\TKTail\TKTail.exe --data D:\bench\data --out D:\bench\results --size 1gb --phases correctness
```

`run.py` writes a new folder per run: `environment.json` (machine, runtimes, the TKTail exe's SHA-256),
`correctness.json`, `raw.jsonl` (every measurement), `payload.json`, `summary.json`, `summary.csv` and `summary.md`
(`scripts/summarize.py` computes them from `raw.jsonl` - nothing is typed by hand). A full run at 1 GB takes a few
hours, most of it the PowerShell baselines. Each implementation can also be run alone, e.g.
`dotnet csharp\bin\Release\net10.0\win-x64\CompetitiveBench.dll --scenario top-ip-5xx --input D:\bench\data\iis-1gb.log`.

## Files

```
README.md, LICENSE (MIT - this suite only), BENCHMARK-MANIFEST.json, SOURCE-SHA256SUMS.txt
methodology/METHODOLOGY.md   cold / warm, cache, repetitions, order, statistics, fairness notes, the code review
scripts/                     run.py (orchestration), scenarios.py (definitions), summarize.py, top_from_pages.py
tktail/                      tktail_driver.py (TKTail over MCP stdio)
csharp/                      CompetitiveBench.csproj, Program.cs, global.json
python/                      bench.py
powershell/                  bench.ps1 (optimized streaming), idiomatic.ps1 (convenience pipeline)
datasets/                    generate.py, configs/*.json, README.md
results/                     README.md (the result files and their fields)
```