MCPcopy Create free account
hub / github.com/apple/foundationdb / commitMessages

Function commitMessages

fdbserver/OldTLogServer_6_2.actor.cpp:1245–1349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243}
1244
1245void commitMessages(TLogData* self,
1246 Reference<LogData> logData,
1247 Version version,
1248 const std::vector<TagsAndMessage>& taggedMessages) {
1249 // SOMEDAY: This method of copying messages is reasonably memory efficient, but it's still a lot of bytes copied.
1250 // Find a way to do the memory allocation right as we receive the messages in the network layer.
1251
1252 int64_t addedBytes = 0;
1253 int64_t overheadBytes = 0;
1254 int expectedBytes = 0;
1255 int txsBytes = 0;
1256
1257 if (!taggedMessages.size()) {
1258 return;
1259 }
1260
1261 int msgSize = 0;
1262 for (auto& i : taggedMessages) {
1263 msgSize += i.message.size();
1264 }
1265
1266 // Grab the last block in the blocks list so we can share its arena
1267 // We pop all of the elements of it to create a "fresh" vector that starts at the end of the previous vector
1268 Standalone<VectorRef<uint8_t>> block;
1269 if (logData->messageBlocks.empty()) {
1270 block = Standalone<VectorRef<uint8_t>>();
1271 block.reserve(block.arena(), std::max<int64_t>(SERVER_KNOBS->TLOG_MESSAGE_BLOCK_BYTES, msgSize));
1272 } else {
1273 block = logData->messageBlocks.back().second;
1274 }
1275
1276 block.pop_front(block.size());
1277
1278 for (auto& msg : taggedMessages) {
1279 if (msg.message.size() > block.capacity() - block.size()) {
1280 logData->messageBlocks.emplace_back(version, block);
1281 addedBytes += int64_t(block.size()) * SERVER_KNOBS->TLOG_MESSAGE_BLOCK_OVERHEAD_FACTOR;
1282 block = Standalone<VectorRef<uint8_t>>();
1283 block.reserve(block.arena(), std::max<int64_t>(SERVER_KNOBS->TLOG_MESSAGE_BLOCK_BYTES, msgSize));
1284 }
1285
1286 block.append(block.arena(), msg.message.begin(), msg.message.size());
1287 for (auto tag : msg.tags) {
1288 if (logData->locality == tagLocalitySatellite) {
1289 if (!(tag.locality == tagLocalityTxs || tag.locality == tagLocalityLogRouter || tag == txsTag)) {
1290 continue;
1291 }
1292 } else if (!(logData->locality == tagLocalitySpecial || logData->locality == tag.locality ||
1293 tag.locality < 0)) {
1294 continue;
1295 }
1296
1297 if (tag.locality == tagLocalityLogRouter) {
1298 if (!logData->logRouterTags) {
1299 continue;
1300 }
1301 tag.id = tag.id % logData->logRouterTags;
1302 }

Callers 3

Future<Void> commitQueueFunction · 0.70
whenFunction · 0.70

Calls 15

TraceEventClass · 0.85
UnversionedFunction · 0.85
moveFunction · 0.85
emplace_backMethod · 0.80
detailMethod · 0.80
loadFromArenaMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
backMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected