Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
a728780f
Commit
a728780f
authored
8 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
Store::computeFSClosure(): Use thread pool
This speeds up queries against the binary cache.
parent
77c2739c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libstore/misc.cc
+48
-27
48 additions, 27 deletions
src/libstore/misc.cc
with
48 additions
and
27 deletions
src/libstore/misc.cc
+
48
−
27
View file @
a728780f
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include
"globals.hh"
#include
"globals.hh"
#include
"local-store.hh"
#include
"local-store.hh"
#include
"store-api.hh"
#include
"store-api.hh"
#include
"thread-pool.hh"
namespace
nix
{
namespace
nix
{
...
@@ -10,43 +11,63 @@ namespace nix {
...
@@ -10,43 +11,63 @@ namespace nix {
void
Store
::
computeFSClosure
(
const
Path
&
path
,
void
Store
::
computeFSClosure
(
const
Path
&
path
,
PathSet
&
paths
,
bool
flipDirection
,
bool
includeOutputs
,
bool
includeDerivers
)
PathSet
&
paths
,
bool
flipDirection
,
bool
includeOutputs
,
bool
includeDerivers
)
{
{
if
(
paths
.
find
(
path
)
!=
paths
.
end
())
return
;
ThreadPool
pool
;
paths
.
insert
(
path
);
PathSet
edges
;
Sync
<
bool
>
state_
;
if
(
flipDirection
)
{
std
::
function
<
void
(
Path
)
>
doPath
;
queryReferrers
(
path
,
edges
);
if
(
includeOutputs
)
{
doPath
=
[
&
](
const
Path
&
path
)
{
PathSet
derivers
=
queryValidDerivers
(
path
);
{
for
(
auto
&
i
:
derivers
)
auto
state
(
state_
.
lock
());
edges
.
insert
(
i
);
if
(
paths
.
count
(
path
))
return
;
paths
.
insert
(
path
);
}
}
if
(
includeDerivers
&&
isDerivation
(
path
))
{
PathSet
outputs
=
queryDerivationOutputs
(
path
);
for
(
auto
&
i
:
outputs
)
if
(
isValidPath
(
i
)
&&
queryPathInfo
(
i
)
->
deriver
==
path
)
edges
.
insert
(
i
);
}
}
else
{
auto
info
=
queryPathInfo
(
path
);
auto
info
=
queryPathInfo
(
path
);
edges
=
info
->
references
;
if
(
includeOutputs
&&
isDerivation
(
path
))
{
if
(
flipDirection
)
{
PathSet
outputs
=
queryDerivationOutputs
(
path
);
for
(
auto
&
i
:
outputs
)
PathSet
referrers
;
if
(
isValidPath
(
i
))
edges
.
insert
(
i
);
queryReferrers
(
path
,
referrers
);
for
(
auto
&
ref
:
referrers
)
if
(
ref
!=
path
)
pool
.
enqueue
(
std
::
bind
(
doPath
,
ref
));
if
(
includeOutputs
)
{
PathSet
derivers
=
queryValidDerivers
(
path
);
for
(
auto
&
i
:
derivers
)
pool
.
enqueue
(
std
::
bind
(
doPath
,
i
));
}
if
(
includeDerivers
&&
isDerivation
(
path
))
{
PathSet
outputs
=
queryDerivationOutputs
(
path
);
for
(
auto
&
i
:
outputs
)
if
(
isValidPath
(
i
)
&&
queryPathInfo
(
i
)
->
deriver
==
path
)
pool
.
enqueue
(
std
::
bind
(
doPath
,
i
));
}
}
else
{
for
(
auto
&
ref
:
info
->
references
)
if
(
ref
!=
path
)
pool
.
enqueue
(
std
::
bind
(
doPath
,
ref
));
if
(
includeOutputs
&&
isDerivation
(
path
))
{
PathSet
outputs
=
queryDerivationOutputs
(
path
);
for
(
auto
&
i
:
outputs
)
if
(
isValidPath
(
i
))
pool
.
enqueue
(
std
::
bind
(
doPath
,
i
));
}
if
(
includeDerivers
&&
isValidPath
(
info
->
deriver
))
pool
.
enqueue
(
std
::
bind
(
doPath
,
info
->
deriver
));
}
}
};
if
(
includeDerivers
&&
isValidPath
(
info
->
deriver
))
pool
.
enqueue
(
std
::
bind
(
doPath
,
path
));
edges
.
insert
(
info
->
deriver
);
}
for
(
auto
&
i
:
edges
)
pool
.
process
();
computeFSClosure
(
i
,
paths
,
flipDirection
,
includeOutputs
,
includeDerivers
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment