Documentation
¶
Overview ¶
Package codec combines encoders and decoders for chunk storage and workers, and adapts FPGA scheduling and CPU fallback to the same interface.
Index ¶
- Constants
- Variables
- type Codec
- type FPGA
- type FPGAGroup
- type Fallback
- type FileDecoder
- type FileEncoder
- type FileResult
- type FileResultEncoder
- type FirmwareIdentity
- type Gzip
- type LZ4
- type MinLZ
- type MultiFPGA
- type MultiFPGAOptions
- type Prediction
- type PredictionMetrics
- type PredictionOptions
- type Predictor
- type Raw
- type Stats
- type WorkerStatus
- type Zstd
Constants ¶
const MultiAlgorithmSDKAvailable = false
The published v0.0.2 SDK has no generic transport. Keep ordinary builds reproducible against that release; local SDK workers enable fpga_multialgo.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Codec ¶
Codec compresses one bounded read-only raw chunk and decodes one stored chunk. The chunk boundary is deliberate: it gives FUSE random reads a bounded decode cost and lets the storage layer deduplicate by raw content hash.
type FPGA ¶
type FPGA struct {
Hardware fpgagzip.Hardware
// OpenHardware optionally supplies a fresh XDMA handle for each chunk. The
// current fpga-gzip pipeline closes its H2C/C2H streams when one bounded
// transaction ends, so a reusable FUSE mount must open a new handle before
// the next chunk. Hardware remains supported for callers that intentionally
// own a one-shot or compatible reusable implementation.
OpenHardware func() (fpgagzip.Hardware, error)
Options fpgagzip.Options
Report func(fpgagzip.Progress)
// contains filtered or unexported fields
}
FPGA uses the fpga-gzip SDK for one complete chunk. The shell needs the chunk length before H2C starts, which is naturally available at this layer.
func (*FPGA) Health ¶
Health reports the first error that opened the FPGA circuit breaker. A nil error means the codec is currently allowed to submit work.
func (*FPGA) ResetHealth ¶
func (f *FPGA) ResetHealth()
ResetHealth re-enables FPGA submissions after the device has been reprogrammed or its XDMA streams have been repaired. It is safe to call while other goroutines are waiting in Encode.
type FPGAGroup ¶
type FPGAGroup struct {
// contains filtered or unexported fields
}
FPGAGroup schedules whole chunks on independent gzip cores. Each FPGA keeps its own transaction lock and circuit breaker; failed cores leave the group while healthy cores continue. A group must never share a stream/control bank.
func NewFPGAGroup ¶
type Fallback ¶
Fallback retries into a private buffer so a failed primary codec cannot leave partial bytes in the caller's destination.
type FileDecoder ¶
type FileDecoder interface {
DecodeFile(ctx context.Context, source *os.File, rawSize int64, dst io.Writer) error
}
FileDecoder optionally decodes an immutable read-only file. The source's ownership and offset remain with the caller; rawSize is the exact expected output length. No bytes may reach dst before a complete validated result. ErrUnavailable requests the ordinary Decode path without consuming src/dst.
type FileEncoder ¶
type FileEncoder interface {
EncodeFile(ctx context.Context, source *os.File, dst io.Writer) (Stats, error)
}
FileEncoder optionally encodes an immutable read-only file without sending its entire input through an IPC byte stream. Offset and ownership are kept. A raw result may write no bytes and return Name="raw", RawSize=StoredSize= file size; callers retain the original bytes and must use that representation.
type FileResult ¶
func (*FileResult) Close ¶
func (r *FileResult) Close() error
Close releases the owned temporary file and its name. Backend hard links survive this cleanup. It is safe to close a result more than once.
type FileResultEncoder ¶
type FileResultEncoder interface {
EncodeFileResult(ctx context.Context, source *os.File) (*FileResult, error)
}
FileResultEncoder returns a private immutable encoded file. The caller closes the result after its storage consumer completes. A raw result has no File and refers to the original input. ErrUnavailable requests the normal FileEncoder/Codec path without treating capability absence as an error.
type FirmwareIdentity ¶
type Gzip ¶
Gzip combines the gzip encoder and decoder for chunk-store and worker use. Encoder state stays in encoder.Gzip, including Level and its bounded pool.
type MinLZ ¶
MinLZ combines the MinLZ encoder and decoder. Do not copy after first use.
type MultiFPGA ¶
type MultiFPGA struct {
// contains filtered or unexported fields
}
MultiFPGA follows versioned images without binding a mount's decoder to the current image. A switch or hardware failure falls back to the same CPU format; auto uses the last observed format (gzip before the first successful probe). Failed cores are disabled for that build and re-enabled by a new image ID.
func NewMultiFPGA ¶
func NewMultiFPGA(options MultiFPGAOptions) (*MultiFPGA, error)
func (*MultiFPGA) WithAlgorithm ¶
WithAlgorithm selects a format while retaining the same core leases and health state. All aliases for one card in a worker must share this state: fpga-auto and fpga-lz4 can otherwise target the same DMA core concurrently.
type MultiFPGAOptions ¶
type Prediction ¶
type Prediction struct {
Checked bool
Skip bool
SampleBytes int64
Nanos int64
Ratio float64
Entropy float64
}
Prediction describes one chunk, never a permanent classification of a file. A false positive only forgoes compression; the original bytes are retained.
type PredictionMetrics ¶
type PredictionMetrics struct {
Mode string `json:"mode"`
Checks int64 `json:"checks"`
RawBytes int64 `json:"raw_bytes"`
SampleBytes int64 `json:"sample_bytes"`
Nanos int64 `json:"nanos"`
SkippedChunks int64 `json:"skipped_chunks"`
SkippedBytes int64 `json:"skipped_bytes"`
Errors int64 `json:"errors"`
LastRatio float64 `json:"last_ratio,omitempty"`
LastEntropy float64 `json:"last_entropy,omitempty"`
}
PredictionMetrics counts successful RPCs observed by this mount, including across worker replacements. It does not include other mounts sharing a worker.
type PredictionOptions ¶
type PredictionOptions struct {
Mode string `json:"mode"`
SampleBytes int `json:"sample_bytes"`
DeflateRatio float64 `json:"deflate_ratio"`
EntropyThreshold float64 `json:"entropy_threshold"`
}
PredictionOptions controls a bounded content precheck. Ratios are sample output/input: 0.94 requires an estimated saving greater than six percent.
func DefaultPredictionOptions ¶
func DefaultPredictionOptions() PredictionOptions
type Predictor ¶
type Predictor struct {
// contains filtered or unexported fields
}
Predictor uses only Go code and reuses sample/Deflate buffers between chunks. A nil predictor disables the precheck.
func NewPredictor ¶
func NewPredictor(options PredictionOptions) (*Predictor, error)
func (*Predictor) Options ¶
func (p *Predictor) Options() PredictionOptions
type Raw ¶
Raw combines the byte-for-byte encoder and decoder for uncompressed chunks.
type WorkerStatus ¶
type WorkerStatus struct {
PID int `json:"pid"`
Socket string `json:"socket"`
Version string `json:"version"`
Protocol int `json:"protocol"`
Retries int64 `json:"retries"`
LastCodec string `json:"last_codec,omitempty"`
CPUFallbacks int64 `json:"cpu_fallbacks"`
Prediction *PredictionMetrics `json:"prediction,omitempty"`
FileRequests int64 `json:"file_requests"`
FileBytes int64 `json:"file_bytes"`
FileFallbacks int64 `json:"file_fallbacks"`
FileOutputRequests int64 `json:"file_output_requests"`
FileOutputBytes int64 `json:"file_output_bytes"`
FileDecodeRequests int64 `json:"file_decode_requests"`
FileDecodeBytes int64 `json:"file_decode_bytes"`
}
WorkerStatus describes the process serving a remote codec. It is diagnostic state only; chunk refs retain their encoding names independently of workers.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package decoder implements pure Go chunk decoders independently of storage, worker protocols, and the corresponding encoders.
|
Package decoder implements pure Go chunk decoders independently of storage, worker protocols, and the corresponding encoders. |
|
Package encoder implements pure Go chunk encoders independently of storage, worker protocols, and the corresponding decoders.
|
Package encoder implements pure Go chunk encoders independently of storage, worker protocols, and the corresponding decoders. |
|
Package worker runs chunk codecs in an independently updatable process.
|
Package worker runs chunk codecs in an independently updatable process. |