MySQL 9.1.0
Source Code Documentation
|
This class is used for storing unstructured optimizer trace text (as used by the Hypergraph optimizer). More...
#include <optimizer_trace.h>
Public Member Functions | |
TraceBuffer (int64_t max_bytes) | |
int_type | overflow (int_type ch) override |
Called by std::ostream if the current segment is full. More... | |
template<typename Sink > | |
void | Consume (Sink sink) |
Apply 'sink' to each character in the trace text. More... | |
int64_t | excess_bytes () const |
Get the number of bytes that did not fit in m_segments. More... | |
std::string | ToString () const |
Return a copy of the contents as a string. More... | |
Static Public Attributes | |
static constexpr int64_t | kSegmentSize {4096} |
The size of each consecutive buffer. More... | |
Private Types | |
using | Segment = std::array< char, kSegmentSize > |
A consecutive buffer. More... | |
Private Attributes | |
int64_t | m_max_segments |
Max number of segments (as given by the optimizer_trace_max_mem_size system variable). More... | |
std::deque< Segment > | m_segments |
The sequence of segments. More... | |
std::unique_ptr< Segment > | m_excess_segment |
If we fill m_max_segments, allocate a single extra segment that is repeatedly overwritten with any additional data. More... | |
int64_t | m_full_excess_segments {0} |
The number of full segments that did not fit in m_segments. More... | |
This class is used for storing unstructured optimizer trace text (as used by the Hypergraph optimizer).
It is used as the std::streambuf object of an associated std::ostream (which writes the formatted text into a TraceBuffer object). The text is stored in a non-consecutive sequence of segments, where each segment has a chunk of consecutive memory. That way, the buffer can grow without having to copy the text into ever bigger buffers of consecutive memory.
|
private |
A consecutive buffer.
|
inlineexplicit |
max_bytes | The maximal number of trace bytes, as given by the optimizer_trace_max_mem_size system variable. |
|
inline |
Apply 'sink' to each character in the trace text.
Free each segment when its contents have been consumed. (That way, we avoid storing two copies of a potentially huge trace at the same time.)
|
inline |
Get the number of bytes that did not fit in m_segments.
|
override |
Called by std::ostream if the current segment is full.
Allocate a new segment (or use m_excess_segment if we have reached m_max_segments) and put 'ch' at the beginning of it.
|
inline |
Return a copy of the contents as a string.
This may be expensive for large traces, and is only intended for unit tests.
|
staticconstexpr |
The size of each consecutive buffer.
|
private |
If we fill m_max_segments, allocate a single extra segment that is repeatedly overwritten with any additional data.
This field will point to that segment.
|
private |
The number of full segments that did not fit in m_segments.
|
private |
Max number of segments (as given by the optimizer_trace_max_mem_size system variable).
|
private |
The sequence of segments.