You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned in #414, it would be great if the configuration of storage backends is not just a large bag of CCACHE_... variables but had some more structure. It should be possible to:
Configure a secondary storage backend in a simple way.
Define an order in which backends are queried.
Configure backend-specific settings such as credentials or modes.
Add a configuration option called storage which specifies the list of storage backends to query in order. The standard backend has to be part of the list by using the keyword standard (or absent to not use it). Other storage backends are specified by URLs.
Storage backends can receive a list of key-value attributes with configuration.
It's possible to set a backend to read-only mode using an attribute. Setting the standard backend to read-only has the same effect as memcached_only in Memcached #58. Setting another backend to read-only has the same effect as read_only_memcached in Memcached #58.
To make the common use case of just adding a single backend nicer, add a level_2_storage configuration option as a shorthand for setting storage to standard plus another backend.
level_2_storage = http://example.com/cache/location
# Or equivalently:
storage = standard http://example.com/cache/location
Add two configuration options level_0_storage and level_2_storage. These contains lists of backends to query before and after the standard one.
Just as in variant 1, storage backends can receive a list of key-value attributes with configuration.
Just as in variant 1, it's possible to set a backend (except the standard one) read-only mode using an attribute.
Add a read_only_local configuration option to make it possible to set the standard backend to read-only mode.
In this variant multiple backends can be "level 0" or "level 2" which maybe is slightly strange but should be OK. (Especially since I guess it's unlikely that somebody wants to specify multiple backends in practice...)
I realize that this may appear slightly overengineered, but I felt that I wanted to try to make the configuration syntax extensible for future use cases.
We can start with just implementing support for level_2_storage with a single backend, so we don't have to decide on a variant now. That said, I'm leaning towards variant 2.
I didn't want to introduce special configuration files for backends since I see a value in being able to set environment variables instead of requiring configuration files.
Similarly, I didn't want to introduce some new generic configuration file syntax since it should be possible to continue using just environment variables with minimal syntactical noise (i.e., no JSON, etc.).
I'm not using the term "remote" since alternative file backends don't necessarily have to be on network storage and therefore are not "remote".
I chose | as the delimiter for attributes because it's an invalid character in URLs which makes it trivial to parse the configuration. And I think it looks kind of nice. I tried other variations with brackets and braces as well, but I didn't think it looked better at the end.
It could be that the use case of Add support for two level cache #380 is not worth the complexity of adding level_0_storage and that it would be OK with just level_2_storage = file:///example/cache/location|read-only.
@afbjorklund (and others): What do you think about this plan? Comments are welcome.
Looks OK. I guess you decide the type of the storage backend by inventing some scheme for it, like redis://localhost:6379 ?
Using the local storage as temporary files sounds like reasonable workarounds for both memcached_only and level_0_storage. I don't think doing a local copy of the file adds major overhead, compared to the transport from memcached or from nfs (or so) ? Previously we went to great lengths to write directly from memcached results in memory or from the remote file system path. Then again, since the options are here and this is only about configuration - the optimizations can be kept when doing the implementation.
I think having a single "storage" configuration would be enough, and it seems like it would cover all the different scenarios too ?
storage = standard
storage = standard http://example.com/cache/location
Looks OK. I guess you decide the type of the storage backend by inventing some scheme for it, like redis://localhost:6379 ?
Yes, that's the idea.
Then again, since the options are here and this is only about configuration - the optimizations can be kept when doing the implementation.
Yep.
For the record, the API I envisioned (but never got to describe in detail) in #414 had streaming versions of get/put operations. In fact the manifest and result implementations are already prepared (after a small refactoring to work on a new file I/O API instead of directly on FILE*) for consuming or producing streaming data with such a storage API in mind. In other words, they can then be driven by feeding/fetching chunks of data directly from/to a network storage backend without landing the data on disk.
My plan now is to start with local files as bearer of data in the APIs (similar to #676's API) just to get something going, and then potentially refactor into streaming APIs later.
I think having a single "storage" configuration would be enough, and it seems like it would cover all the different scenarios too ?
Right, so your prefer variant 1 without the "level_2_storage" nice to have? Only having storage was what I had initially, but I just felt that for 99% of the cases a user just wants to add another level 2 backend and then having to write (or even know about) the standard keyword feels a bit unfortunate.
I've started to look into implementing this and I now realize it's hard to describe the distinction between the standard backend (which has a much richer feature set and API) and other backends. Here's another variant:
Add a configuration option called secondary_storage which specifies the list of storage backends to query in order after the primary cache. This makes it possible to describe the difference between the primary and secondary storage APIs and implementations. A future optional replacement of the primary storage could then be primary_storage.
Just as in variant 1, storage backends can receive a list of key-value attributes with configuration.
Just as in variant 1, it's possible to set a backend (except the standard one) read-only mode using an attribute.
Add a read_only_primary configuration option to make it possible to set the primary backend to read-only mode.
Add an optional backend attribute for making ccache query that backend before the primary one, maybe prepend or similar.
Activity
[-]Storage backend: configuration format[/-][+]Storage backends: configuration format[/+]jrosdahl commentedon Jun 10, 2021
Here's what I got so far:
Variant 1
Documentation sketch: 36f48b0
Main ideas:
storagewhich specifies the list of storage backends to query in order. The standard backend has to be part of the list by using the keywordstandard(or absent to not use it). Other storage backends are specified by URLs.memcached_onlyin Memcached #58. Setting another backend to read-only has the same effect asread_only_memcachedin Memcached #58.level_2_storageconfiguration option as a shorthand for settingstoragetostandardplus another backend.Use case #676 looks like this:
Use case #380 looks like this:
Variant 2
Documentation sketch: 6c80174
Main ideas:
level_0_storageandlevel_2_storage. These contains lists of backends to query before and after the standard one.read_only_localconfiguration option to make it possible to set the standard backend to read-only mode.In this variant multiple backends can be "level 0" or "level 2" which maybe is slightly strange but should be OK. (Especially since I guess it's unlikely that somebody wants to specify multiple backends in practice...)
Use case #676 look like this:
Use case #380 looks like this:
Random comments
level_2_storagewith a single backend, so we don't have to decide on a variant now. That said, I'm leaning towards variant 2.|as the delimiter for attributes because it's an invalid character in URLs which makes it trivial to parse the configuration. And I think it looks kind of nice. I tried other variations with brackets and braces as well, but I didn't think it looked better at the end.level_0_storageand that it would be OK with justlevel_2_storage = file:///example/cache/location|read-only.@afbjorklund (and others): What do you think about this plan? Comments are welcome.
afbjorklund commentedon Jun 12, 2021
Looks OK. I guess you decide the type of the storage backend by inventing some scheme for it, like
redis://localhost:6379?Using the local storage as temporary files sounds like reasonable workarounds for both memcached_only and level_0_storage. I don't think doing a local copy of the file adds major overhead, compared to the transport from memcached or from nfs (or so) ? Previously we went to great lengths to write directly from memcached results in memory or from the remote file system path. Then again, since the options are here and this is only about configuration - the optimizations can be kept when doing the implementation.
I think having a single "storage" configuration would be enough, and it seems like it would cover all the different scenarios too ?
storage = standardstorage = standard http://example.com/cache/locationjrosdahl commentedon Jun 12, 2021
Yes, that's the idea.
Yep.
For the record, the API I envisioned (but never got to describe in detail) in #414 had streaming versions of get/put operations. In fact the manifest and result implementations are already prepared (after a small refactoring to work on a new file I/O API instead of directly on
FILE*) for consuming or producing streaming data with such a storage API in mind. In other words, they can then be driven by feeding/fetching chunks of data directly from/to a network storage backend without landing the data on disk.My plan now is to start with local files as bearer of data in the APIs (similar to #676's API) just to get something going, and then potentially refactor into streaming APIs later.
Right, so your prefer variant 1 without the "level_2_storage" nice to have? Only having
storagewas what I had initially, but I just felt that for 99% of the cases a user just wants to add another level 2 backend and then having to write (or even know about) thestandardkeyword feels a bit unfortunate.jrosdahl commentedon Jun 12, 2021
I've started to look into implementing this and I now realize it's hard to describe the distinction between the standard backend (which has a much richer feature set and API) and other backends. Here's another variant:
Variant 3
Documentation sketch: ed1f662
Main ideas:
secondary_storagewhich specifies the list of storage backends to query in order after the primary cache. This makes it possible to describe the difference between the primary and secondary storage APIs and implementations. A future optional replacement of the primary storage could then beprimary_storage.read_only_primaryconfiguration option to make it possible to set the primary backend to read-only mode.prependor similar.Use case #676 looks like this:
Use case #380 looks like this:
Note the
prependattribute.jrosdahl commentedon Jun 27, 2021
I went with variant 3, see 2b3368c.