An update on `kiritan` & `subatomic` (alternative to `createrepo_c`)

This is a continuation from the post I’ve made 2 months ago at https://discussion.fedoraproject.org/t/kiritan-alternative-to-createrepo-c-10x-faster-30x-less-ram. The feedback overall was positive, thank you very much!

TL;DR: kiritan is an alternative to createrepo_c, written in Rust, and many times more efficient in memory and performance. subatomic is an API server for receiving RPM uploads and handles the repomd too.

Anyway I’ve recently released subatomic 1.1.4. We added support for storing RPMs on an S3-compatible bucket. We’re currently testing it out but it seems to be working fine. I think we will probably use subatomic in production very soon.

Since we had some left-over infra power from one of my staff in Fyra Stack, we decided to download most of Fedora’s repository and test it against kiritan and createrepo_c. Here are the quick statistics:

Cache enabled

Well I promised kiritan’s memory usage is O(1), and I do mean it. Here’s the graph for createrepo_c for reference:

hyperfine -w 1 '../kiritan --compact auto' 'createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .'
Benchmark 1: ../kiritan --compact auto
  Time (mean ± σ):      7.666 s ±  0.149 s    [User: 7.896 s, System: 1.773 s]
  Range (min … max):    7.455 s …  7.892 s    10 runs
 
Benchmark 2: createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .
  Time (mean ± σ):     34.028 s ±  0.247 s    [User: 60.206 s, System: 22.632 s]
  Range (min … max):   33.685 s … 34.361 s    10 runs
 
Summary
  ../kiritan --compact auto ran
    4.44 ± 0.09 times faster than createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .

To the extent of my knowledge most of the time spent in kiritan is just zstd compressions on the repodata files. I believe 7.5 s is probably close to the limit for any reasonable implementations.

Cache disabled


hyperfine -p 'rm -rf repodata .subatomic-cache || true' -w 1 -m 5 '../kiritan --compact auto' 'createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .'Benchmark 1: ../kiritan --compact auto
  Time (mean ± σ):     49.075 s ±  0.154 s    [User: 438.284 s, System: 28.395 s]
  Range (min … max):   48.860 s … 49.278 s    5 runs
 
Benchmark 2: createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .
  Time (mean ± σ):     95.524 s ±  0.056 s    [User: 263.958 s, System: 45.500 s]
  Range (min … max):   95.458 s … 95.594 s    5 runs
 
Summary
  ../kiritan --compact auto ran
    1.95 ± 0.01 times faster than createrepo_c --update --skip-stat --local-sqlite --workers 48 --ignore-lock .

Conclusion

On Fedora 44 repository (70069 packages):

  • Without caching: ~2× faster, ~8× less memory
  • With caching: ~4× faster, ~35× less memory

Future

As the main author of subatomic, I acknowledge that writing subatomic / kiritan in Rust nightly definitely makes this harder to be packaged in Fedora. There are many reasons by design why I chose Rust nightly and I think this will unfortunately stick until something like “subatomic v2” (one of them being default_field_values).

However, working with the underlying libsubatomic library is very easy (partially because we’re using nightly ironically). I’ve placed quite some effort to make libsubatomic very easily usable by other people, e.g. by publishing this on crates.io. As an example you can define your own metadata types apart from just primary, other, filelists and appstream (this customisation is possible because I noticed there are other metadata types in OpenSUSE). The revamp between 1.0.0 and 1.1.0 also allowed many more other combinations of configurations, we support different file hierarchy (the one we use in Terra which places all rpms in the same directory, vs. the one Fedora uses which places rpms in the directory named by the first character of the package name), compression algorithms, checksum algorithms, and as mentioned you can host rpm files on a local filesystem or a remote S3-compatible bucket.

I’m very happy to work with Fedora if you guys would like to use this in your infra, and in the future we may also de-nightly-ify subatomic. Maybe we can find a way around (we have docker containers that come with the server binary that we’re using in prod, maybe that’s also possible?)

That’s all for subatomic/kiritan for now, thank you!