According to following two benchmarks: - https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison/ - http://catchchallenger.first-world.info/wiki/Quick_Benchmark:_Gzip_vs_Bzip2_vs_LZMA_vs_XZ_vs_LZ4_vs_LZO xz has better compression ratio than bzip2 at lowest compression rate. https://github.com/vasi/pixz has been chosen as it can scale compressing over multiple cores linearly. We're using this in snabblab for a month now and it has improved CPU wise the main Hydra server.
28 lines
592 B
Perl
28 lines
592 B
Perl
package Hydra::View::NixNAR;
|
|
|
|
use strict;
|
|
use base qw/Catalyst::View/;
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
sub process {
|
|
my ($self, $c) = @_;
|
|
|
|
my $storePath = $c->stash->{storePath};
|
|
my $numThreads = $c->config->{'compress_num_threads'};
|
|
my $pParam = ($numThreads > 0) ? "-p$numThreads" : "";
|
|
|
|
$c->response->content_type('application/x-nix-archive'); # !!! check MIME type
|
|
|
|
my $fh = new IO::Handle;
|
|
|
|
open $fh, "nix-store --dump '$storePath' | pixz -0 $pParam |";
|
|
|
|
setCacheHeaders($c, 365 * 24 * 60 * 60);
|
|
|
|
$c->response->body($fh);
|
|
|
|
return 1;
|
|
}
|
|
|
|
1;
|