* Start of concurrent garbage collection. Processes write temporary
roots to a per-process temporary file in /nix/var/nix/temproots while holding a write lock on that file. The garbage collector acquires read locks on all those files, thus blocking further progress in other Nix processes, and reads the sets of temporary roots.
This commit is contained in:
		
							parent
							
								
									a7668411a1
								
							
						
					
					
						commit
						1328aa3307
					
				
					 11 changed files with 193 additions and 108 deletions
				
			
		| 
						 | 
				
			
			@ -9,6 +9,7 @@ my $storeDir = "@storedir@";
 | 
			
		|||
my %alive;
 | 
			
		||||
 | 
			
		||||
my $gcOper = "--delete";
 | 
			
		||||
my $extraArgs = "";
 | 
			
		||||
 | 
			
		||||
my @roots = ();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +20,9 @@ for (my $i = 0; $i < scalar @ARGV; $i++) {
 | 
			
		|||
    if ($arg eq "--delete" || $arg eq "--print-live" || $arg eq "--print-dead") {
 | 
			
		||||
        $gcOper = $arg;
 | 
			
		||||
    }
 | 
			
		||||
    elsif ($arg =~ /^-v+$/) {
 | 
			
		||||
        $extraArgs = "$extraArgs $arg";
 | 
			
		||||
    }
 | 
			
		||||
    else { die "unknown argument `$arg'" };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +70,7 @@ findRoots 1, $rootsDir;
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
# Run the collector with the roots we found.
 | 
			
		||||
my $pid = open2(">&1", \*WRITE, "@bindir@/nix-store --gc $gcOper")
 | 
			
		||||
my $pid = open2(">&1", \*WRITE, "@bindir@/nix-store --gc $gcOper $extraArgs")
 | 
			
		||||
    or die "cannot run `nix-store --gc'";
 | 
			
		||||
 | 
			
		||||
foreach my $root (@roots) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue