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

Remove the ever growing pile of memory in locking_tx_datastore #38

Merged
merged 8 commits into from
Jul 1, 2023

Conversation

kulakowski
Copy link
Contributor

Description of Changes

API

  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI

If the API is breaking, please state below what will break

set_id: table_id.0,
data_key: row_id.0,
})
if let Some(pv) = table.delete(&row_id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This let Some check became necessary after rebasing onto the restart patch.

/// Operations in a transaction are either Inserts or Deletes.
/// Inserts report the byte objects they inserted, to be persisted
/// later in an object store.
pub enum TxOp {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to rename these new types to whatever.

@@ -51,37 +57,38 @@ impl CommitLog {
}
}

fn generate_commit<D>(&self, transaction: Arc<Transaction>, datastore: &D) -> Option<Vec<u8>>
fn generate_commit<D>(&self, tx_data: &TxData, datastore: &D) -> Option<Vec<u8>>
where
D: MutTxDatastore<RowId = RowId>,
{
// TODO(george) Don't clone the data, just the Arc.
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'm not 100% sure what this comment was referring to; is it now stale?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like it was your comment, so I'm not sure tbh.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks stale... no visible cloning anymore?

crates/core/src/db/commit_log.rs Outdated Show resolved Hide resolved
@@ -51,37 +57,38 @@ impl CommitLog {
}
}

fn generate_commit<D>(&self, transaction: Arc<Transaction>, datastore: &D) -> Option<Vec<u8>>
fn generate_commit<D>(&self, tx_data: &TxData, datastore: &D) -> Option<Vec<u8>>
where
D: MutTxDatastore<RowId = RowId>,
{
// TODO(george) Don't clone the data, just the Arc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks stale... no visible cloning anymore?

crates/core/src/db/commit_log.rs Outdated Show resolved Hide resolved
{
let mut guard = self.odb.lock().unwrap();
for data in datas.into_iter() {
guard.add((*data).clone());
for record in tx_data.records.iter() {
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
for record in tx_data.records.iter() {
for record in &tx_data.records {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why?

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is more idiomatic rust basically.

crates/core/src/db/datastore/locking_tx_datastore/mod.rs Outdated Show resolved Hide resolved
crates/core/src/db/datastore/locking_tx_datastore/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

LGTM I just have the two comments.

/// Whether the operation was an insert or a delete.
pub(crate) op: TxOp,
/// The value of the modified row.
pub(crate) pv: ProductValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we storing both the product_value and the bytes for the produce_value in the record? Shouldn't we just be doing one or the other?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I'd probably change pv -> product_value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bytes make it out to the object store. The ProductValue goes out to the sql vm. Doing just one or the other would I think require this also handing out the schema for the row at the point of time of the transaction, to either encode or decode accordingly.

Changing pv now.

@cloutiertyler cloutiertyler merged commit f54e0a7 into master Jul 1, 2023
cloutiertyler added a commit that referenced this pull request Aug 1, 2023
* Remove the ever growing pile of memory in locking_tx_datastore

* Clippy lint

* cargo fmt

* Cleanups

* Fix lint

* Rename TxRecord::pv to product_value

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
cloutiertyler added a commit that referenced this pull request Aug 1, 2023
* Remove the ever growing pile of memory in locking_tx_datastore

* Clippy lint

* cargo fmt

* Cleanups

* Fix lint

* Rename TxRecord::pv to product_value

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
@cloutiertyler cloutiertyler deleted the george/tx-memory branch August 1, 2023 21:53
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