MemStore.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 20 Memory Cache */
10 
11 #include "squid.h"
12 #include "base/RunnersRegistry.h"
13 #include "CollapsedForwarding.h"
14 #include "HttpReply.h"
15 #include "ipc/mem/Page.h"
16 #include "ipc/mem/Pages.h"
17 #include "MemObject.h"
18 #include "MemStore.h"
19 #include "mime_header.h"
20 #include "SquidConfig.h"
21 #include "SquidMath.h"
22 #include "StoreStats.h"
23 #include "tools.h"
24 
26 static const SBuf MapLabel("cache_mem_map");
28 static const char *SpaceLabel = "cache_mem_space";
30 static const char *ExtrasLabel = "cache_mem_ex";
31 // TODO: sync with Rock::SwapDir::*Path()
32 
33 // We store free slot IDs (i.e., "space") as Page objects so that we can use
34 // Ipc::Mem::PageStack. Pages require pool IDs. The value here is not really
35 // used except for a positivity test. A unique value is handy for debugging.
36 static const uint32_t SpacePoolId = 510716;
37 
40 class ShmWriter: public Packable
41 {
42 public:
43  ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice = -1);
44 
45  /* Packable API */
46  virtual void append(const char *aBuf, int aSize) override;
47  virtual void vappendf(const char *fmt, va_list ap) override;
48 
49 public:
51 
55 
58 
59  uint64_t totalWritten;
60 
61 protected:
62  void copyToShm();
64 
65 private:
67  const sfileno fileNo;
68 
69  /* set by (and only valid during) append calls */
70  const char *buf;
71  int bufSize;
72  int bufWritten;
73 };
74 
75 /* ShmWriter */
76 
77 ShmWriter::ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice):
78  entry(anEntry),
79  firstSlice(aFirstSlice),
80  lastSlice(firstSlice),
81  totalWritten(0),
82  store(aStore),
83  fileNo(aFileNo),
84  buf(nullptr),
85  bufSize(0),
86  bufWritten(0)
87 {
88  Must(entry);
89 }
90 
91 void
92 ShmWriter::append(const char *aBuf, int aBufSize)
93 {
94  Must(!buf);
95  buf = aBuf;
96  bufSize = aBufSize;
97  if (bufSize) {
98  Must(buf);
99  bufWritten = 0;
100  copyToShm();
101  }
102  buf = nullptr;
103  bufSize = 0;
104  bufWritten = 0;
105 }
106 
107 void
108 ShmWriter::vappendf(const char *fmt, va_list ap)
109 {
110  SBuf vaBuf;
111  va_list apCopy;
112  va_copy(apCopy, ap);
113  vaBuf.vappendf(fmt, apCopy);
114  va_end(apCopy);
115  append(vaBuf.rawContent(), vaBuf.length());
116 }
117 
119 void
121 {
122  Must(bufSize > 0); // do not use up shared memory pages for nothing
123  Must(firstSlice < 0 || lastSlice >= 0);
124 
125  // fill, skip slices that are already full
126  while (bufWritten < bufSize) {
128  if (firstSlice < 0)
130  copyToShmSlice(slice);
131  }
132 
133  debugs(20, 7, "stored " << bufWritten << '/' << totalWritten << " header bytes of " << *entry);
134 }
135 
137 void
139 {
141  debugs(20, 7, "entry " << *entry << " slice " << lastSlice << " has " <<
142  page);
143 
144  Must(bufWritten <= bufSize);
145  const int64_t writingDebt = bufSize - bufWritten;
146  const int64_t pageSize = Ipc::Mem::PageSize();
147  const int64_t sliceOffset = totalWritten % pageSize;
148  const int64_t copySize = std::min(writingDebt, pageSize - sliceOffset);
149  memcpy(static_cast<char*>(PagePointer(page)) + sliceOffset, buf + bufWritten,
150  copySize);
151 
152  debugs(20, 7, "copied " << slice.size << '+' << copySize << " bytes of " <<
153  entry << " from " << sliceOffset << " in " << page);
154 
155  slice.size += copySize;
156  bufWritten += copySize;
157  totalWritten += copySize;
158  // fresh anchor.basics.swap_file_sz is already set [to the stale value]
159 
160  // either we wrote everything or we filled the entire slice
161  Must(bufWritten == bufSize || sliceOffset + copySize == pageSize);
162 }
163 
164 /* MemStore */
165 
166 MemStore::MemStore(): map(NULL), lastWritingSlice(-1)
167 {
168 }
169 
171 {
172  delete map;
173 }
174 
175 void
177 {
178  const int64_t entryLimit = EntryLimit();
179  if (entryLimit <= 0)
180  return; // no shared memory cache configured or a misconfiguration
181 
182  // check compatibility with the disk cache, if any
183  if (Config.cacheSwap.n_configured > 0) {
184  const int64_t diskMaxSize = Store::Root().maxObjectSize();
185  const int64_t memMaxSize = maxObjectSize();
186  if (diskMaxSize == -1) {
187  debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
188  "is unlimited but mem-cache maximum object size is " <<
189  memMaxSize / 1024.0 << " KB");
190  } else if (diskMaxSize > memMaxSize) {
191  debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
192  "is too large for mem-cache: " <<
193  diskMaxSize / 1024.0 << " KB > " <<
194  memMaxSize / 1024.0 << " KB");
195  }
196  }
197 
200 
201  Must(!map);
202  map = new MemStoreMap(MapLabel);
203  map->cleaner = this;
204 }
205 
206 void
208 {
209  const size_t pageSize = Ipc::Mem::PageSize();
210 
211  stats.mem.shared = true;
212  stats.mem.capacity =
214  stats.mem.size =
216  stats.mem.count = currentCount();
217 }
218 
219 void
221 {
222  storeAppendPrintf(&e, "\n\nShared Memory Cache\n");
223 
224  storeAppendPrintf(&e, "Maximum Size: %.0f KB\n", maxSize()/1024.0);
225  storeAppendPrintf(&e, "Current Size: %.2f KB %.2f%%\n",
226  currentSize() / 1024.0,
228 
229  if (map) {
230  const int entryLimit = map->entryLimit();
231  const int slotLimit = map->sliceLimit();
232  storeAppendPrintf(&e, "Maximum entries: %9d\n", entryLimit);
233  if (entryLimit > 0) {
234  storeAppendPrintf(&e, "Current entries: %" PRId64 " %.2f%%\n",
235  currentCount(), (100.0 * currentCount() / entryLimit));
236  }
237 
238  storeAppendPrintf(&e, "Maximum slots: %9d\n", slotLimit);
239  if (slotLimit > 0) {
240  const unsigned int slotsFree =
242  if (slotsFree <= static_cast<const unsigned int>(slotLimit)) {
243  const int usedSlots = slotLimit - static_cast<const int>(slotsFree);
244  storeAppendPrintf(&e, "Used slots: %9d %.2f%%\n",
245  usedSlots, (100.0 * usedSlots / slotLimit));
246  }
247 
248  if (slotLimit < 100) { // XXX: otherwise too expensive to count
250  map->updateStats(stats);
251  stats.dump(e);
252  }
253  }
254  }
255 }
256 
257 void
259 {
260 }
261 
262 uint64_t
264 {
265  return 0; // XXX: irrelevant, but Store parent forces us to implement this
266 }
267 
268 uint64_t
270 {
271  return Config.memMaxSize;
272 }
273 
274 uint64_t
276 {
279 }
280 
281 uint64_t
283 {
284  return map ? map->entryCount() : 0;
285 }
286 
287 int64_t
289 {
291 }
292 
293 void
295 {
296 }
297 
298 bool
300 {
301  // no need to keep e in the global store_table for us; we have our own map
302  return false;
303 }
304 
305 StoreEntry *
307 {
308  if (!map)
309  return NULL;
310 
311  sfileno index;
312  const Ipc::StoreMapAnchor *const slot = map->openForReading(key, index);
313  if (!slot)
314  return NULL;
315 
316  // create a brand new store entry and initialize it with stored info
317  StoreEntry *e = new StoreEntry();
318 
319  // XXX: We do not know the URLs yet, only the key, but we need to parse and
320  // store the response for the Root().find() callers to be happy because they
321  // expect IN_MEMORY entries to already have the response headers and body.
322  e->createMemObject();
323 
324  anchorEntry(*e, index, *slot);
325 
326  const bool copied = copyFromShm(*e, index, *slot);
327 
328  if (copied)
329  return e;
330 
331  debugs(20, 3, "failed for " << *e);
332  map->freeEntry(index); // do not let others into the same trap
333  destroyStoreEntry(static_cast<hash_link *>(e));
334  return NULL;
335 }
336 
337 void
339 {
340  if (!map)
341  return;
342 
343  Ipc::StoreMapUpdate update(updatedE);
344  assert(updatedE);
345  assert(updatedE->mem_obj);
346  if (!map->openForUpdating(update, updatedE->mem_obj->memCache.index))
347  return;
348 
349  try {
350  updateHeadersOrThrow(update);
351  } catch (const std::exception &ex) {
352  debugs(20, 2, "error starting to update entry " << *updatedE << ": " << ex.what());
353  map->abortUpdating(update);
354  }
355 }
356 
357 void
359 {
360  // our +/- hdr_sz math below does not work if the chains differ [in size]
362 
363  const HttpReply *rawReply = update.entry->getReply();
364  Must(rawReply);
365  const HttpReply &reply = *rawReply;
366  const uint64_t staleHdrSz = reply.hdr_sz;
367  debugs(20, 7, "stale hdr_sz: " << staleHdrSz);
368 
369  /* we will need to copy same-slice payload after the stored headers later */
370  Must(staleHdrSz > 0);
371  update.stale.splicingPoint = map->sliceContaining(update.stale.fileNo, staleHdrSz);
372  Must(update.stale.splicingPoint >= 0);
373  Must(update.stale.anchor->basics.swap_file_sz >= staleHdrSz);
374 
375  Must(update.stale.anchor);
376  ShmWriter writer(*this, update.entry, update.fresh.fileNo);
377  reply.packHeadersUsingSlowPacker(writer);
378  const uint64_t freshHdrSz = writer.totalWritten;
379  debugs(20, 7, "fresh hdr_sz: " << freshHdrSz << " diff: " << (freshHdrSz - staleHdrSz));
380 
381  /* copy same-slice payload remaining after the stored headers */
382  const Ipc::StoreMapSlice &slice = map->readableSlice(update.stale.fileNo, update.stale.splicingPoint);
383  const Ipc::StoreMapSlice::Size sliceCapacity = Ipc::Mem::PageSize();
384  const Ipc::StoreMapSlice::Size headersInLastSlice = staleHdrSz % sliceCapacity;
385  Must(headersInLastSlice > 0); // or sliceContaining() would have stopped earlier
386  Must(slice.size >= headersInLastSlice);
387  const Ipc::StoreMapSlice::Size payloadInLastSlice = slice.size - headersInLastSlice;
388  const MemStoreMapExtras::Item &extra = extras->items[update.stale.splicingPoint];
389  char *page = static_cast<char*>(PagePointer(extra.page));
390  debugs(20, 5, "appending same-slice payload: " << payloadInLastSlice);
391  writer.append(page + headersInLastSlice, payloadInLastSlice);
392  update.fresh.splicingPoint = writer.lastSlice;
393 
394  update.fresh.anchor->basics.swap_file_sz -= staleHdrSz;
395  update.fresh.anchor->basics.swap_file_sz += freshHdrSz;
396 
397  map->closeForUpdating(update);
398 }
399 
400 bool
401 MemStore::anchorToCache(StoreEntry &entry, bool &inSync)
402 {
403  if (!map)
404  return false;
405 
406  sfileno index;
407  const Ipc::StoreMapAnchor *const slot = map->openForReading(
408  reinterpret_cast<cache_key*>(entry.key), index);
409  if (!slot)
410  return false;
411 
412  anchorEntry(entry, index, *slot);
413  inSync = updateAnchoredWith(entry, index, *slot);
414  return true; // even if inSync is false
415 }
416 
417 bool
419 {
420  if (!map)
421  return false;
422 
423  assert(entry.mem_obj);
424  assert(entry.hasMemStore());
425  const sfileno index = entry.mem_obj->memCache.index;
426  const Ipc::StoreMapAnchor &anchor = map->readableEntry(index);
427  return updateAnchoredWith(entry, index, anchor);
428 }
429 
431 bool
433 {
434  entry.swap_file_sz = anchor.basics.swap_file_sz;
435  const bool copied = copyFromShm(entry, index, anchor);
436  return copied;
437 }
438 
440 void
442 {
443  assert(!e.hasDisk()); // no conflict with disk entry basics
444  anchor.exportInto(e);
445 
446  assert(e.mem_obj);
447  if (anchor.complete()) {
451  } else {
453  assert(e.mem_obj->object_sz < 0);
455  }
456 
458 
460  mc.index = index;
462 }
463 
465 bool
467 {
468  debugs(20, 7, "mem-loading entry " << index << " from " << anchor.start);
469  assert(e.mem_obj);
470 
471  // emulate the usual Store code but w/o inapplicable checks and callbacks:
472 
473  Ipc::StoreMapSliceId sid = anchor.start; // optimize: remember the last sid
474  bool wasEof = anchor.complete() && sid < 0;
475  int64_t sliceOffset = 0;
476  while (sid >= 0) {
477  const Ipc::StoreMapSlice &slice = map->readableSlice(index, sid);
478  // slice state may change during copying; take snapshots now
479  wasEof = anchor.complete() && slice.next < 0;
480  const Ipc::StoreMapSlice::Size wasSize = slice.size;
481 
482  debugs(20, 9, "entry " << index << " slice " << sid << " eof " <<
483  wasEof << " wasSize " << wasSize << " <= " <<
484  anchor.basics.swap_file_sz << " sliceOffset " << sliceOffset <<
485  " mem.endOffset " << e.mem_obj->endOffset());
486 
487  if (e.mem_obj->endOffset() < sliceOffset + wasSize) {
488  // size of the slice data that we already copied
489  const size_t prefixSize = e.mem_obj->endOffset() - sliceOffset;
490  assert(prefixSize <= wasSize);
491 
492  const MemStoreMapExtras::Item &extra = extras->items[sid];
493 
494  char *page = static_cast<char*>(PagePointer(extra.page));
495  const StoreIOBuffer sliceBuf(wasSize - prefixSize,
496  e.mem_obj->endOffset(),
497  page + prefixSize);
498  if (!copyFromShmSlice(e, sliceBuf, wasEof))
499  return false;
500  debugs(20, 9, "entry " << index << " copied slice " << sid <<
501  " from " << extra.page << '+' << prefixSize);
502  }
503  // else skip a [possibly incomplete] slice that we copied earlier
504 
505  // careful: the slice may have grown _and_ gotten the next slice ID!
506  if (slice.next >= 0) {
507  assert(!wasEof);
508  // here we know that slice.size may not change any more
509  if (wasSize >= slice.size) { // did not grow since we started copying
510  sliceOffset += wasSize;
511  sid = slice.next;
512  }
513  } else if (wasSize >= slice.size) { // did not grow
514  break;
515  }
516  }
517 
518  if (!wasEof) {
519  debugs(20, 7, "mem-loaded " << e.mem_obj->endOffset() << '/' <<
520  anchor.basics.swap_file_sz << " bytes of " << e);
521  return true;
522  }
523 
524  debugs(20, 7, "mem-loaded all " << e.mem_obj->object_sz << '/' <<
525  anchor.basics.swap_file_sz << " bytes of " << e);
526 
527  // from StoreEntry::complete()
531 
532  assert(e.mem_obj->object_sz >= 0);
533  assert(static_cast<uint64_t>(e.mem_obj->object_sz) == anchor.basics.swap_file_sz);
534  // would be nice to call validLength() here, but it needs e.key
535 
536  // we read the entire response into the local memory; no more need to lock
537  disconnect(e);
538  return true;
539 }
540 
542 bool
544 {
545  debugs(20, 7, "buf: " << buf.offset << " + " << buf.length);
546 
547  // from store_client::readBody()
548  // parse headers if needed; they might span multiple slices!
549  HttpReply *rep = (HttpReply *)e.getReply();
550  if (rep->pstate < Http::Message::psParsed) {
551  // XXX: have to copy because httpMsgParseStep() requires 0-termination
552  MemBuf mb;
553  mb.init(buf.length+1, buf.length+1);
554  mb.append(buf.data, buf.length);
555  mb.terminate();
556  const int result = rep->httpMsgParseStep(mb.buf, buf.length, eof);
557  if (result > 0) {
559  } else if (result < 0) {
560  debugs(20, DBG_IMPORTANT, "Corrupted mem-cached headers: " << e);
561  return false;
562  } else { // more slices are needed
563  assert(!eof);
564  }
565  }
566  debugs(20, 7, "rep pstate: " << rep->pstate);
567 
568  // local memory stores both headers and body so copy regardless of pstate
569  const int64_t offBefore = e.mem_obj->endOffset();
570  assert(e.mem_obj->data_hdr.write(buf)); // from MemObject::write()
571  const int64_t offAfter = e.mem_obj->endOffset();
572  // expect to write the entire buf because StoreEntry::write() never fails
573  assert(offAfter >= 0 && offBefore <= offAfter &&
574  static_cast<size_t>(offAfter - offBefore) == buf.length);
575  return true;
576 }
577 
579 bool
581 {
582  if (e.mem_status == IN_MEMORY) {
583  debugs(20, 5, "already loaded from mem-cache: " << e);
584  return false;
585  }
586 
587  if (e.mem_obj && e.mem_obj->memCache.offset > 0) {
588  debugs(20, 5, "already written to mem-cache: " << e);
589  return false;
590  }
591 
592  if (!e.memoryCachable()) {
593  debugs(20, 7, HERE << "Not memory cachable: " << e);
594  return false; // will not cache due to entry state or properties
595  }
596 
597  assert(e.mem_obj);
598 
599  if (!e.mem_obj->vary_headers.isEmpty()) {
600  // XXX: We must store/load SerialisedMetaData to cache Vary in RAM
601  debugs(20, 5, "Vary not yet supported: " << e.mem_obj->vary_headers);
602  return false;
603  }
604 
605  const int64_t expectedSize = e.mem_obj->expectedReplySize(); // may be < 0
606  const int64_t loadedSize = e.mem_obj->endOffset();
607  const int64_t ramSize = max(loadedSize, expectedSize);
608  if (ramSize > maxObjectSize()) {
609  debugs(20, 5, HERE << "Too big max(" <<
610  loadedSize << ", " << expectedSize << "): " << e);
611  return false; // will not cache due to cachable entry size limits
612  }
613 
614  if (!e.mem_obj->isContiguous()) {
615  debugs(20, 5, "not contiguous");
616  return false;
617  }
618 
619  if (!map) {
620  debugs(20, 5, HERE << "No map to mem-cache " << e);
621  return false;
622  }
623 
624  if (EBIT_TEST(e.flags, ENTRY_SPECIAL)) {
625  debugs(20, 5, "Not mem-caching ENTRY_SPECIAL " << e);
626  return false;
627  }
628 
629  return true;
630 }
631 
633 bool
635 {
636  sfileno index = 0;
637  Ipc::StoreMapAnchor *slot = map->openForWriting(reinterpret_cast<const cache_key *>(e.key), index);
638  if (!slot) {
639  debugs(20, 5, HERE << "No room in mem-cache map to index " << e);
640  return false;
641  }
642 
643  assert(e.mem_obj);
644  e.mem_obj->memCache.index = index;
646  slot->set(e);
647  // Do not allow others to feed off an unknown-size entry because we will
648  // stop swapping it out if it grows too large.
649  if (e.mem_obj->expectedReplySize() >= 0)
650  map->startAppending(index);
651  e.memOutDecision(true);
652  return true;
653 }
654 
656 void
658 {
659  assert(map);
660  assert(e.mem_obj);
662 
663  const int64_t eSize = e.mem_obj->endOffset();
664  if (e.mem_obj->memCache.offset >= eSize) {
665  debugs(20, 5, "postponing copying " << e << " for lack of news: " <<
666  e.mem_obj->memCache.offset << " >= " << eSize);
667  return; // nothing to do (yet)
668  }
669 
670  // throw if an accepted unknown-size entry grew too big or max-size changed
671  Must(eSize <= maxObjectSize());
672 
673  const int32_t index = e.mem_obj->memCache.index;
674  assert(index >= 0);
675  Ipc::StoreMapAnchor &anchor = map->writeableEntry(index);
676  lastWritingSlice = anchor.start;
677 
678  // fill, skip slices that are already full
679  // Optimize: remember lastWritingSlice in e.mem_obj
680  while (e.mem_obj->memCache.offset < eSize) {
683  if (anchor.start < 0)
684  anchor.start = lastWritingSlice;
685  copyToShmSlice(e, anchor, slice);
686  }
687 
688  debugs(20, 7, "mem-cached available " << eSize << " bytes of " << e);
689 }
690 
692 void
694 {
696  debugs(20, 7, "entry " << e << " slice " << lastWritingSlice << " has " <<
697  page);
698 
699  const int64_t bufSize = Ipc::Mem::PageSize();
700  const int64_t sliceOffset = e.mem_obj->memCache.offset % bufSize;
701  StoreIOBuffer sharedSpace(bufSize - sliceOffset, e.mem_obj->memCache.offset,
702  static_cast<char*>(PagePointer(page)) + sliceOffset);
703 
704  // check that we kept everything or purge incomplete/sparse cached entry
705  const ssize_t copied = e.mem_obj->data_hdr.copy(sharedSpace);
706  if (copied <= 0) {
707  debugs(20, 2, "Failed to mem-cache " << (bufSize - sliceOffset) <<
708  " bytes of " << e << " from " << e.mem_obj->memCache.offset <<
709  " in " << page);
710  throw TexcHere("data_hdr.copy failure");
711  }
712 
713  debugs(20, 7, "mem-cached " << copied << " bytes of " << e <<
714  " from " << e.mem_obj->memCache.offset << " in " << page);
715 
716  slice.size += copied;
717  e.mem_obj->memCache.offset += copied;
719 }
720 
724 MemStore::nextAppendableSlice(const sfileno fileNo, sfileno &sliceOffset)
725 {
726  // allocate the very first slot for the entry if needed
727  if (sliceOffset < 0) {
728  Ipc::StoreMapAnchor &anchor = map->writeableEntry(fileNo);
729  Must(anchor.start < 0);
730  Ipc::Mem::PageId page;
731  sliceOffset = reserveSapForWriting(page); // throws
732  extras->items[sliceOffset].page = page;
733  anchor.start = sliceOffset;
734  }
735 
736  const size_t sliceCapacity = Ipc::Mem::PageSize();
737  do {
738  Ipc::StoreMap::Slice &slice = map->writeableSlice(fileNo, sliceOffset);
739 
740  if (slice.size >= sliceCapacity) {
741  if (slice.next >= 0) {
742  sliceOffset = slice.next;
743  continue;
744  }
745 
746  Ipc::Mem::PageId page;
747  slice.next = sliceOffset = reserveSapForWriting(page);
748  extras->items[sliceOffset].page = page;
749  debugs(20, 7, "entry " << fileNo << " new slice: " << sliceOffset);
750  continue; // to get and return the slice at the new sliceOffset
751  }
752 
753  return slice;
754  } while (true);
755  /* not reached */
756 }
757 
761 {
762  Must(extras);
763  Must(sliceId >= 0);
764  Ipc::Mem::PageId page = extras->items[sliceId].page;
765  Must(page);
766  return page;
767 }
768 
770 sfileno
772 {
773  Ipc::Mem::PageId slot;
774  if (freeSlots->pop(slot)) {
775  debugs(20, 5, "got a previously free slot: " << slot);
776 
778  debugs(20, 5, "and got a previously free page: " << page);
779  return slot.number - 1;
780  } else {
781  debugs(20, 3, "but there is no free page, returning " << slot);
782  freeSlots->push(slot);
783  }
784  }
785 
786  // catch free slots delivered to noteFreeMapSlice()
787  assert(!waitingFor);
788  waitingFor.slot = &slot;
789  waitingFor.page = &page;
790  if (map->purgeOne()) {
791  assert(!waitingFor); // noteFreeMapSlice() should have cleared it
792  assert(slot.set());
793  assert(page.set());
794  debugs(20, 5, "got previously busy " << slot << " and " << page);
795  return slot.number - 1;
796  }
797  assert(waitingFor.slot == &slot && waitingFor.page == &page);
798  waitingFor.slot = NULL;
799  waitingFor.page = NULL;
800 
801  debugs(47, 3, "cannot get a slice; entries: " << map->entryCount());
802  throw TexcHere("ran out of mem-cache slots");
803 }
804 
805 void
807 {
808  Ipc::Mem::PageId &pageId = extras->items[sliceId].page;
809  debugs(20, 9, "slice " << sliceId << " freed " << pageId);
810  assert(pageId);
811  Ipc::Mem::PageId slotId;
812  slotId.pool = SpacePoolId;
813  slotId.number = sliceId + 1;
814  if (!waitingFor) {
815  // must zero pageId before we give slice (and pageId extras!) to others
816  Ipc::Mem::PutPage(pageId);
817  freeSlots->push(slotId);
818  } else {
819  *waitingFor.slot = slotId;
820  *waitingFor.page = pageId;
821  waitingFor.slot = NULL;
822  waitingFor.page = NULL;
823  pageId = Ipc::Mem::PageId();
824  }
825 }
826 
827 void
829 {
830  assert(e.mem_obj);
831 
832  debugs(20, 7, "entry " << e);
833 
834  switch (e.mem_obj->memCache.io) {
836  if (!shouldCache(e) || !startCaching(e)) {
838  e.memOutDecision(false);
839  return;
840  }
841  break;
842 
843  case MemObject::ioDone:
845  return; // we should not write in all of the above cases
846 
848  break; // already decided to write and still writing
849  }
850 
851  try {
852  copyToShm(e);
853  if (e.store_status == STORE_OK) // done receiving new content
854  completeWriting(e);
855  else
857  return;
858  } catch (const std::exception &x) { // TODO: should we catch ... as well?
859  debugs(20, 2, "mem-caching error writing entry " << e << ": " << x.what());
860  // fall through to the error handling code
861  }
862 
863  disconnect(e);
864 }
865 
866 void
868 {
869  assert(e.mem_obj);
870  const int32_t index = e.mem_obj->memCache.index;
871  assert(index >= 0);
872  assert(map);
873 
874  debugs(20, 5, "mem-cached all " << e.mem_obj->memCache.offset << " bytes of " << e);
875 
876  e.mem_obj->memCache.index = -1;
878  map->closeForWriting(index);
879 
880  CollapsedForwarding::Broadcast(e); // before we close our transient entry!
882 }
883 
884 void
886 {
887  debugs(47, 5, e);
888  if (e.hasMemStore()) {
891  if (!e.locked()) {
892  disconnect(e);
893  e.destroyMemObject();
894  }
895  } else if (const auto key = e.publicKey()) {
896  // the entry may have been loaded and then disconnected from the cache
897  evictIfFound(key);
898  if (!e.locked())
899  e.destroyMemObject();
900  }
901 }
902 
903 void
905 {
906  if (map)
907  map->freeEntryByKey(key);
908 }
909 
910 void
912 {
913  assert(e.mem_obj);
914  MemObject &mem_obj = *e.mem_obj;
915  if (e.hasMemStore()) {
916  if (mem_obj.memCache.io == MemObject::ioWriting) {
917  map->abortWriting(mem_obj.memCache.index);
918  mem_obj.memCache.index = -1;
919  mem_obj.memCache.io = MemObject::ioDone;
920  Store::Root().stopSharing(e); // broadcasts after the change
921  } else {
923  map->closeForReading(mem_obj.memCache.index);
924  mem_obj.memCache.index = -1;
925  mem_obj.memCache.io = MemObject::ioDone;
926  }
927  }
928 }
929 
930 bool
932 {
933  return Config.memShared && Config.memMaxSize > 0;
934 }
935 
937 int64_t
939 {
940  if (!Requested())
941  return 0;
942 
943  const int64_t minEntrySize = Ipc::Mem::PageSize();
944  const int64_t entryLimit = Config.memMaxSize / minEntrySize;
945  return entryLimit;
946 }
947 
952 {
953 public:
954  /* RegisteredRunner API */
956  virtual void finalizeConfig();
957  virtual void claimMemoryNeeds();
958  virtual void useConfig();
959  virtual ~MemStoreRr();
960 
961 protected:
962  /* Ipc::Mem::RegisteredRunner API */
963  virtual void create();
964 
965 private:
969 };
970 
972 
973 void
975 {
977 }
978 
979 void
981 {
982  // decide whether to use a shared memory cache if the user did not specify
983  if (!Config.memShared.configured()) {
985  Config.memMaxSize > 0);
986  } else if (Config.memShared && !Ipc::Mem::Segment::Enabled()) {
987  fatal("memory_cache_shared is on, but no support for shared memory detected");
988  } else if (Config.memShared && !UsingSmp()) {
989  debugs(20, DBG_IMPORTANT, "WARNING: memory_cache_shared is on, but only"
990  " a single worker is running");
991  }
992 
994  debugs(20, DBG_IMPORTANT, "WARNING: mem-cache size is too small (" <<
995  (Config.memMaxSize / 1024.0) << " KB), should be >= " <<
996  (Ipc::Mem::PageSize() / 1024.0) << " KB");
997  }
998 }
999 
1000 void
1002 {
1005 }
1006 
1007 void
1009 {
1010  if (!MemStore::Enabled())
1011  return;
1012 
1013  const int64_t entryLimit = MemStore::EntryLimit();
1014  assert(entryLimit > 0);
1015  Must(!spaceOwner);
1017  entryLimit, 0);
1018  Must(!mapOwner);
1019  mapOwner = MemStoreMap::Init(MapLabel, entryLimit);
1020  Must(!extrasOwner);
1022 }
1023 
1025 {
1026  delete extrasOwner;
1027  delete mapOwner;
1028  delete spaceOwner;
1029 }
1030 
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: MemStore.cc:263
sfileno fileNo
StoreMap::fileNos[name], for convenience/speed.
Definition: StoreMap.h:172
virtual void claimMemoryNeeds()
Definition: MemStore.cc:974
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: MemStore.cc:207
std::atomic< uint64_t > swap_file_sz
Definition: StoreMap.h:102
bool freeEntry(const sfileno)
Definition: StoreMap.cc:263
bool complete() const
Definition: StoreMap.h:74
#define assert(EX)
Definition: assert.h:17
struct Ipc::StoreMapAnchor::Basics basics
size_t maxInMemObjSize
Definition: SquidConfig.h:268
virtual uint64_t maxSize() const override
Definition: MemStore.cc:269
std::atomic< StoreMapSliceId > next
ID of the next entry slice.
Definition: StoreMap.h:46
virtual void append(const char *c, int sz)
Definition: MemBuf.cc:216
const char * buf
content being appended now
Definition: MemStore.cc:70
Aggregates information required for updating entry metadata and headers.
Definition: StoreMap.h:159
SlotAndPage waitingFor
a cache for a single "hot" free slot and page
Definition: MemStore.h:117
ParseState pstate
the current parsing state
Definition: Message.h:94
void copyToShm(StoreEntry &e)
copies all local data to shared memory
Definition: MemStore.cc:657
void push(PageId &page)
makes value available as a free page number to future pop() callers
Definition: PageStack.cc:76
int entryLimit() const
maximum entryCount() possible
Definition: StoreMap.cc:652
int hdr_sz
Definition: Message.h:81
double size
bytes currently in use
Definition: StoreStats.h:20
Definition: SBuf.h:86
std::atomic< Size > size
slice contents size
Definition: StoreMap.h:45
Ipc::Mem::Pointer< Ipc::Mem::PageStack > freeSlots
unused map slot IDs
Definition: MemStore.h:99
char * PagePointer(const PageId &page)
converts page handler into a temporary writeable shared memory pointer
Definition: Pages.cc:48
unsigned char cache_key
Store key.
Definition: forward.h:29
static constexpr Io ioWriting
Definition: MemObject.h:130
#define shm_old(Class)
Definition: Pointer.h:180
virtual ~MemStoreRr()
Definition: MemStore.cc:1024
void completeWriting(StoreEntry &e)
all data has been received; there will be no more write() calls
Definition: MemStore.cc:867
void freeEntryByKey(const cache_key *const key)
Definition: StoreMap.cc:281
int64_t endOffset() const
Definition: MemObject.cc:218
#define PRId64
Definition: types.h:110
static const uint32_t SpacePoolId
Definition: MemStore.cc:36
Ipc::Mem::PageId * slot
local slot variable, waiting to be filled
Definition: MemStore.h:114
ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice=-1)
Definition: MemStore.cc:77
void stopSharing(StoreEntry &)
stop any current (and prevent any future) SMP sharing of the given entry
Definition: Controller.cc:592
Ipc::StoreMap MemStoreMap
Definition: MemStore.h:23
MemStoreMap * map
index of mem-cached entries
Definition: MemStore.h:100
virtual void init() override
Definition: MemStore.cc:176
YesNoNone memShared
whether the memory cache is shared among workers
Definition: SquidConfig.h:83
void abortUpdating(Update &update)
undoes partial update, unlocks, and cleans up
Definition: StoreMap.cc:227
void updateHeadersOrThrow(Ipc::StoreMapUpdate &update)
Definition: MemStore.cc:358
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1997
Io io
current I/O state
Definition: MemObject.h:149
MemStore()
Definition: MemStore.cc:166
bool shouldCache(StoreEntry &e) const
whether we should cache the entry
Definition: MemStore.cc:580
class Ping::pingStats_ stats
bool copyFromShm(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
copies the entire entry from shared to local memory
Definition: MemStore.cc:466
virtual void finalizeConfig()
Definition: MemStore.cc:980
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: MemStore.cc:282
void NotePageNeed(const int purpose, const int count)
claim the need for a number of pages for a given purpose
Definition: Pages.cc:72
StoreMapCleaner * cleaner
notified before a readable entry is freed
Definition: StoreMap.h:319
approximate stats of a set of ReadWriteLocks
Definition: ReadWriteLock.h:56
struct SquidConfig::@110 Store
uint32_t Size
Definition: StoreMap.h:31
static void Broadcast(const StoreEntry &e, const bool includingThisWorker=false)
notify other workers about changes in entry state (e.g., new data)
bool GetPage(const PageId::Purpose purpose, PageId &page)
sets page ID and returns true unless no free pages are found
Definition: Pages.cc:34
void closeForWriting(const sfileno fileno)
successfully finish creating or updating the entry at fileno pos
Definition: StoreMap.cc:158
bool isEmpty() const
Definition: SBuf.h:420
virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: MemStore.cc:806
static Owner * Init(const SBuf &path, const int slotLimit)
initialize shared memory
Definition: StoreMap.cc:38
static const SBuf MapLabel("cache_mem_map")
shared memory segment path to use for MemStore maps
bool openForUpdating(Update &update, sfileno fileNoHint)
finds and locks the Update entry for an exclusive metadata update
Definition: StoreMap.cc:439
Controller & Root()
safely access controller singleton
Definition: Controller.cc:877
uint32_t pool
page pool ID within Squid
Definition: Page.h:33
Ipc::Mem::PageId * page
local page variable, waiting to be filled
Definition: MemStore.h:115
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: MemStore.cc:288
RunnerRegistrationEntry(MemStoreRr)
double count
number of cached objects
Definition: StoreStats.h:21
void memOutDecision(const bool willCacheInRam)
Definition: store.cc:1856
void destroyMemObject()
Definition: store.cc:372
A const & max(A const &lhs, A const &rhs)
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:151
static constexpr Io ioUndecided
Definition: MemObject.h:128
int32_t index
entry position inside the memory cache
Definition: MemObject.h:146
Ipc::StoreMap::Slice & nextAppendableSlice(const sfileno entryIndex, sfileno &sliceOffset)
Definition: MemStore.cc:724
virtual void evictIfFound(const cache_key *) override
Definition: MemStore.cc:904
bool updateAnchoredWith(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &)
updates Transients entry after its anchor has been located
Definition: MemStore.cc:432
void anchorEntry(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
anchors StoreEntry to an already locked map entry
Definition: MemStore.cc:441
void init(mb_size_t szInit, mb_size_t szMax)
Definition: MemBuf.cc:96
virtual uint64_t currentSize() const override
current size
Definition: MemStore.cc:275
static bool Enabled()
Whether shared memory support is available.
Definition: Segment.cc:321
double capacity
the size limit
Definition: StoreStats.h:22
bool copyFromShmSlice(StoreEntry &e, const StoreIOBuffer &buf, bool eof)
imports one shared memory slice into local memory
Definition: MemStore.cc:543
double doublePercent(const double, const double)
Definition: SquidMath.cc:25
Mem mem
all cache_dirs stats
Definition: StoreStats.h:49
int locked() const
Definition: store.cc:1249
uint64_t swap_file_sz
Definition: Store.h:206
int bufSize
buf size
Definition: MemStore.cc:71
uint32_t number
page number within the segment
Definition: Page.h:35
bool startCaching(StoreEntry &e)
locks map anchor and preps to store the entry in shared memory
Definition: MemStore.cc:634
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:404
int64_t offset
Definition: StoreIOBuffer.h:55
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:143
bool write(StoreIOBuffer const &)
Definition: stmem.cc:342
int64_t object_sz
Definition: MemObject.h:168
size_t PagesAvailable()
approximate total number of shared memory pages we can allocate now
Definition: Pages.h:47
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:124
void startAppending(const sfileno fileno)
restrict opened for writing entry to appending operations; allow reads
Definition: StoreMap.cc:149
virtual ~MemStore()
Definition: MemStore.cc:170
static bool Enabled()
whether Squid is correctly configured to use a shared memory cache
Definition: MemStore.h:68
#define DBG_IMPORTANT
Definition: Debug.h:46
bool pop(PageId &page)
sets value and returns true unless no free page numbers are found
Definition: PageStack.cc:40
virtual void evictCached(StoreEntry &) override
Definition: MemStore.cc:885
void write(StoreEntry &e)
copy non-shared entry data of the being-cached entry to our cache
Definition: MemStore.cc:828
bool configured() const
Definition: YesNoNone.h:67
HttpReply const * getReply() const
Definition: store.cc:1670
virtual bool anchorToCache(StoreEntry &e, bool &inSync) override
Definition: MemStore.cc:401
mem_status_t mem_status
Definition: Store.h:216
virtual void vappendf(const char *fmt, va_list ap) override
Definition: MemStore.cc:108
Slice & writeableSlice(const AnchorId anchorId, const SliceId sliceId)
writeable slice within an entry chain created by openForWriting()
Definition: StoreMap.cc:179
virtual bool dereference(StoreEntry &e) override
Definition: MemStore.cc:299
bool hasMemStore() const
whether there is a corresponding locked shared memory table entry
Definition: Store.h:189
virtual void stat(StoreEntry &e) const override
Definition: MemStore.cc:220
int32_t StoreMapSliceId
Definition: StoreMap.h:24
SliceId sliceContaining(const sfileno fileno, const uint64_t nth) const
Definition: StoreMap.cc:364
void updateStats(ReadWriteLockStats &stats) const
adds approximate current stats to the supplied ones
Definition: StoreMap.cc:670
void fatal(const char *message)
Definition: fatal.cc:28
MemStore & store
Definition: MemStore.cc:66
Anchor & writeableEntry(const AnchorId anchorId)
writeable anchor for the entry created by openForWriting()
Definition: StoreMap.cc:195
const sfileno fileNo
Definition: MemStore.cc:67
void abortWriting(const sfileno fileno)
stop writing the entry, freeing its slot for others to use if possible
Definition: StoreMap.cc:209
uint16_t flags
Definition: Store.h:208
void copyToShm()
copies the entire buffer to shared memory
Definition: MemStore.cc:120
ssize_t copy(StoreIOBuffer const &) const
Definition: stmem.cc:226
StoreMapAnchor * anchor
StoreMap::anchors[fileNo], for convenience/speed.
Definition: StoreMap.h:171
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition: YesNoNone.h:53
signed_int32_t sfileno
Definition: forward.h:22
MemObject * mem_obj
Definition: Store.h:197
void disconnect(StoreEntry &e)
called when the entry is about to forget its association with mem cache
Definition: MemStore.cc:911
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:658
virtual StoreEntry * get(const cache_key *) override
Definition: MemStore.cc:306
Ipc::Mem::Owner< Ipc::Mem::PageStack > * spaceOwner
free slices Owner
Definition: MemStore.cc:966
void const char * buf
Definition: stub_helper.cc:16
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:153
#define shm_new(Class)
Definition: Pointer.h:179
bool shared
whether memory cache is shared among workers
Definition: StoreStats.h:42
bool set() const
true if and only if both critical components have been initialized
Definition: Page.h:27
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: MemStore.cc:938
Definition: enums.h:46
int sliceLimit() const
maximum number of slices possible
Definition: StoreMap.cc:664
SBuf vary_headers
Definition: MemObject.h:174
void packHeadersUsingSlowPacker(Packable &p) const
same as packHeadersUsingFastPacker() but assumes that p cannot quickly process small additions ...
Definition: HttpReply.cc:94
size_t PageSize()
returns page size in bytes; all pages are assumed to be the same size
Definition: Pages.cc:28
char * buf
Definition: MemBuf.h:134
static bool Requested()
Definition: MemStore.cc:931
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: MemStore.cc:258
#define EBIT_SET(flag, bit)
Definition: defines.h:105
void transientsCompleteWriting(StoreEntry &)
marks the entry completed for collapsed requests
Definition: Controller.cc:602
store_status_t store_status
Definition: Store.h:220
const Anchor * openForReading(const cache_key *const key, sfileno &fileno)
opens entry (identified by key) for reading, increments read level
Definition: StoreMap.cc:383
virtual bool updateAnchored(StoreEntry &) override
Definition: MemStore.cc:418
const Anchor & readableEntry(const AnchorId anchorId) const
readable anchor for the entry created by openForReading()
Definition: StoreMap.cc:202
Edition stale
old anchor and chain being updated
Definition: StoreMap.h:186
void copyToShmSlice(StoreEntry &e, Ipc::StoreMapAnchor &anchor, Ipc::StoreMap::Slice &slice)
copies at most one slice worth of local memory to shared memory
Definition: MemStore.cc:693
bool memoryCachable()
checkCachable() and can be cached in memory
Definition: store.cc:1339
StoreEntry * entry
the entry being updated
Definition: MemStore.cc:50
Store::DiskConfig cacheSwap
Definition: SquidConfig.h:423
Ipc::StoreMapSliceId lastSlice
the slot keeping the last byte of the appended content (at least)
Definition: MemStore.cc:57
Ipc::Mem::Owner< MemStoreMapExtras > * extrasOwner
PageIds Owner.
Definition: MemStore.cc:968
Edition fresh
new anchor and updated chain prefix
Definition: StoreMap.h:187
virtual void useConfig()
Definition: Segment.cc:376
int bufWritten
buf bytes appended so far
Definition: MemStore.cc:72
aggregates anchor and slice owners for Init() caller convenience
Definition: StoreMap.h:210
void exportInto(StoreEntry &) const
load StoreEntry basics that were previously stored with set()
Definition: StoreMap.cc:797
const cache_key * publicKey() const
Definition: Store.h:98
Shared memory page identifier, address, or handler.
Definition: Page.h:21
sfileno reserveSapForWriting(Ipc::Mem::PageId &page)
finds a slot and a free page to fill or throws
Definition: MemStore.cc:771
size_t PageLevel()
approximate total number of shared memory pages used now
Definition: Pages.cc:80
Definition: MemBuf.h:23
size_t memMaxSize
Definition: SquidConfig.h:85
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:55
int httpMsgParseStep(const char *buf, int len, int atEnd)
Definition: Message.cc:170
static const char * SpaceLabel
shared memory segment path to use for the free slices index
Definition: MemStore.cc:28
void PutPage(PageId &page)
makes identified page available as a free page to future GetPage() callers
Definition: Pages.cc:41
Ipc::Mem::Pointer< Extras > extras
IDs of pages with slice data.
Definition: MemStore.h:103
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: MemStore.cc:294
void set(const StoreEntry &anEntry, const cache_key *aKey=nullptr)
store StoreEntry key and basics for an inode slot
Definition: StoreMap.cc:777
bool purgeOne()
either finds and frees an entry with at least 1 slice or returns false
Definition: StoreMap.cc:621
const Slice & readableSlice(const AnchorId anchorId, const SliceId sliceId) const
readable slice within an entry chain opened by openForReading()
Definition: StoreMap.cc:187
StoreMapSliceId splicingPoint
the last slice in the chain still containing metadata/headers
Definition: StoreMap.h:176
virtual void append(const char *aBuf, int aSize) override
Appends a c-string to existing packed data.
Definition: MemStore.cc:92
static const char * ExtrasLabel
shared memory segment path to use for IDs of shared pages with slice data
Definition: MemStore.cc:30
SBuf & vappendf(const char *fmt, va_list vargs)
Definition: SBuf.cc:249
Anchor * openForWriting(const cache_key *const key, sfileno &fileno)
Definition: StoreMap.cc:98
mem_hdr data_hdr
Definition: MemObject.h:103
static constexpr Io ioDone
Definition: MemObject.h:131
sfileno lastWritingSlice
the last allocate slice for writing a store entry (during copyToShm)
Definition: MemStore.h:106
static constexpr Io ioReading
Definition: MemObject.h:129
const char * rawContent() const
Definition: SBuf.cc:519
bool isContiguous() const
Definition: MemObject.cc:392
Ipc::StoreMapSliceId firstSlice
Definition: MemStore.cc:54
virtual void create()
called when the runner should create a new memory segment
Definition: MemStore.cc:1008
void closeForReading(const sfileno fileno)
closes open entry after reading, decrements read level
Definition: StoreMap.cc:430
std::atomic< StoreMapSliceId > start
where the chain of StoreEntry slices begins [app]
Definition: StoreMap.h:108
FREE destroyStoreEntry
uint64_t totalWritten
cumulative number of bytes appended so far
Definition: MemStore.cc:59
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:875
int entryCount() const
number of writeable and readable entries
Definition: StoreMap.cc:658
virtual void updateHeaders(StoreEntry *e) override
make stored metadata and HTTP headers the same as in the given entry
Definition: MemStore.cc:338
MemStoreMap::Owner * mapOwner
primary map Owner
Definition: MemStore.cc:967
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
size_t PageLimit()
the total number of shared memory pages that can be in use at any time
Definition: Pages.cc:55
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
void copyToShmSlice(Ipc::StoreMap::Slice &slice)
copies at most one slice worth of buffer to shared memory
Definition: MemStore.cc:138
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:191
Ipc::Mem::PageId pageForSlice(Ipc::StoreMapSliceId sliceId)
safely returns a previously allocated memory page for the given entry slice
Definition: MemStore.cc:760
int64_t expectedReplySize() const
Definition: MemObject.cc:242
A const & min(A const &lhs, A const &rhs)
void closeForUpdating(Update &update)
makes updated info available to others, unlocks, and cleans up
Definition: StoreMap.cc:527
void dump(StoreEntry &e) const
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:147
virtual void useConfig()
Definition: MemStore.cc:1001
StoreEntry * entry
the store entry being updated
Definition: StoreMap.h:185
void setMemStatus(mem_status_t)
Definition: store.cc:1558
void terminate()
Definition: MemBuf.cc:250
void createMemObject()
Definition: store.cc:1609

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors