Skip to content
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

fix: global queue capacity #225

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

undercover-cactus
Copy link
Contributor

No description provided.

@undercover-cactus undercover-cactus marked this pull request as ready for review October 15, 2024 10:26
if !capacity_queue.is_empty() {
let size: u64 = capacity_queue.drain(..).sum();

let new_capacity = self.calculate_capacity(size, current_capacity)?;
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 couldn't find a good way to test this, especially for the max storage value because it would require a 4GB file and it is not practical.

A way this function could be tested is to pass the config as an argument and have a test in rust to make sure the calculation is right and that it will goes higher than the max storage authorize.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could pass these aditional arguments in your test and reduce it to a reasonable size.

additionalArgs: [
`--max-storage-capacity=${MAX_STORAGE_CAPACITY}`,
`--jump-capacity=${CAPACITY[1024]}`
]

@@ -69,7 +69,7 @@ export const getContainerIp = async (containerName: string, verbose = false): Pr

export const checkNodeAlive = async (url: string, verbose = false) => getContainerIp(url, verbose);
export const getContainerPeerId = async (url: string, verbose = false) => {
const maxRetries = 60;
const maxRetries = 120;
Copy link
Contributor

Choose a reason for hiding this comment

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

For my info, why the increase?

.capacityUsed.toNumber();
await userApi.block.skipToMinChangeTime();
const minCapacity = userApi.consts.providers.spMinCapacity.toNumber();
const newCapacity = Math.max(minCapacity, capacityUsed + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why capacityUsed + 1 and not just capacityUsed?

))
.watch_for_success(&self.storage_hub_handler.blockchain)
.await?;
// wwe read from the queue
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// wwe read from the queue
// we read from the queue

.watch_for_success(&self.storage_hub_handler.blockchain)
.await?;

drop(capacity_queue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why drop the lock here and not outside?

&mut self,
event: &NewStorageRequest,
&self,
size: StorageDataUnit,
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of renaming this to required_additional_capacity?

@@ -53,6 +56,7 @@ where
{
storage_hub_handler: StorageHubHandler<FL, FSH>,
file_key_cleanup: Option<H256>,
capacity_queue: Arc<Mutex<Vec<u64>>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be missing something, but as far as I understand this could be just a u64 instead of Vec<u64> - seems this is the way we are using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants