logpattern

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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.

View Source
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

func Compile(p string) (*regexp.Regexp, error)

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.

func Estimate

func Estimate(p string) (int, error)

Estimate parses p and estimates the size of its compiled program without building it, at a cost linear in len(p). 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL