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

Function commitMessages

fdbserver/LogRouter.actor.cpp:207–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205};
206
207void commitMessages(LogRouterData* self, Version version, const std::vector<TagsAndMessage>& taggedMessages) {
208 if (!taggedMessages.size()) {
209 return;
210 }
211
212 int msgSize = 0;
213 for (const auto& i : taggedMessages) {
214 msgSize += i.message.size();
215 }
216
217 // Grab the last block in the blocks list so we can share its arena
218 // We pop all of the elements of it to create a "fresh" vector that starts at the end of the previous vector
219 Standalone<VectorRef<uint8_t>> block;
220 if (self->messageBlocks.empty()) {
221 block = Standalone<VectorRef<uint8_t>>();
222 block.reserve(block.arena(), std::max<int64_t>(SERVER_KNOBS->TLOG_MESSAGE_BLOCK_BYTES, msgSize));
223 } else {
224 block = self->messageBlocks.back().second;
225 }
226
227 block.pop_front(block.size());
228
229 for (const auto& msg : taggedMessages) {
230 if (msg.message.size() > block.capacity() - block.size()) {
231 self->messageBlocks.emplace_back(version, block);
232 block = Standalone<VectorRef<uint8_t>>();
233 block.reserve(block.arena(), std::max<int64_t>(SERVER_KNOBS->TLOG_MESSAGE_BLOCK_BYTES, msgSize));
234 }
235
236 block.append(block.arena(), msg.message.begin(), msg.message.size());
237 for (const auto& tag : msg.tags) {
238 auto tagData = self->getTagData(tag);
239 if (!tagData) {
240 tagData = self->createTagData(tag, 0, 0);
241 }
242
243 if (version >= tagData->popped) {
244 tagData->version_messages.emplace_back(
245 version, LengthPrefixedStringRef((uint32_t*)(block.end() - msg.message.size())));
246 if (tagData->version_messages.back().second.expectedSize() > SERVER_KNOBS->MAX_MESSAGE_SIZE) {
247 TraceEvent(SevWarnAlways, "LargeMessage")
248 .detail("Size", tagData->version_messages.back().second.expectedSize());
249 }
250 }
251 }
252
253 msgSize -= msg.message.size();
254 }
255 self->messageBlocks.emplace_back(version, block);
256}
257
258ACTOR Future<Void> waitForVersion(LogRouterData* self, Version ver) {
259 // The only time the log router should allow a gap in versions larger than MAX_READ_TRANSACTION_LIFE_VERSIONS is

Callers 1

Calls 15

TraceEventClass · 0.85
emplace_backMethod · 0.80
detailMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
backMethod · 0.45
pop_frontMethod · 0.45
capacityMethod · 0.45
appendMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected