Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: klauspost/compress
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.17.8
Choose a base ref
...
head repository: klauspost/compress
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.17.9
Choose a head ref
  • 7 commits
  • 25 files changed
  • 3 contributors

Commits on Apr 12, 2024

  1. s2: Reduce ReadFrom temporary allocations (#949)

    Only functional change is to add minimum 1MB between entries (which was enforced when saving anyway).
    
    Probably close to a worst case (and probably noisy), but overall looks good:
    
    ```
    benchmark                                                old ns/op     new ns/op     delta
    BenchmarkReadFromRandom/default-c1-4k-win-32             4157177       2604339       -37.35%
    BenchmarkReadFromRandom/default-c2-32                    788147        679660        -13.76%
    BenchmarkReadFromRandom/best-c2-4k-win-32                215513740     207505150     -3.72%
    BenchmarkReadFromRandom/default-c2-4k-win-32             8712437       8354241       -4.11%
    BenchmarkReadFromRandom/better-c1-32                     2861139       1862028       -34.92%
    BenchmarkReadFromRandom/none-c1-32                       2331903       1430642       -38.65%
    BenchmarkReadFromRandom/best-c1-4k-win-32                278422200     267546000     -3.91%
    BenchmarkReadFromRandom/none-c2-pad-min-32               772803        672716        -12.95%
    BenchmarkReadFromRandom/best-c2-pad-min-32               5460325       5095500       -6.68%
    BenchmarkReadFromRandom/none-c2-4M-win-pad-min-32        1121548       651889        -41.88%
    BenchmarkReadFromRandom/better-c1-4M-win-32              3135030       1813419       -42.16%
    BenchmarkReadFromRandom/none-c2-4k-win-32                4854943       4876356       +0.44%
    BenchmarkReadFromRandom/default-c1-4M-win-pad-min-32     2526561       1457227       -42.32%
    BenchmarkReadFromRandom/better-c2-4k-win-32              11868536      11714897      -1.29%
    BenchmarkReadFromRandom/best-c1-4M-win-pad-min-32        15489805      11971380      -22.71%
    BenchmarkReadFromRandom/none-c1-pad-min-32               2416111       1421856       -41.15%
    BenchmarkReadFromRandom/none-c2-4M-win-32                1101574       668233        -39.34%
    BenchmarkReadFromRandom/default-c2-4M-win-32             1125451       669567        -40.51%
    BenchmarkReadFromRandom/better-c1-pad-min-32             3601453       1885376       -47.65%
    BenchmarkReadFromRandom/best-c1-4M-win-32                15391320      13574288      -11.81%
    BenchmarkReadFromRandom/default-c1-32                    2910080       1468122       -49.55%
    BenchmarkReadFromRandom/better-c1-4k-win-pad-min-32      8912611       6817072       -23.51%
    BenchmarkReadFromRandom/none-c2-32                       772356        670370        -13.20%
    BenchmarkReadFromRandom/default-c1-4M-win-32             2588579       1450875       -43.95%
    BenchmarkReadFromRandom/default-c2-4k-win-pad-min-32     8659309       8312865       -4.00%
    BenchmarkReadFromRandom/better-c2-4k-win-pad-min-32      11869082      11664866      -1.72%
    BenchmarkReadFromRandom/better-c1-4k-win-32              8838607       6716940       -24.00%
    BenchmarkReadFromRandom/better-c2-4M-win-32              1191929       835844        -29.87%
    BenchmarkReadFromRandom/best-c1-32                       14526139      12391446      -14.70%
    BenchmarkReadFromRandom/best-c2-4k-win-pad-min-32        195756200     202187120     +3.29%
    BenchmarkReadFromRandom/none-c1-4k-win-pad-min-32        2738898       833709        -69.56%
    BenchmarkReadFromRandom/better-c2-pad-min-32             1004892       884365        -11.99%
    BenchmarkReadFromRandom/none-c2-4k-win-pad-min-32        4823234       4856289       +0.69%
    BenchmarkReadFromRandom/best-c2-4M-win-32                5898056       5408690       -8.30%
    BenchmarkReadFromRandom/best-c2-4M-win-pad-min-32        5669392       5523631       -2.57%
    BenchmarkReadFromRandom/default-c1-4k-win-pad-min-32     4570917       2567954       -43.82%
    BenchmarkReadFromRandom/better-c2-4M-win-pad-min-32      1231687       847167        -31.22%
    BenchmarkReadFromRandom/default-c2-4M-win-pad-min-32     1096798       678716        -38.12%
    BenchmarkReadFromRandom/none-c1-4k-win-32                3316746       843895        -74.56%
    BenchmarkReadFromRandom/none-c1-4M-win-pad-min-32        2640620       1429627       -45.86%
    BenchmarkReadFromRandom/best-c1-4k-win-pad-min-32        278722100     273288575     -1.95%
    BenchmarkReadFromRandom/best-c1-pad-min-32               14499535      12347208      -14.84%
    BenchmarkReadFromRandom/none-c1-4M-win-32                2652251       1453083       -45.21%
    BenchmarkReadFromRandom/default-c1-pad-min-32            2791364       1474998       -47.16%
    BenchmarkReadFromRandom/default-c2-pad-min-32            824566        707436        -14.21%
    BenchmarkReadFromRandom/best-c2-32                       5362292       5104630       -4.81%
    BenchmarkReadFromRandom/better-c1-4M-win-pad-min-32      3919478       1822777       -53.49%
    BenchmarkReadFromRandom/better-c2-32                     969154        880528        -9.14%
    
    benchmark                                                old MB/s     new MB/s     speedup
    BenchmarkReadFromRandom/default-c1-4k-win-32             2017.86      3221.01      1.60x
    BenchmarkReadFromRandom/default-c2-32                    10643.46     12342.35     1.16x
    BenchmarkReadFromRandom/best-c2-4k-win-32                38.92        40.43        1.04x
    BenchmarkReadFromRandom/default-c2-4k-win-32             962.83       1004.11      1.04x
    BenchmarkReadFromRandom/better-c1-32                     2931.91      4505.09      1.54x
    BenchmarkReadFromRandom/none-c1-32                       3597.32      5863.53      1.63x
    BenchmarkReadFromRandom/best-c1-4k-win-32                30.13        31.35        1.04x
    BenchmarkReadFromRandom/none-c2-pad-min-32               10854.78     12469.75     1.15x
    BenchmarkReadFromRandom/best-c2-pad-min-32               1536.28      1646.28      1.07x
    BenchmarkReadFromRandom/none-c2-4M-win-pad-min-32        7479.49      12868.15     1.72x
    BenchmarkReadFromRandom/better-c1-4M-win-32              2675.77      4625.85      1.73x
    BenchmarkReadFromRandom/none-c2-4k-win-32                1727.85      1720.26      1.00x
    BenchmarkReadFromRandom/default-c1-4M-win-pad-min-32     3320.17      5756.55      1.73x
    BenchmarkReadFromRandom/better-c2-4k-win-32              706.79       716.06       1.01x
    BenchmarkReadFromRandom/best-c1-4M-win-pad-min-32        541.56       700.72       1.29x
    BenchmarkReadFromRandom/none-c1-pad-min-32               3471.95      5899.76      1.70x
    BenchmarkReadFromRandom/none-c2-4M-win-32                7615.11      12553.42     1.65x
    BenchmarkReadFromRandom/default-c2-4M-win-32             7453.55      12528.41     1.68x
    BenchmarkReadFromRandom/better-c1-pad-min-32             2329.23      4449.30      1.91x
    BenchmarkReadFromRandom/best-c1-4M-win-32                545.02       617.98       1.13x
    BenchmarkReadFromRandom/default-c1-32                    2882.60      5713.84      1.98x
    BenchmarkReadFromRandom/better-c1-4k-win-pad-min-32      941.21       1230.53      1.31x
    BenchmarkReadFromRandom/none-c2-32                       10861.07     12513.39     1.15x
    BenchmarkReadFromRandom/default-c1-4M-win-32             3240.62      5781.76      1.78x
    BenchmarkReadFromRandom/default-c2-4k-win-pad-min-32     968.74       1009.11      1.04x
    BenchmarkReadFromRandom/better-c2-4k-win-pad-min-32      706.76       719.13       1.02x
    BenchmarkReadFromRandom/better-c1-4k-win-32              949.09       1248.87      1.32x
    BenchmarkReadFromRandom/better-c2-4M-win-32              7037.84      10036.09     1.43x
    BenchmarkReadFromRandom/best-c1-32                       577.48       676.97       1.17x
    BenchmarkReadFromRandom/best-c2-4k-win-pad-min-32        42.85        41.49        0.97x
    BenchmarkReadFromRandom/none-c1-4k-win-pad-min-32        3062.77      10061.79     3.29x
    BenchmarkReadFromRandom/better-c2-pad-min-32             8347.77      9485.46      1.14x
    BenchmarkReadFromRandom/none-c2-4k-win-pad-min-32        1739.21      1727.37      0.99x
    BenchmarkReadFromRandom/best-c2-4M-win-32                1422.27      1550.95      1.09x
    BenchmarkReadFromRandom/best-c2-4M-win-pad-min-32        1479.63      1518.68      1.03x
    BenchmarkReadFromRandom/default-c1-4k-win-pad-min-32     1835.21      3266.65      1.78x
    BenchmarkReadFromRandom/better-c2-4M-win-pad-min-32      6810.66      9901.96      1.45x
    BenchmarkReadFromRandom/default-c2-4M-win-pad-min-32     7648.27      12359.53     1.62x
    BenchmarkReadFromRandom/none-c1-4k-win-32                2529.17      9940.34      3.93x
    BenchmarkReadFromRandom/none-c1-4M-win-pad-min-32        3176.76      5867.69      1.85x
    BenchmarkReadFromRandom/best-c1-4k-win-pad-min-32        30.10        30.70        1.02x
    BenchmarkReadFromRandom/best-c1-pad-min-32               578.54       679.39       1.17x
    BenchmarkReadFromRandom/none-c1-4M-win-32                3162.83      5772.97      1.83x
    BenchmarkReadFromRandom/default-c1-pad-min-32            3005.20      5687.20      1.89x
    BenchmarkReadFromRandom/default-c2-pad-min-32            10173.36     11857.76     1.17x
    BenchmarkReadFromRandom/best-c2-32                       1564.37      1643.33      1.05x
    BenchmarkReadFromRandom/better-c1-4M-win-pad-min-32      2140.24      4602.10      2.15x
    BenchmarkReadFromRandom/better-c2-32                     8655.60      9526.79      1.10x
    
    benchmark                                                old allocs     new allocs     delta
    BenchmarkReadFromRandom/default-c1-4k-win-32             8196           6145           -25.02%
    BenchmarkReadFromRandom/default-c2-32                    59             57             -3.39%
    BenchmarkReadFromRandom/best-c2-4k-win-32                14356          14347          -0.06%
    BenchmarkReadFromRandom/default-c2-4k-win-32             14344          14341          -0.02%
    BenchmarkReadFromRandom/better-c1-32                     35             25             -28.57%
    BenchmarkReadFromRandom/none-c1-32                       35             25             -28.57%
    BenchmarkReadFromRandom/best-c1-4k-win-32                8196           6147           -25.00%
    BenchmarkReadFromRandom/none-c2-pad-min-32               59             57             -3.39%
    BenchmarkReadFromRandom/best-c2-pad-min-32               58             57             -1.72%
    BenchmarkReadFromRandom/none-c2-4M-win-pad-min-32        18             15             -16.67%
    BenchmarkReadFromRandom/better-c1-4M-win-32              11             7              -36.36%
    BenchmarkReadFromRandom/none-c2-4k-win-32                14345          14343          -0.01%
    BenchmarkReadFromRandom/default-c1-4M-win-pad-min-32     11             7              -36.36%
    BenchmarkReadFromRandom/better-c2-4k-win-32              14343          14343          +0.00%
    BenchmarkReadFromRandom/best-c1-4M-win-pad-min-32        11             7              -36.36%
    BenchmarkReadFromRandom/none-c1-pad-min-32               35             25             -28.57%
    BenchmarkReadFromRandom/none-c2-4M-win-32                18             15             -16.67%
    BenchmarkReadFromRandom/default-c2-4M-win-32             18             15             -16.67%
    BenchmarkReadFromRandom/better-c1-pad-min-32             35             25             -28.57%
    BenchmarkReadFromRandom/best-c1-4M-win-32                11             7              -36.36%
    BenchmarkReadFromRandom/default-c1-32                    35             25             -28.57%
    BenchmarkReadFromRandom/better-c1-4k-win-pad-min-32      8196           6145           -25.02%
    BenchmarkReadFromRandom/none-c2-32                       59             57             -3.39%
    BenchmarkReadFromRandom/default-c1-4M-win-32             11             7              -36.36%
    BenchmarkReadFromRandom/default-c2-4k-win-pad-min-32     14345          14343          -0.01%
    BenchmarkReadFromRandom/better-c2-4k-win-pad-min-32      14344          14346          +0.01%
    BenchmarkReadFromRandom/better-c1-4k-win-32              8196           6145           -25.02%
    BenchmarkReadFromRandom/better-c2-4M-win-32              18             15             -16.67%
    BenchmarkReadFromRandom/best-c1-32                       35             25             -28.57%
    BenchmarkReadFromRandom/best-c2-4k-win-pad-min-32        14347          14343          -0.03%
    BenchmarkReadFromRandom/none-c1-4k-win-pad-min-32        8196           6145           -25.02%
    BenchmarkReadFromRandom/better-c2-pad-min-32             59             57             -3.39%
    BenchmarkReadFromRandom/none-c2-4k-win-pad-min-32        14345          14343          -0.01%
    BenchmarkReadFromRandom/best-c2-4M-win-32                17             15             -11.76%
    BenchmarkReadFromRandom/best-c2-4M-win-pad-min-32        17             15             -11.76%
    BenchmarkReadFromRandom/default-c1-4k-win-pad-min-32     8196           6145           -25.02%
    BenchmarkReadFromRandom/better-c2-4M-win-pad-min-32      18             15             -16.67%
    BenchmarkReadFromRandom/default-c2-4M-win-pad-min-32     18             15             -16.67%
    BenchmarkReadFromRandom/none-c1-4k-win-32                8196           6145           -25.02%
    BenchmarkReadFromRandom/none-c1-4M-win-pad-min-32        11             7              -36.36%
    BenchmarkReadFromRandom/best-c1-4k-win-pad-min-32        8196           6148           -24.99%
    BenchmarkReadFromRandom/best-c1-pad-min-32               35             25             -28.57%
    BenchmarkReadFromRandom/none-c1-4M-win-32                11             7              -36.36%
    BenchmarkReadFromRandom/default-c1-pad-min-32            35             25             -28.57%
    BenchmarkReadFromRandom/default-c2-pad-min-32            59             57             -3.39%
    BenchmarkReadFromRandom/best-c2-32                       58             57             -1.72%
    BenchmarkReadFromRandom/better-c1-4M-win-pad-min-32      11             7              -36.36%
    BenchmarkReadFromRandom/better-c2-32                     59             57             -3.39%
    
    benchmark                                                old bytes     new bytes     delta
    BenchmarkReadFromRandom/default-c1-4k-win-32             10119115      148076        -98.54%
    BenchmarkReadFromRandom/default-c2-32                    1454676       4899          -99.66%
    BenchmarkReadFromRandom/best-c2-4k-win-32                631225        625546        -0.90%
    BenchmarkReadFromRandom/default-c2-4k-win-32             630732        625959        -0.76%
    BenchmarkReadFromRandom/better-c1-32                     9514904       2797          -99.97%
    BenchmarkReadFromRandom/none-c1-32                       9516943       2440          -99.97%
    BenchmarkReadFromRandom/best-c1-4k-win-32                10119906      150564        -98.51%
    BenchmarkReadFromRandom/none-c2-pad-min-32               1500410       6171          -99.59%
    BenchmarkReadFromRandom/best-c2-pad-min-32               1173566       25894         -97.79%
    BenchmarkReadFromRandom/none-c2-4M-win-pad-min-32        6423795       5415          -99.92%
    BenchmarkReadFromRandom/better-c1-4M-win-32              12610237      6582          -99.95%
    BenchmarkReadFromRandom/none-c2-4k-win-32                632307        626486        -0.92%
    BenchmarkReadFromRandom/default-c1-4M-win-pad-min-32     12610296      5410          -99.96%
    BenchmarkReadFromRandom/better-c2-4k-win-32              630839        626113        -0.75%
    BenchmarkReadFromRandom/best-c1-4M-win-pad-min-32        12610476      49191         -99.61%
    BenchmarkReadFromRandom/none-c1-pad-min-32               9514740       2479          -99.97%
    BenchmarkReadFromRandom/none-c2-4M-win-32                6545265       13213         -99.80%
    BenchmarkReadFromRandom/default-c2-4M-win-32             6481737       11355         -99.82%
    BenchmarkReadFromRandom/better-c1-pad-min-32             9514861       2763          -99.97%
    BenchmarkReadFromRandom/best-c1-4M-win-32                12610426      57138         -99.55%
    BenchmarkReadFromRandom/default-c1-32                    9517523       2540          -99.97%
    BenchmarkReadFromRandom/better-c1-4k-win-pad-min-32      10118890      148124        -98.54%
    BenchmarkReadFromRandom/none-c2-32                       1530722       5478          -99.64%
    BenchmarkReadFromRandom/default-c1-4M-win-32             12610210      5454          -99.96%
    BenchmarkReadFromRandom/default-c2-4k-win-pad-min-32     630895        626457        -0.70%
    BenchmarkReadFromRandom/better-c2-4k-win-pad-min-32      630794        626720        -0.65%
    BenchmarkReadFromRandom/better-c1-4k-win-32              10118922      148161        -98.54%
    BenchmarkReadFromRandom/better-c2-4M-win-32              6598822       13798         -99.79%
    BenchmarkReadFromRandom/best-c1-32                       9516160       12594         -99.87%
    BenchmarkReadFromRandom/best-c2-4k-win-pad-min-32        631572        628459        -0.49%
    BenchmarkReadFromRandom/none-c1-4k-win-pad-min-32        10118789      148120        -98.54%
    BenchmarkReadFromRandom/better-c2-pad-min-32             1489742       6937          -99.53%
    BenchmarkReadFromRandom/none-c2-4k-win-pad-min-32        631988        626774        -0.83%
    BenchmarkReadFromRandom/best-c2-4M-win-32                4734174       79313         -98.32%
    BenchmarkReadFromRandom/best-c2-4M-win-pad-min-32        4859587       78584         -98.38%
    BenchmarkReadFromRandom/default-c1-4k-win-pad-min-32     10118817      148094        -98.54%
    BenchmarkReadFromRandom/better-c2-4M-win-pad-min-32      6497809       13671         -99.79%
    BenchmarkReadFromRandom/default-c2-4M-win-pad-min-32     6482743       13380         -99.79%
    BenchmarkReadFromRandom/none-c1-4k-win-32                10118669      148214        -98.54%
    BenchmarkReadFromRandom/none-c1-4M-win-pad-min-32        12610006      5378          -99.96%
    BenchmarkReadFromRandom/best-c1-4k-win-pad-min-32        10119906      150652        -98.51%
    BenchmarkReadFromRandom/best-c1-pad-min-32               9515185       12174         -99.87%
    BenchmarkReadFromRandom/none-c1-4M-win-32                12610010      5304          -99.96%
    BenchmarkReadFromRandom/default-c1-pad-min-32            9514765       2516          -99.97%
    BenchmarkReadFromRandom/default-c2-pad-min-32            1524283       4986          -99.67%
    BenchmarkReadFromRandom/best-c2-32                       1238837       3118          -99.75%
    BenchmarkReadFromRandom/better-c1-4M-win-pad-min-32      12636434      7013          -99.94%
    BenchmarkReadFromRandom/better-c2-32                     1486984       6114          -99.59%
    ```
    
    `magicChunkSnappyBytes` and `magicChunkBytes` not included.
    klauspost authored Apr 12, 2024
    Copy the full SHA
    8bd3916 View commit details

Commits on May 30, 2024

  1. Fix arm64 vet issues (#964)

    klauspost authored May 30, 2024
    Copy the full SHA
    3a0faf3 View commit details
  2. flate, zstd: Shave some bytes off amd64 matchLen (#963)

    XORQ sets the flags, so there is no need for TESTQ.
    
    Use a 32-bit shift after TZCNT/BSF.
    greatroar authored May 30, 2024
    Copy the full SHA
    5f7dd25 View commit details

Commits on Jun 1, 2024

  1. build(deps): bump the github-actions group across 1 directory with 2 …

    …updates (#967)
    
    Bumps the github-actions group with 2 updates in the / directory: [github/codeql-action](https://github.com/github/codeql-action) and [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action).
    
    
    Updates `github/codeql-action` from 3.24.9 to 3.25.7
    - [Release notes](https://github.com/github/codeql-action/releases)
    - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
    - [Commits](github/codeql-action@1b1aada...f079b84)
    
    Updates `goreleaser/goreleaser-action` from 5.0.0 to 5.1.0
    - [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
    - [Commits](goreleaser/goreleaser-action@7ec5c2b...5742e2a)
    
    ---
    updated-dependencies:
    - dependency-name: github/codeql-action
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: github-actions
    - dependency-name: goreleaser/goreleaser-action
      dependency-type: direct:production
      update-type: version-update:semver-minor
      dependency-group: github-actions
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jun 1, 2024
    Copy the full SHA
    d9f6f55 View commit details

Commits on Jun 5, 2024

  1. zip: Upgrade to 1.22.4 upstream (#970)

    * Upgrade zip to 1.22.4 upstream
    
    This removes `CreateHeaderRaw`
    klauspost authored Jun 5, 2024
    Copy the full SHA
    8411e1d View commit details

Commits on Jun 12, 2024

  1. zstd: BuildDict fails with RLE table (#951)

    * zstd: BuildDict fails with RLE table
    
    We cannot build a useable table if RLE. Add a fake entry to generate valid tables.
    
    * Prevent offsets longer than dict to be selected.
    klauspost authored Jun 12, 2024
    Copy the full SHA
    0396178 View commit details
  2. Upgrade zlib to upstream (#971)

    Mostly cosmetic changes.
    klauspost authored Jun 12, 2024
    Copy the full SHA
    7ae2138 View commit details
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -71,4 +71,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ jobs:
go-version: 1.22.x
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0
with:
version: 1.24.x
args: release --rm-dist
10 changes: 4 additions & 6 deletions flate/matchlen_amd64.s
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
#include "textflag.h"

// func matchLen(a []byte, b []byte) int
// Requires: BMI
TEXT ·matchLen(SB), NOSPLIT, $0-56
MOVQ a_base+0(FP), AX
MOVQ b_base+24(FP), CX
@@ -17,17 +16,16 @@ TEXT ·matchLen(SB), NOSPLIT, $0-56
JB matchlen_match4_standalone

matchlen_loopback_standalone:
MOVQ (AX)(SI*1), BX
XORQ (CX)(SI*1), BX
TESTQ BX, BX
JZ matchlen_loop_standalone
MOVQ (AX)(SI*1), BX
XORQ (CX)(SI*1), BX
JZ matchlen_loop_standalone

#ifdef GOAMD64_v3
TZCNTQ BX, BX
#else
BSFQ BX, BX
#endif
SARQ $0x03, BX
SHRL $0x03, BX
LEAL (SI)(BX*1), SI
JMP gen_match_len_end

44 changes: 44 additions & 0 deletions internal/godebug/godebug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package godebug makes the simplified settings in the $GODEBUG environment variable
// available to packages.
// Needed since internal/godebug is not available here.
package godebug

import "os"

func Get(key string) string {
s := os.Getenv("GODEBUG")
if s == "" {
return ""
}
// Scan the string backward so that later settings are used
// and earlier settings are ignored.
// Note that a forward scan would cause cached values
// to temporarily use the ignored value before being
// updated to the "correct" one.
end := len(s)
eq := -1
for i := end - 1; i >= -1; i-- {
if i == -1 || s[i] == ',' {
if eq >= 0 {
name, arg := s[i+1:eq], s[eq+1:end]
if name == key {
for j := 0; j < len(arg); j++ {
if arg[j] == '#' {
return arg[:j]
}
}
return arg
}
}
eq = -1
end = i
} else if s[i] == '=' {
eq = i
}
}
return ""
}
2 changes: 1 addition & 1 deletion s2/decode_arm64.s
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@
//
// The d variable is implicitly R_DST - R_DBASE, and len(dst)-d is R_DEND - R_DST.
// The s variable is implicitly R_SRC - R_SBASE, and len(src)-s is R_SEND - R_SRC.
TEXT ·s2Decode(SB), NOSPLIT, $56-64
TEXT ·s2Decode(SB), NOSPLIT, $56-56
// Initialize R_SRC, R_DST and R_DBASE-R_SEND.
MOVD dst_base+0(FP), R_DBASE
MOVD dst_len+8(FP), R_DLEN
10 changes: 8 additions & 2 deletions s2/index.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ const (
S2IndexHeader = "s2idx\x00"
S2IndexTrailer = "\x00xdi2s"
maxIndexEntries = 1 << 16
// If distance is less than this, we do not add the entry.
minIndexDist = 1 << 20
)

// Index represents an S2/Snappy index.
@@ -72,6 +74,10 @@ func (i *Index) add(compressedOffset, uncompressedOffset int64) error {
if latest.compressedOffset > compressedOffset {
return fmt.Errorf("internal error: Earlier compressed received (%d > %d)", latest.uncompressedOffset, uncompressedOffset)
}
if latest.uncompressedOffset+minIndexDist > uncompressedOffset {
// Only add entry if distance is large enough.
return nil
}
}
i.info = append(i.info, struct {
compressedOffset int64
@@ -122,7 +128,7 @@ func (i *Index) Find(offset int64) (compressedOff, uncompressedOff int64, err er

// reduce to stay below maxIndexEntries
func (i *Index) reduce() {
if len(i.info) < maxIndexEntries && i.estBlockUncomp >= 1<<20 {
if len(i.info) < maxIndexEntries && i.estBlockUncomp >= minIndexDist {
return
}

@@ -132,7 +138,7 @@ func (i *Index) reduce() {
j := 0

// Each block should be at least 1MB, but don't reduce below 1000 entries.
for i.estBlockUncomp*(int64(removeN)+1) < 1<<20 && len(i.info)/(removeN+1) > 1000 {
for i.estBlockUncomp*(int64(removeN)+1) < minIndexDist && len(i.info)/(removeN+1) > 1000 {
removeN++
}
for idx := 0; idx < len(src); idx++ {
6 changes: 5 additions & 1 deletion s2/s2.go
Original file line number Diff line number Diff line change
@@ -109,7 +109,11 @@ const (
chunkTypeStreamIdentifier = 0xff
)

var crcTable = crc32.MakeTable(crc32.Castagnoli)
var (
crcTable = crc32.MakeTable(crc32.Castagnoli)
magicChunkSnappyBytes = []byte(magicChunkSnappy) // Can be passed to functions where it escapes.
magicChunkBytes = []byte(magicChunk) // Can be passed to functions where it escapes.
)

// crc implements the checksum specified in section 3 of
// https://github.com/google/snappy/blob/master/framing_format.txt
26 changes: 16 additions & 10 deletions s2/writer.go
Original file line number Diff line number Diff line change
@@ -239,6 +239,9 @@ func (w *Writer) ReadFrom(r io.Reader) (n int64, err error) {
}
}
if n2 == 0 {
if cap(inbuf) >= w.obufLen {
w.buffers.Put(inbuf)
}
break
}
n += int64(n2)
@@ -314,9 +317,9 @@ func (w *Writer) AddSkippableBlock(id uint8, data []byte) (err error) {
hWriter := make(chan result)
w.output <- hWriter
if w.snappy {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes}
} else {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes}
}
}

@@ -370,9 +373,9 @@ func (w *Writer) EncodeBuffer(buf []byte) (err error) {
hWriter := make(chan result)
w.output <- hWriter
if w.snappy {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes}
} else {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes}
}
}

@@ -478,9 +481,9 @@ func (w *Writer) write(p []byte) (nRet int, errRet error) {
hWriter := make(chan result)
w.output <- hWriter
if w.snappy {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes}
} else {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes}
}
}

@@ -560,6 +563,9 @@ func (w *Writer) writeFull(inbuf []byte) (errRet error) {

if w.concurrency == 1 {
_, err := w.writeSync(inbuf[obufHeaderLen:])
if cap(inbuf) >= w.obufLen {
w.buffers.Put(inbuf)
}
return err
}

@@ -569,9 +575,9 @@ func (w *Writer) writeFull(inbuf []byte) (errRet error) {
hWriter := make(chan result)
w.output <- hWriter
if w.snappy {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunkSnappy)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkSnappyBytes}
} else {
hWriter <- result{startOffset: w.uncompWritten, b: []byte(magicChunk)}
hWriter <- result{startOffset: w.uncompWritten, b: magicChunkBytes}
}
}

@@ -637,9 +643,9 @@ func (w *Writer) writeSync(p []byte) (nRet int, errRet error) {
var n int
var err error
if w.snappy {
n, err = w.writer.Write([]byte(magicChunkSnappy))
n, err = w.writer.Write(magicChunkSnappyBytes)
} else {
n, err = w.writer.Write([]byte(magicChunk))
n, err = w.writer.Write(magicChunkBytes)
}
if err != nil {
return 0, w.err(err)
30 changes: 30 additions & 0 deletions s2/writer_test.go
Original file line number Diff line number Diff line change
@@ -603,6 +603,36 @@ func BenchmarkWriterRandom(b *testing.B) {
}
}

func BenchmarkReadFromRandom(b *testing.B) {
rng := rand.New(rand.NewSource(1))
// Make max window so we never get matches.
data := make([]byte, 8<<20)
for i := range data {
data[i] = uint8(rng.Intn(256))
}

for name, opts := range testOptions(b) {
w := NewWriter(io.Discard, opts...)
in := bytes.NewReader(data)
w.ReadFrom(in)
b.Run(name, func(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
b.SetBytes(int64(len(data)))
for i := 0; i < b.N; i++ {
in.Reset(data)
_, err := w.ReadFrom(in)
if err != nil {
b.Fatal(err)
}
}
// Flush output
w.Flush()
})
w.Close()
}
}

func BenchmarkIndexFind(b *testing.B) {
fatalErr := func(t testing.TB, err error) {
if err != nil {
Loading