Documentation
¶
Overview ¶
Package logpattern compiles an SQI_LOG_CHECKS pattern under the size bound that both the server (submission validation, internal/openjd) and the worker (the checker it runs against every output line, internal/worker/executor) enforce. It is a stdlib-only leaf because the worker must not import internal/openjd, and both sides need the same bound.
Index ¶
Constants ¶
const ( // MaxPatterns is the most patterns one list may hold. MaxPatterns = 32 // MaxPatternBytes is the longest a single pattern may be. MaxPatternBytes = 1024 )
Limits on one pattern list, shared by every step-block extension that carries patterns (SQI_LOG_CHECKS, SQI_LOG_PROGRESS) so the server never accepts a list the worker refuses.
const EstimateCeiling = 2 * MaxProgramInsts
EstimateCeiling is the estimate above which Compile rejects a pattern without compiling it. Measuring a program means building it, at a cost proportional to its size, which a submission would repeat for every pattern it carries. The estimate tracks the real size closely (see estimate), and twice the bound leaves room for where it overstates, so a pattern within MaxProgramInsts is never refused by it.
const MaxProgramInsts = 2000
MaxProgramInsts is the most instructions a pattern's compiled program may hold.
RE2 matching is linear in the length of the line, but the constant is the size of the compiled program: Go bounds nested repetition at 1000 but not concatenation, so the 905-byte pattern strings.Repeat(".{0,999}", 113)+"x" compiles to about 226,000 instructions, which makes matching each line slow. Realistic patterns compile to 10 to 100 instructions; 2000 leaves room for a long alternation of literals.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile compiles p as regexp.Compile does, but first measures its program and returns a *TooLargeError, without building the matcher, when it exceeds MaxProgramInsts. A program whose estimate exceeds EstimateCeiling is refused without being built at all. A syntax error is returned exactly as regexp.Compile would return it.
Types ¶
type TooLargeError ¶
type TooLargeError struct {
// Insts is the size of the pattern's compiled program, or its estimate
// when Estimated is set.
Insts int
// Estimated reports that the program was too large to be worth building,
// so Insts is estimate's figure rather than a count.
Estimated bool
}
TooLargeError reports a pattern whose compiled program exceeds MaxProgramInsts.
func (*TooLargeError) Error ¶
func (e *TooLargeError) Error() string