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

Misc datastore cleanups & less cloning #1263

Merged
merged 1 commit into from
May 22, 2024

Conversation

Centril
Copy link
Contributor

@Centril Centril commented May 20, 2024

Description of Changes

  1. Privatize st_*_schema functions, only used in system_tables() now.
  2. Only call system_tables() once in bootstrap_system_tables. Eagerly Arc those and then clone as little as possible.
  3. Take TableId by value more
  4. Rename table_exists -> table_name
  5. Dedup table_name by using get_schema().
  6. Other minor misc deduping.

API and ABI breaking changes

None

Expected complexity level and risk

2, touches some system table code but in a fairly small way.
Still, be sure to double check ST_TABLES_IDX and the bootstrap_system_tables changes.

Comment on lines +61 to +81
pub(crate) const ST_TABLES_IDX: usize = 0;
pub(crate) const ST_COLUMNS_IDX: usize = 1;
pub(crate) const ST_INDEXES_IDX: usize = 2;
pub(crate) const ST_CONSTRAINTS_IDX: usize = 3;
pub(crate) const ST_MODULE_IDX: usize = 4;
pub(crate) const ST_SEQUENCES_IDX: usize = 5;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These should correspond to the indices in the array in system_tables() above.

Comment on lines -32 to -34
fn table_exists(&self, table_id: &TableId) -> Option<&str> {
self.committed_state_shared_lock.table_exists(table_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.

Now a provided function defined via get_schema.

Comment on lines +38 to +40
fn table_name(&self, table_id: TableId) -> Option<&str> {
self.get_schema(table_id).map(|s| &*s.table_name)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Said provided definition.

Comment on lines -1004 to -1013
fn table_exists(&self, table_id: &TableId) -> Option<&str> {
// TODO(bikeshedding, docs): should this also check if the schema is in the system tables,
// but the table hasn't been constructed yet?
// If not, document why.
self.tx_state
.insert_tables
.get(table_id)
.or_else(|| self.committed_state_write_lock.tables.get(table_id))
.map(|table| &*table.schema.table_name)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the provided definition.

Comment on lines -63 to -66
fn table_exists(&self, table_id: &TableId) -> Option<&str> {
self.tables.get(table_id).map(|t| &*t.schema.table_name)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

provided def.

let schemas = system_tables().map(Arc::new);
let ref_schemas = schemas.each_ref().map(|s| &**s);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We immediately Arc all the system tables and then get out &TableSchema for use as needed. We refer to all system tables by index rather than recreating them.

@bfops bfops added the release-any To be landed in any release window label May 21, 2024
Copy link
Contributor

@Shubham8287 Shubham8287 left a comment

Choose a reason for hiding this comment

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

I extensively checked for system_table and related schema changes, Looks fine to me.

@Centril Centril force-pushed the centril/misc-datastore-cleanup branch from 5e1aa59 to df8b241 Compare May 22, 2024 15:31
2. Only call system_tables() once in bootstrap_system_tables.
3. Take `TableId` by value more
4. Rename `table_exists` -> `table_name`
5. Dedup `table_name` by using `get_schema()`.
6. Other misc deduping.
@Centril Centril force-pushed the centril/misc-datastore-cleanup branch from df8b241 to 8a6241a Compare May 22, 2024 15:31
@Centril Centril enabled auto-merge May 22, 2024 15:32
@Centril Centril added this pull request to the merge queue May 22, 2024
Merged via the queue into master with commit 9257208 May 22, 2024
6 checks passed
@Centril Centril deleted the centril/misc-datastore-cleanup branch May 22, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants