-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build artifact caching #67
Conversation
Looking for some comments. I still need to write some tests to cover the new stuff, but this implementation currently works on my machine. |
from .caches.directorycache import DirectoryCache | ||
|
||
|
||
def __invoke_with_configured_needy(func, parameters): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to deduplicate repeated code here, but ugh. I'm not sure of a clean way to do this using the with
blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cleaner way would be with another context manager. This is fine though. Not a big deal.
This PR is still a little bit WIP, but I think the structure is mostly good. RE garbage collection in the base class: I don't think it's applicable here unless we generalize it further with methods for enumerating keys and deleting keys. If that's the case, then GC in the base class essentially becomes something like...
I'm not saying that's a nice thing to have, I'm just not sure it's within the scope of this first iteration without knowing what we want out of other cache implementations. So TODO:
|
ldflags emits the linker flags required to use the satisfied needs | ||
builddir emits the build directory for a need | ||
sourcedir emits the source directory for a need | ||
pkg-config-path emits the pkg-config path for a need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Why is this pkg-config-path stuff showing up in this diff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and you forgot to add that to the epilog before.
Tests and better garbage collection are what remain. I'm not sure if the file locking works or not--about to write some tests for it. |
Notes as discussed in person:
|
9dea642
to
c69ab23
Compare
logging.info('Storing build artifacts in cache') | ||
try: | ||
with self.__load_manifest() as m: | ||
self.__cache.store_directory(directory, key, timeout=self.__lock_timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could reduce contention if you update the manifest, then release the lock before the store
with self.__load_manifest() as m:
m.touch(key)
self.__collect_garbage(m)
self.__cache.store_directory(directory, key, timeout=self.__lock_timeout)
for key in [k for k in manifest if manifest[k].use_time < min_time]: | ||
try: | ||
with self.__cache.lease(key, timeout=0): | ||
self.__cache.unset_key(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you invoke self.__cache.unset_key(key)
without a lease?
7ea22f0
to
0d48fa2
Compare
|
||
def set_cache_path(args=[]): | ||
needs_dir = Needy.resolve_needs_directory('.') | ||
default_cache_path = os.path.join(needs_dir, '.cache') if needs_dir else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't currently have a use-case for a default cache in the needs directory, which is already a build cache. i'd leave off the default for now
Okay so I'm gonna put two hard merge requirements on this:
|
I'm all ears. Best I can think of is what you've already suggested or just requiring a modification by hand if you want something other than a directory to be default. I'm totally ok requiring hand-crafted configuration files too. I'll go ahead and make a |
This patch introduces caching that can be made available with `needy cache set [path]` and acts as a key/value store to archive the contents of the build directory after builds. When the cache contains artifacts for a particular build, they are used instead of going through the build process.
Fixed the name issues in main, moved |
Alright, let's do this. |
This patch introduces caching that can be made available with
needy cache-path set [path]
and acts as a key/value store to archive the contents of the build directory after builds. When the cache contains artifacts for a particular build, they are used instead of going through the build process.