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

Commit 27c25c4

Browse files
authored
Merge branch 'master' into catalog_update
2 parents d0ccb48 + 881a8e6 commit 27c25c4

18 files changed

+171
-209
lines changed

src/codegen/code_context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ CodeContext::CodeContext()
224224
int64_type_ = llvm::Type::getInt64Ty(*context_);
225225
double_type_ = llvm::Type::getDoubleTy(*context_);
226226
void_type_ = llvm::Type::getVoidTy(*context_);
227-
void_ptr_type_ = llvm::Type::getVoidTy(*context_)->getPointerTo();
227+
void_ptr_type_ = llvm::Type::getInt8PtrTy(*context_);
228228
char_ptr_type_ = llvm::Type::getInt8PtrTy(*context_);
229229
}
230230

src/codegen/function_builder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ FunctionBuilder::FunctionBuilder(
131131
cc,
132132
ConstructFunction(cc, name, FunctionDeclaration::Visibility::External,
133133
ret_type, args)) {}
134-
134+
135135
FunctionBuilder::~FunctionBuilder() {
136136
if (!finished_) {
137-
throw Exception{"Missing call to FunctionBuilder::ReturnAndFinish()"};
137+
LOG_ERROR(
138+
"Missing call to FunctionBuilder::ReturnAndFinish() for function '%s'",
139+
func_->getName().data());
138140
}
139141
}
140142

src/codegen/lang/vectorized_loop.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ VectorizedLoop::VectorizedLoop(CodeGen &codegen, llvm::Value *num_elements,
3333
}
3434

3535
VectorizedLoop::~VectorizedLoop() {
36-
PELOTON_ASSERT(ended_ && "You didn't call lang::VectorizedLoop::LoopEnd()!");
36+
if (!ended_) {
37+
LOG_ERROR("You didn't call lang::VectorizedLoop::LoopEnd()!");
38+
}
3739
}
3840

