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

Don't check the hard limit on each insert #339

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/storage/db/storage_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,11 +1252,6 @@ bool storage_db_op_set(
storage_db_entry_index_t *entry_index = NULL;
bool result_res = false;

if (storage_db_will_new_entry_hit_hard_limit(db, value_chunk_sequence->size)) {
LOG_V(TAG, "Unable to set the key because it would exceed the hard limit");
goto end;
}

entry_index = storage_db_entry_index_ring_buffer_new(db);

// Set up the key if necessary
Expand Down Expand Up @@ -1384,11 +1379,6 @@ bool storage_db_op_rmw_commit_update(
storage_db_entry_index_t *entry_index = NULL;
bool result_res = false;

if (storage_db_will_new_entry_hit_hard_limit(db, value_chunk_sequence->size)) {
LOG_V(TAG, "Unable to set the key because it would exceed the hard limit");
goto end;
}

entry_index = storage_db_entry_index_ring_buffer_new(db);

// Set up the key if necessary
Expand Down
17 changes: 0 additions & 17 deletions src/storage/db/storage_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,6 @@ static inline double storage_db_keys_eviction_calculate_close_to_hard_limit_perc
keys_count_close_to_hard_limit_percentage : data_size_close_to_hard_limit_percentage;
}

static inline bool storage_db_will_new_entry_hit_hard_limit(
storage_db_t *db,
uint64_t new_entry_size) {
uint64_t keys_count = storage_db_op_get_keys_count(db);
uint64_t data_size = storage_db_op_get_data_size(db);

if (db->limits.keys_count.hard_limit > 0 && keys_count + 1 > db->limits.keys_count.hard_limit) {
return true;
}

if (db->limits.data_size.hard_limit > 0 && data_size + new_entry_size > db->limits.data_size.hard_limit) {
return true;
}

return false;
}

#ifdef __cplusplus
}
#endif
Expand Down