performance: avoid repeated DB locking on view generation
`ViewDescriptor.regenerate()` checks repeatedly whether packages are installed and also does a lot of DB queries. Put a read transaction around the whole thing to avoid repeatedly locking and unlocking the DB.
This commit is contained in:
		@@ -516,8 +516,11 @@ def regenerate(self, all_specs, roots):
 | 
			
		||||
            if spec.concrete:  # Do not link unconcretized roots
 | 
			
		||||
                specs_for_view.append(spec.copy(deps=('link', 'run')))
 | 
			
		||||
 | 
			
		||||
        installed_specs_for_view = set(s for s in specs_for_view
 | 
			
		||||
                                       if s in self and s.package.installed)
 | 
			
		||||
        # regeneration queries the database quite a bit; this read
 | 
			
		||||
        # transaction ensures that we don't repeatedly lock/unlock.
 | 
			
		||||
        with spack.store.db.read_transaction():
 | 
			
		||||
            installed_specs_for_view = set(
 | 
			
		||||
                s for s in specs_for_view if s in self and s.package.installed)
 | 
			
		||||
 | 
			
		||||
            view = self.view()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user