Skip to content

Commit

Permalink
tests: Add Go 1.19 - deprecate Go 1.16 (#651)
Browse files Browse the repository at this point in the history
* tests: Add Go 1.19 - deprecate Go 1.16
  • Loading branch information
klauspost committed Aug 29, 2022
1 parent 5a3a4a9 commit 6d0019a
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 63 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/go.yml
Expand Up @@ -6,19 +6,19 @@ on:
pull_request:
branches: [ master ]


jobs:
build:
strategy:
matrix:
go-version: [1.16.x, 1.17.x,1.18.x]
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]
env:
CGO_ENABLED: 0
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -68,9 +68,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -89,7 +89,7 @@ jobs:

- name: goreleaser deprecation
run: curl -sfL https://git.io/goreleaser | VERSION=v1.9.2 sh -s -- check

- name: goreleaser snapshot
run: curl -sL https://git.io/goreleaser | VERSION=v1.9.2 sh -s -- --snapshot --skip-publish --rm-dist

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -18,10 +18,10 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x
-
name: install garble
run: go install mvdan.cc/garble@v0.7.0
run: go install mvdan.cc/garble@v0.7.1
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down
24 changes: 12 additions & 12 deletions flate/dict_decoder.go
Expand Up @@ -7,19 +7,19 @@ package flate
// dictDecoder implements the LZ77 sliding dictionary as used in decompression.
// LZ77 decompresses data through sequences of two forms of commands:
//
// * Literal insertions: Runs of one or more symbols are inserted into the data
// stream as is. This is accomplished through the writeByte method for a
// single symbol, or combinations of writeSlice/writeMark for multiple symbols.
// Any valid stream must start with a literal insertion if no preset dictionary
// is used.
// - Literal insertions: Runs of one or more symbols are inserted into the data
// stream as is. This is accomplished through the writeByte method for a
// single symbol, or combinations of writeSlice/writeMark for multiple symbols.
// Any valid stream must start with a literal insertion if no preset dictionary
// is used.
//
// * Backward copies: Runs of one or more symbols are copied from previously
// emitted data. Backward copies come as the tuple (dist, length) where dist
// determines how far back in the stream to copy from and length determines how
// many bytes to copy. Note that it is valid for the length to be greater than
// the distance. Since LZ77 uses forward copies, that situation is used to
// perform a form of run-length encoding on repeated runs of symbols.
// The writeCopy and tryWriteCopy are used to implement this command.
// - Backward copies: Runs of one or more symbols are copied from previously
// emitted data. Backward copies come as the tuple (dist, length) where dist
// determines how far back in the stream to copy from and length determines how
// many bytes to copy. Note that it is valid for the length to be greater than
// the distance. Since LZ77 uses forward copies, that situation is used to
// perform a form of run-length encoding on repeated runs of symbols.
// The writeCopy and tryWriteCopy are used to implement this command.
//
// For performance reasons, this implementation performs little to no sanity
// checks about the arguments. As such, the invariants documented for each
Expand Down
12 changes: 6 additions & 6 deletions flate/huffman_bit_writer.go
Expand Up @@ -265,9 +265,9 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) {
// Codes 0-15 are single byte codes. Codes 16-18 are followed by additional
// information. Code badCode is an end marker
//
// numLiterals The number of literals in literalEncoding
// numOffsets The number of offsets in offsetEncoding
// litenc, offenc The literal and offset encoder to use
// numLiterals The number of literals in literalEncoding
// numOffsets The number of offsets in offsetEncoding
// litenc, offenc The literal and offset encoder to use
func (w *huffmanBitWriter) generateCodegen(numLiterals int, numOffsets int, litEnc, offEnc *huffmanEncoder) {
for i := range w.codegenFreq {
w.codegenFreq[i] = 0
Expand Down Expand Up @@ -460,9 +460,9 @@ func (w *huffmanBitWriter) writeOutBits() {

// Write the header of a dynamic Huffman block to the output stream.
//
// numLiterals The number of literals specified in codegen
// numOffsets The number of offsets specified in codegen
// numCodegens The number of codegens used in codegen
// numLiterals The number of literals specified in codegen
// numOffsets The number of offsets specified in codegen
// numCodegens The number of codegens used in codegen
func (w *huffmanBitWriter) writeDynamicHeader(numLiterals int, numOffsets int, numCodegens int, isEof bool) {
if w.err != nil {
return
Expand Down
15 changes: 10 additions & 5 deletions flate/huffman_code.go
Expand Up @@ -168,13 +168,18 @@ func (h *huffmanEncoder) canReuseBits(freq []uint16) int {
// The cases of 0, 1, and 2 literals are handled by special case code.
//
// list An array of the literals with non-zero frequencies
// and their associated frequencies. The array is in order of increasing
// frequency, and has as its last element a special element with frequency
// MaxInt32
//
// and their associated frequencies. The array is in order of increasing
// frequency, and has as its last element a special element with frequency
// MaxInt32
//
// maxBits The maximum number of bits that should be used to encode any literal.
// Must be less than 16.
//
// Must be less than 16.
//
// return An integer array in which array[i] indicates the number of literals
// that should be encoded in i bits.
//
// that should be encoded in i bits.
func (h *huffmanEncoder) bitCounts(list []literalNode, maxBits int32) []int32 {
if maxBits >= maxBitsLimit {
panic("flate: maxBits too large")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
@@ -1,3 +1,3 @@
module github.com/klauspost/compress

go 1.16
go 1.17
4 changes: 3 additions & 1 deletion huff0/_generate/gen.go
@@ -1,6 +1,7 @@
package main

//go:generate go run gen.go -out ../decompress_amd64.s -pkg=huff0
//go:generate gofmt -w ../decompress_amd64.go

import (
"flag"
Expand Down Expand Up @@ -104,7 +105,8 @@ func (d decompress4x) generateProcedure(name string) {
}

// TODO [wmu]: I believe it's doable in avo, but can't figure out how to deal
// with arbitrary pointers to a given type
//
// with arbitrary pointers to a given type
const bitReader_in = 0
const bitReader_off = bitReader_in + 3*8 // {ptr, len, cap}
const bitReader_value = bitReader_off + 8
Expand Down
9 changes: 8 additions & 1 deletion huff0/_generate/go.mod
@@ -1,10 +1,17 @@
module github.com/klauspost/compress/s2/_generate

go 1.15
go 1.17

require (
github.com/klauspost/compress v1.15.1
github.com/mmcloughlin/avo v0.4.0
)

require (
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sys v0.0.0-20211030160813-b3129d9d1021 // indirect
golang.org/x/tools v0.1.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)

replace github.com/klauspost/compress => ../..
4 changes: 4 additions & 0 deletions huff0/decompress_amd64.go
Expand Up @@ -14,12 +14,14 @@ import (

// decompress4x_main_loop_x86 is an x86 assembler implementation
// of Decompress4X when tablelog > 8.
//
//go:noescape
func decompress4x_main_loop_amd64(ctx *decompress4xContext)

// decompress4x_8b_loop_x86 is an x86 assembler implementation
// of Decompress4X when tablelog <= 8 which decodes 4 entries
// per loop.
//
//go:noescape
func decompress4x_8b_main_loop_amd64(ctx *decompress4xContext)

Expand Down Expand Up @@ -145,11 +147,13 @@ func (d *Decoder) Decompress4X(dst, src []byte) ([]byte, error) {

// decompress4x_main_loop_x86 is an x86 assembler implementation
// of Decompress1X when tablelog > 8.
//
//go:noescape
func decompress1x_main_loop_amd64(ctx *decompress1xContext)

// decompress4x_main_loop_x86 is an x86 with BMI2 assembler implementation
// of Decompress1X when tablelog > 8.
//
//go:noescape
func decompress1x_main_loop_bmi2(ctx *decompress1xContext)

Expand Down
1 change: 0 additions & 1 deletion huff0/decompress_amd64.s
@@ -1,7 +1,6 @@
// Code generated by command: go run gen.go -out ../decompress_amd64.s -pkg=huff0. DO NOT EDIT.

//go:build amd64 && !appengine && !noasm && gc
// +build amd64,!appengine,!noasm,gc

// func decompress4x_main_loop_amd64(ctx *decompress4xContext)
TEXT ·decompress4x_main_loop_amd64(SB), $0-8
Expand Down
6 changes: 5 additions & 1 deletion internal/snapref/encode_other.go
Expand Up @@ -18,6 +18,7 @@ func load64(b []byte, i int) uint64 {
// emitLiteral writes a literal chunk and returns the number of bytes written.
//
// It assumes that:
//
// dst is long enough to hold the encoded bytes
// 1 <= len(lit) && len(lit) <= 65536
func emitLiteral(dst, lit []byte) int {
Expand All @@ -42,6 +43,7 @@ func emitLiteral(dst, lit []byte) int {
// emitCopy writes a copy chunk and returns the number of bytes written.
//
// It assumes that:
//
// dst is long enough to hold the encoded bytes
// 1 <= offset && offset <= 65535
// 4 <= length && length <= 65535
Expand Down Expand Up @@ -89,6 +91,7 @@ func emitCopy(dst []byte, offset, length int) int {
// src[i:i+k-j] and src[j:k] have the same contents.
//
// It assumes that:
//
// 0 <= i && i < j && j <= len(src)
func extendMatch(src []byte, i, j int) int {
for ; j < len(src) && src[i] == src[j]; i, j = i+1, j+1 {
Expand All @@ -105,8 +108,9 @@ func hash(u, shift uint32) uint32 {
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlock(dst, src []byte) (d int) {
// Initialize the hash table. Its size ranges from 1<<8 to 1<<14 inclusive.
// The table element type is uint16, as s < sLimit and sLimit < len(src)
Expand Down
9 changes: 8 additions & 1 deletion s2/_generate/go.mod
@@ -1,8 +1,15 @@
module github.com/klauspost/compress/s2/_generate

go 1.15
go 1.17

require (
github.com/klauspost/asmfmt v1.3.1
github.com/mmcloughlin/avo v0.4.0
)

require (
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sys v0.0.0-20211030160813-b3129d9d1021 // indirect
golang.org/x/tools v0.1.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
1 change: 0 additions & 1 deletion s2/cmd/internal/readahead/reader.go
Expand Up @@ -10,7 +10,6 @@
// is likely to speed up copies.
//
// Package home: https://github.com/klauspost/readahead
//
package readahead

import (
Expand Down
3 changes: 2 additions & 1 deletion s2/encode_all.go
Expand Up @@ -58,8 +58,9 @@ func encodeGo(dst, src []byte) []byte {
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockGo(dst, src []byte) (d int) {
// Initialize the hash table.
const (
Expand Down
12 changes: 8 additions & 4 deletions s2/encode_amd64.go
Expand Up @@ -8,8 +8,9 @@ package s2
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlock(dst, src []byte) (d int) {
const (
// Use 12 bit table when less than...
Expand Down Expand Up @@ -43,8 +44,9 @@ func encodeBlock(dst, src []byte) (d int) {
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockBetter(dst, src []byte) (d int) {
const (
// Use 12 bit table when less than...
Expand Down Expand Up @@ -78,8 +80,9 @@ func encodeBlockBetter(dst, src []byte) (d int) {
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockSnappy(dst, src []byte) (d int) {
const (
// Use 12 bit table when less than...
Expand Down Expand Up @@ -112,8 +115,9 @@ func encodeBlockSnappy(dst, src []byte) (d int) {
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockBetterSnappy(dst, src []byte) (d int) {
const (
// Use 12 bit table when less than...
Expand Down
8 changes: 6 additions & 2 deletions s2/encode_best.go
Expand Up @@ -15,8 +15,9 @@ import (
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockBest(dst, src []byte) (d int) {
// Initialize the hash tables.
const (
Expand Down Expand Up @@ -288,8 +289,9 @@ emitRemainder:
// been written.
//
// It also assumes that:
//
// len(dst) >= MaxEncodedLen(len(src)) &&
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
// minNonLiteralBlockSize <= len(src) && len(src) <= maxBlockSize
func encodeBlockBestSnappy(dst, src []byte) (d int) {
// Initialize the hash tables.
const (
Expand Down Expand Up @@ -546,6 +548,7 @@ emitRemainder:
// emitCopySize returns the size to encode the offset+length
//
// It assumes that:
//
// 1 <= offset && offset <= math.MaxUint32
// 4 <= length && length <= 1 << 24
func emitCopySize(offset, length int) int {
Expand Down Expand Up @@ -584,6 +587,7 @@ func emitCopySize(offset, length int) int {
// emitCopyNoRepeatSize returns the size to encode the offset+length
//
// It assumes that:
//
// 1 <= offset && offset <= math.MaxUint32
// 4 <= length && length <= 1 << 24
func emitCopyNoRepeatSize(offset, length int) int {
Expand Down

0 comments on commit 6d0019a

Please sign in to comment.