3941
VectorizedLoop::Range VectorizedLoop::GetCurrentRange() const {

src/codegen/operator/table_scan_translator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void TableScanTranslator::ProduceParallel() const {
216216
codegen.Int64Type()};
217217

218218
// Parallel production
219-
auto producer = [this, &codegen, &table](
219+
auto producer = [this, &codegen](
220220
ConsumerContext &ctx, const std::vector<llvm::Value *> params) {
221221
PELOTON_ASSERT(params.size() == 2);
222222
llvm::Value *tilegroup_start = params[0];

src/codegen/transaction_runtime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ uint32_t TransactionRuntime::PerformVectorizedRead(
5656
ItemPointer location{tile_group_idx, selection_vector[idx]};
5757

5858
// Perform the read
59-
bool can_read = txn_manager.PerformRead(&txn, location);
59+
bool can_read = txn_manager.PerformRead(&txn, location, tile_group_header, false);
6060

6161
// Update the selection vector and output position
6262
selection_vector[out_idx] = selection_vector[idx];

src/codegen/util/sorter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void Sorter::SortParallel(
268268
return !(cmp_func_(*l.first, *r.first) < 0);
269269
};
270270
for (auto &work : merge_work) {
271-
work_pool.SubmitTask([&work, &latch, &heap_cmp, &comp] {
271+
work_pool.SubmitTask([&work, &latch, &heap_cmp] {
272272
std::priority_queue<MergeWork::InputRange,
273273
std::vector<MergeWork::InputRange>,
274274
decltype(heap_cmp)> heap(heap_cmp,

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 4 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ void TimestampOrderingTransactionManager::YieldOwnership(
170170
tile_group_header->SetTransactionId(tuple_id, INITIAL_TXN_ID);
171171
}
172172

173-
bool TimestampOrderingTransactionManager::PerformRead(
174-
TransactionContext *const current_txn, const ItemPointer &read_location,
175-
bool acquire_ownership) {
173+
bool TimestampOrderingTransactionManager::PerformRead(TransactionContext *const current_txn,
174+
const ItemPointer &read_location,
175+
storage::TileGroupHeader *tile_group_header,
176+
bool acquire_ownership) {
176177
ItemPointer location = read_location;
177178

178179
//////////////////////////////////////////////////////////
@@ -189,24 +190,18 @@ bool TimestampOrderingTransactionManager::PerformRead(
189190

190191
// TODO: what if we want to read a version that we write?
191192
else if (current_txn->GetIsolationLevel() == IsolationLevelType::SNAPSHOT) {
192-
oid_t tile_group_id = location.block;
193193
oid_t tuple_id = location.offset;
194194

195195
LOG_TRACE("PerformRead (%u, %u)\n", location.block, location.offset);
196-
auto &manager = catalog::Manager::GetInstance();
197-
auto tile_group_header = manager.GetTileGroup(tile_group_id)->GetHeader();
198196

199197
// Check if it's select for update before we check the ownership
200198
// and modify the last reader cid
201199
if (acquire_ownership == true) {
202200
// get the latest version of this tuple.
203201
location = *(tile_group_header->GetIndirection(location.offset));
204202

205-
tile_group_id = location.block;
206203
tuple_id = location.offset;
207204

208-
tile_group_header = manager.GetTileGroup(tile_group_id)->GetHeader();
209-
210205
if (IsOwner(current_txn, tile_group_header, tuple_id) == false) {
211206
// Acquire ownership if we haven't
212207
if (IsOwnable(current_txn, tile_group_header, tuple_id) == false) {
@@ -225,27 +220,11 @@ bool TimestampOrderingTransactionManager::PerformRead(
225220

226221
// if we have already owned the version.
227222
PELOTON_ASSERT(IsOwner(current_txn, tile_group_header, tuple_id) == true);
228-
229-
// Increment table read op stats
230-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
231-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
232-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
233-
location.block);
234-
}
235-
236223
return true;
237224

238225
} else {
239226
// if it's not select for update, then update read set and return true.
240-
241227
current_txn->RecordRead(location);
242-
243-
// Increment table read op stats
244-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
245-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
246-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
247-
location.block);
248-
}
249228
return true;
250229
}
251230

@@ -256,12 +235,9 @@ bool TimestampOrderingTransactionManager::PerformRead(
256235
//////////////////////////////////////////////////////////
257236
else if (current_txn->GetIsolationLevel() ==
258237
IsolationLevelType::READ_COMMITTED) {
259-
oid_t tile_group_id = location.block;
260238
oid_t tuple_id = location.offset;
261239

262240
LOG_TRACE("PerformRead (%u, %u)\n", location.block, location.offset);
263-
auto &manager = catalog::Manager::GetInstance();
264-
auto tile_group_header = manager.GetTileGroup(tile_group_id)->GetHeader();
265241

266242
// Check if it's select for update before we check the ownership.
267243
if (acquire_ownership == true) {
@@ -283,26 +259,13 @@ bool TimestampOrderingTransactionManager::PerformRead(
283259
}
284260
// if we have already owned the version.
285261
PELOTON_ASSERT(IsOwner(current_txn, tile_group_header, tuple_id) == true);
286-
// Increment table read op stats
287-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
288-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
289-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
290-
location.block);
291-
}
292262
return true;
293263

294264
} else {
295265
// a transaction can never read an uncommitted version.
296266
if (IsOwner(current_txn, tile_group_header, tuple_id) == false) {
297267
if (IsOwned(current_txn, tile_group_header, tuple_id) == false) {
298268
current_txn->RecordRead(location);
299-
300-
// Increment table read op stats
301-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
302-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
303-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
304-
location.block);
305-
}
306269
return true;
307270

308271
} else {
@@ -315,14 +278,6 @@ bool TimestampOrderingTransactionManager::PerformRead(
315278
} else {
316279
// this version must already be in the read/write set.
317280
// so no need to update read set.
318-
// current_txn->RecordRead(location);
319-
320-
// Increment table read op stats
321-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
322-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
323-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
324-
location.block);
325-
}
326281
return true;
327282
}
328283
}
@@ -338,13 +293,9 @@ bool TimestampOrderingTransactionManager::PerformRead(
338293
current_txn->GetIsolationLevel() ==
339294
IsolationLevelType::REPEATABLE_READS);
340295

341-
oid_t tile_group_id = location.block;
342296
oid_t tuple_id = location.offset;
343297

344298
LOG_TRACE("PerformRead (%u, %u)\n", location.block, location.offset);
345-
auto &manager = catalog::Manager::GetInstance();
346-
auto tile_group_header = manager.GetTileGroup(tile_group_id)->GetHeader();
347-
348299
// Check if it's select for update before we check the ownership
349300
// and modify the last reader cid.
350301
if (acquire_ownership == true) {
@@ -379,12 +330,6 @@ bool TimestampOrderingTransactionManager::PerformRead(
379330
PELOTON_ASSERT(GetLastReaderCommitId(tile_group_header, tuple_id) ==
380331
current_txn->GetCommitId() ||
381332
GetLastReaderCommitId(tile_group_header, tuple_id) == 0);
382-
// Increment table read op stats
383-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
384-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
385-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
386-
location.block);
387-
}
388333
return true;
389334

390335
} else {
@@ -395,13 +340,6 @@ bool TimestampOrderingTransactionManager::PerformRead(
395340
current_txn->GetCommitId(), false) == true) {
396341
// update read set.
397342
current_txn->RecordRead(location);
398-
399-
// Increment table read op stats
400-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
401-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
402-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
403-
location.block);
404-
}
405343
return true;
406344
} else {
407345
// if the tuple has been owned by some concurrent transactions,
@@ -419,14 +357,6 @@ bool TimestampOrderingTransactionManager::PerformRead(
419357

420358
// this version must already be in the read/write set.
421359
// so no need to update read set.
422-
// current_txn->RecordRead(location);
423-
424-
// Increment table read op stats
425-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
426-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
427-
stats::BackendStatsContext::GetInstance()->IncrementTableReads(
428-
location.block);
429-
}
430360
return true;
431361
}
432362
}
@@ -464,13 +394,6 @@ void TimestampOrderingTransactionManager::PerformInsert(
464394

465395
// Write down the head pointer's address in tile group header
466396
tile_group_header->SetIndirection(tuple_id, index_entry_ptr);
467-
468-
// Increment table insert op stats
469-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
470-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
471-
stats::BackendStatsContext::GetInstance()->IncrementTableInserts(
472-
location.block);
473-
}
474397
}
475398

476399
void TimestampOrderingTransactionManager::PerformUpdate(
@@ -548,13 +471,6 @@ void TimestampOrderingTransactionManager::PerformUpdate(
548471

549472
// Add the old tuple into the update set
550473
current_txn->RecordUpdate(old_location);
551-
552-
// Increment table update op stats
553-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
554-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
555-
stats::BackendStatsContext::GetInstance()->IncrementTableUpdates(
556-
new_location.block);
557-
}
558474
}
559475

560476
void TimestampOrderingTransactionManager::PerformUpdate(
@@ -581,13 +497,6 @@ void TimestampOrderingTransactionManager::PerformUpdate(
581497
// transaction
582498
// is updating a version that is installed by itself.
583499
// in this case, nothing needs to be performed.
584-
585-
// Increment table update op stats
586-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
587-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
588-
stats::BackendStatsContext::GetInstance()->IncrementTableUpdates(
589-
location.block);
590-
}
591500
}
592501

593502
void TimestampOrderingTransactionManager::PerformDelete(
@@ -669,13 +578,6 @@ void TimestampOrderingTransactionManager::PerformDelete(
669578
}
670579

671580
current_txn->RecordDelete(old_location);
672-
673-
// Increment table delete op stats
674-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
675-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
676-
stats::BackendStatsContext::GetInstance()->IncrementTableDeletes(
677-
old_location.block);
678-
}
679581
}
680582

681583
void TimestampOrderingTransactionManager::PerformDelete(
@@ -703,13 +605,6 @@ void TimestampOrderingTransactionManager::PerformDelete(
703605
// if this version is newly inserted.
704606
current_txn->RecordDelete(location);
705607
}
706-
707-
// Increment table delete op stats
708-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
709-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
710-
stats::BackendStatsContext::GetInstance()->IncrementTableDeletes(
711-
location.block);
712-
}
713608
}
714609

715610
ResultType TimestampOrderingTransactionManager::CommitTransaction(
@@ -752,20 +647,6 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
752647
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
753648
}
754649

755-
oid_t database_id = 0;
756-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
757-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
758-
for (const auto &tuple_entry : rw_set) {
759-
// Call the GetConstIterator() function to explicitly lock the cuckoohash
760-
// and initilaize the iterator
761-
const auto tile_group_id = tuple_entry.first.block;
762-
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
763-
if (database_id != CATALOG_DATABASE_OID) {
764-
break;
765-
}
766-
}
767-
}
768-
769650
// install everything.
770651
// 1. install a new version for update operations;
771652
// 2. install an empty version for delete operations;
@@ -896,13 +777,6 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
896777

897778
EndTransaction(current_txn);
898779

899-
// Increment # txns committed metric
900-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
901-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
902-
stats::BackendStatsContext::GetInstance()->IncrementTxnCommitted(
903-
database_id);
904-
}
905-
906780
return result;
907781
}
908782

@@ -930,20 +804,6 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
930804
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
931805
}
932806

933-
oid_t database_id = 0;
934-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
935-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
936-
for (const auto &tuple_entry : rw_set) {
937-
// Call the GetConstIterator() function to explicitly lock the cuckoohash
938-
// and initilaize the iterator
939-
const auto tile_group_id = tuple_entry.first.block;
940-
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
941-
if (database_id != CATALOG_DATABASE_OID) {
942-
break;
943-
}
944-
}
945-
}
946-
947807
// Iterate through each item pointer in the read write set
948808
// TODO (Pooja): This might be inefficient since we will have to get the
949809
// tile_group_header for each entry. Check if this needs to be consolidated
@@ -1085,12 +945,6 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
1085945
current_txn->SetResult(ResultType::ABORTED);
1086946
EndTransaction(current_txn);
1087947

1088-
// Increment # txns aborted metric
1089-
if (static_cast<StatsType>(settings::SettingsManager::GetInt(
1090-
settings::SettingId::stats_mode)) != StatsType::INVALID) {
1091-
stats::BackendStatsContext::GetInstance()->IncrementTxnAborted(database_id);
1092-
}
1093-
1094948
return ResultType::ABORTED;
1095949
}
1096950

0 commit comments

Comments
 (0)