Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit a8b1b0c

Browse files
committed
Try not to look up TileGroupHeader in Abort and Commit as much.
1 parent 96431ee commit a8b1b0c

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,18 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
655655

656656
// TODO (Pooja): This might be inefficient since we will have to get the
657657
// tile_group_header for each entry. Check if this needs to be consolidated
658+
659+
oid_t last_tile_group_id = INVALID_OID;
660+
storage::TileGroupHeader *tile_group_header = nullptr;
661+
658662
for (const auto &tuple_entry : rw_set) {
659663
ItemPointer item_ptr = tuple_entry.first;
660664
oid_t tile_group_id = item_ptr.block;
661665
oid_t tuple_slot = item_ptr.offset;
662666

663-
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader();
667+
if (tile_group_id != last_tile_group_id) {
668+
tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader();
669+
}
664670

665671
if (tuple_entry.second == RWType::READ_OWN) {
666672
// A read operation has acquired ownership but hasn't done any further
@@ -807,11 +813,18 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
807813
// Iterate through each item pointer in the read write set
808814
// TODO (Pooja): This might be inefficient since we will have to get the
809815
// tile_group_header for each entry. Check if this needs to be consolidated
816+
817+
oid_t last_tile_group_id = INVALID_OID;
818+
storage::TileGroupHeader *tile_group_header = nullptr;
819+
810820
for (const auto &tuple_entry : rw_set) {
811821
ItemPointer item_ptr = tuple_entry.first;
812822
oid_t tile_group_id = item_ptr.block;
813823
oid_t tuple_slot = item_ptr.offset;
814-
auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader();
824+
825+
if (tile_group_id != last_tile_group_id) {
826+
tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader();
827+
}
815828

816829
if (tuple_entry.second == RWType::READ_OWN) {
817830
// A read operation has acquired ownership but hasn't done any further

src/concurrency/transaction_context.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ TransactionContext::TransactionContext(const size_t thread_id,
6161
Init(thread_id, isolation, read_id, commit_id);
6262
}
6363

64-
TransactionContext::~TransactionContext() {}
65-
6664
void TransactionContext::Init(const size_t thread_id,
6765
const IsolationLevelType isolation,
6866
const cid_t &read_id, const cid_t &commit_id) {
@@ -80,20 +78,18 @@ void TransactionContext::Init(const size_t thread_id,
8078

8179
isolation_level_ = isolation;
8280

83-
gc_set_.reset(new GCSet());
84-
gc_object_set_.reset(new GCObjectSet());
81+
gc_set_ = std::make_shared<GCSet>();
82+
gc_object_set_ = std::make_shared<GCObjectSet>();
8583

8684
on_commit_triggers_.reset();
8785
}
8886

8987
RWType TransactionContext::GetRWType(const ItemPointer &location) {
90-
RWType rw_type = RWType::INVALID;
91-
9288
const auto rw_set_it = rw_set_.find(location);
9389
if (rw_set_it != rw_set_.end()) {
94-
rw_type = rw_set_it->second;
90+
return rw_set_it->second;
9591
}
96-
return rw_type;
92+
return RWType::INVALID;
9793
}
9894

9995
void TransactionContext::RecordRead(const ItemPointer &location) {

src/include/concurrency/transaction_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TransactionContext : public Printable {
5353
/**
5454
* @brief Destroys the object.
5555
*/
56-
~TransactionContext();
56+
~TransactionContext() = default;
5757

5858
private:
5959
void Init(const size_t thread_id, const IsolationLevelType isolation,

0 commit comments

Comments
 (0)