Skip to content

Conversation

@alexggh
Copy link
Contributor

@alexggh alexggh commented Jan 23, 2026

The topics_and_keys is eating about 200 bytes per statement, which is about 30% of the contribution for each statement.

Since this structure was need only when we clean up of statement it makes more sense to just read the statement from the database instead of paying such a high memory price for each statement.

Signed-off-by: Alexandru Gheorghe <[email protected]>
if let Some((topics, key)) = self.topics_and_keys.remove(hash) {
for t in topics.into_iter().flatten() {
// Read statement from database to get topics and decryption key
let statement = db
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the idea of operating with the DB inside index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is your concern here ?

Signed-off-by: Alexandru Gheorghe <[email protected]>
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

So you are trading memory footprint for IO? :D

// Fallback: iterate through all indexes if database read failed
log::warn!(
target: LOG_TARGET,
"Failed to read statement {:?} from database, falling back to full index scan",
Copy link
Member

Choose a reason for hiding this comment

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

Where is this reading from database? Also can we make this debug?

Copy link
Member

Choose a reason for hiding this comment

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

I see where it is reading from db :D

}
} else {
// Fallback: iterate through all indexes if database read failed
log::warn!(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log::warn!(
log::debug!(

@alexggh
Copy link
Contributor Author

alexggh commented Jan 28, 2026

So you are trading memory footprint for IO? :D

Yes, that's my intention with this PR, with the caveat that expiring statements is not something we do very often and it is not time sensitive.

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.

4 participants