This post is a modernized version of an earlier post of mine in my main blog.
This post’s “published” date reflects the date the original post was published.
Recently, we started the process of upgrading gitoxide’s dependency on imara-diff from 0.1.8 to 0.2.0 (tracked in this issue). Because imara-diff’s API has changed significantly, the changes are currently behind a feature flag. What I’ve been wondering, though, is whether this update has any impact on gix-blame’s performance as gix-blame spends a lot of time diffing two versions of a file.
Running the benchmark
In order to collect some data, I compiled two versions of the gix binary via cargo build --release --features blame-experimental and cargo build --release. Then I used hyperfine to run gix blame on a set of 9 files in my local copy of the gitoxide repo.
This will create a couple of Markdown files, benchmark-1.json through benchmark-9.json.
Loading the data
Then, in order to work with these files, we’re going to use numpy and pandas to load them into data.
A few helper functions for loading the data
import numpy as npimport pandas as pdimport matplotlib as mplimport seaborn as snsimport jsondef load_results(filename):withopen(filename) as f:return json.load(f)["results"]def extract_data_points(result): command = result["command"] path = result["parameters"]["path"]return {"command": command, "path": path, "time": result["times"]}
filenames = [f"benchmark-{i}.json"for i inrange(1, 10)]results = [load_results(filename) for filename in filenames]results = [extract_data_points(result) for result in np.concatenate(results)]data = pd.concat( [pd.DataFrame(result) for result in results], ignore_index=True,)
And finally, we’re going to create 2 plots that will give us an idea of how both versions of gix blame compare with respect to performance. Looking in particular at the boxplot, it seems that performance got better for files that are changed frequently, such as CHANGELOG.md and README.md.
It seems that the version using imara-diff 0.2 has a slight advantage over the version using imara-diff 0.1 when it comes to some of the files that have changed a lot over the course of gitoxide’s history, such as CHANGELOG.md or README.md. Cargo.toml, on the other hand, doesn’t fit that diagnosis. For files that changed less frequently, the situation is much closer, so I don’t want to draw too many conclusions.