Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

feat: Introduce "--storage-memory-cache-limit" #671

Merged
merged 2 commits into from
Oct 12, 2023
Merged

Conversation

jsantell
Copy link
Contributor

@jsantell jsantell commented Oct 6, 2023

  • Introduce ConfigurableStorage trait to open storage with generalized configurations (only memory_cache_limit at the moment)
  • Introduce --storage-memory-cache-limit and NoosphereStorage { config: NoosphereStorageConfig, path: NoosphereStoragePath } for propagating these values from orb and rust API respectively into the sphere builder, which makes its way into the storage provider.
  • Make invoke_cli() take a mutable Workspace (for setting storage config)

rust/noosphere/tests/cli.rs Outdated Show resolved Hide resolved
rust/noosphere/src/storage.rs Show resolved Hide resolved
@jsantell jsantell force-pushed the storage-memory-limit branch 6 times, most recently from 67f2ff5 to 1544059 Compare October 9, 2023 18:05
@jsantell jsantell marked this pull request as ready for review October 9, 2023 18:11
@jsantell jsantell requested a review from cdata October 9, 2023 18:27
@jsantell
Copy link
Contributor Author

jsantell commented Oct 9, 2023

  • Sled: Limits the system page cache capacity.
  • RocksDB: Memory usage in RocksDB can be attributed to the block cache, indexes/filter blocks, and memtable. This config field limits the overall memtable cache usage across all column families (stores). The block cache is 32MB by default. May need to tweak these settings more in the future.
  • IndexedDb: Does not use this value. I imagine IndexedDb will eventually have some storage configurations where it'd make sense to implement ConfigurationStorage for it, ignoring the unsupported values.

Other ideas:

  • A supports_config() method in the trait if we need to concretely know how supported a config is (enum ConfigSupport { Unsupported, PartialSupport, Supported })
  • Dumping internal stats from a Storage (RocksDB has a lot of insight here) via maybe a timer or gateway API


/// If set, the amount of memory that the storage provider may use
/// for caching in bytes.
#[clap(long)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a short arg for this? e.g., short = 'S' or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Punting on this for now, as this is a low-level operator command

@@ -54,6 +58,25 @@ impl Storage for SledStorage {
}
}

#[async_trait]
impl ConfigurableStorage for SledStorage {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this implementation is the same for both SledStorage and RocksDbStorage. Can it just be a general default implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, they both just coincidentally have the core of their instantiation and setup in Self::with_config rather than calling <Self as ConfigurableStorage>::open_with_config from Self::new

IpfsStorage::new(storage, maybe_client)
};

debug!("Creating platform storage: {:#?}", storage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log line might be better written before the storage is created (otherwise change to past tense e.g., "created" not "creating"; but, I think moving it is better so that you get appropriate context for any subsequent error).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to created, as we use storage's Debug implementation to log storage type and extra configurations (could add more debugging to type if needed e.g. trait StorageInfo { fn name() -> String }

Copy link
Collaborator

@cdata cdata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thanks for adding this capability.

@jsantell jsantell force-pushed the storage-memory-limit branch from 1544059 to 387bbeb Compare October 11, 2023 19:42
/// creates a new [Workspace] from the current working directory.
///
/// Use [invoke_cli_with_workspace] if using your own [Workspace].
pub async fn invoke_cli<'a>(cli: Cli, context: &CliContext<'a>) -> Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invoke_cli now creates a Workspace from its args rather than accept one so that we can always have the correct storage configuration on instantiation (this is the bulk of the follow up changes)

to limit size of memory cache in storage providers.
@jsantell jsantell force-pushed the storage-memory-limit branch from 387bbeb to 949468d Compare October 11, 2023 19:46
@jsantell jsantell requested a review from cdata October 11, 2023 19:53
Copy link
Collaborator

@cdata cdata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for implementing this!

@cdata cdata merged commit 9d44417 into main Oct 12, 2023
@cdata cdata deleted the storage-memory-limit branch October 12, 2023 16:53
@github-actions github-actions bot mentioned this pull request Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants