Squid Web Cache wiki

Squid Web Cache documentation

🔗 StringNg

StringNg is Squid’s representation of a String-buffer

🔗 Aims

Aim of this implementation effort is to increase the primitives squid uses for string manipulation, in particular:

🔗 memory management

🔗 Architectural overview

Three main classes perform the job

Instances of SBuf have an N-to-1 relationship with instances of MemBlob: one MemBlob holds the data of many SBuf’s, possibly overlapping in part or in whole.

SBufs implement copy-on-write to prevent aliasing side-effects. Shortcuts are provided for the common cases, e.g. appending to a SBuf (no COW when there is unused space at the end of the MemBlob) or when the SBuf is the only holder of the MemBlob.

Memory Manager friendliness can be obtained by tuning the allocation strategies for MemBlobs. Current practices are: heuristics are used to define how much extra space to allocate. Burden is split between SBuf and MemBlob: the former former uses SBuf-local informations (e.g. the length of the SBuf lifetime expressed in number of copy operations), while MemBlob handles lower-level optimizations.

🔗 Optimizations

SBufs (and StringNgs) are mainly immutable. It needn’t be so in all cases. For instance, changing portions of strings may be allowed when a SBuf owns the MemBlob (aka when the MemBlob’s refcount is 1).

🔗 Thread safety

Thread safety is out of scope.

Navigation: Site Search, Site Pages, Categories, 🔼 go up