-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zstd: Make load(32|64)32 safer and smaller #788
Conversation
load3232 and load6432 now limit their slice to its length. This improves safety, since encoders can no longer look at the part beyond the length. It also produces several dozen fewer instructions for bounds checks.
@greatroar Great. Could you double check that times are same or better? |
|
okie. I don't really see how it produces several dozen fewer instructions for bounds check:
Seems like a SUBQ was replaced by a NEGQ - same latency and throughput. But as long as it isn't worse it's fine. Just want to know what to expect. |
Inlining is key. E.g. in Line 315 in 2f99358
the inlined load6432 previously had to fetch both len(src) and cap(src) from the stack to do the bounds check. It now only needs the length. |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/klauspost/compress](https://togithub.com/klauspost/compress) | indirect | patch | `v1.16.3` -> `v1.16.5` | --- ### Release Notes <details> <summary>klauspost/compress</summary> ### [`v1.16.5`](https://togithub.com/klauspost/compress/releases/tag/v1.16.5) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.4...v1.16.5) #### What's Changed - zstd: readByte needs to use io.ReadFull by [@​jnoxon](https://togithub.com/jnoxon) in [klauspost/compress#802 - gzip: Fix WriterTo after initial read by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#804 #### New Contributors - [@​jnoxon](https://togithub.com/jnoxon) made their first contribution in [klauspost/compress#802 **Full Changelog**: klauspost/compress@v1.16.4...v1.16.5 ### [`v1.16.4`](https://togithub.com/klauspost/compress/releases/tag/v1.16.4) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.3...v1.16.4) #### What's Changed - s2: Fix huge block overflow by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#779 - s2: Allow CustomEncoder fallback by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#780 - zstd: Fix amd64 not always detecting corrupt data by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#785 - zstd: Improve zstd best efficiency by [@​klauspost](https://togithub.com/klauspost) and [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#784 - zstd: Make load(32|64)32 safer and smaller by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#788 - zstd: Fix quick reject on long backmatches by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#787 - zstd: Revert table size change by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#789 - zstd: Respect WithAllLitEntropyCompression by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#792 - zstd: Fix back-referenced offset by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#793 - zstd: Load source value at start of loop by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#794 - zstd: Shorten checksum code by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#795 - zstd: Fix fallback on incompressible block by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#798 - gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by [@​jgimenez](https://togithub.com/jgimenez) in [klauspost/compress#799 #### New Contributors - [@​jgimenez](https://togithub.com/jgimenez) made their first contribution in [klauspost/compress#799 **Full Changelog**: klauspost/compress@v1.16.3...v1.16.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 3am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS42Ni4zIiwidXBkYXRlZEluVmVyIjoiMzUuNjYuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/klauspost/compress](https://togithub.com/klauspost/compress) | indirect | patch | `v1.16.0` -> `v1.16.6` | --- ### Release Notes <details> <summary>klauspost/compress (github.com/klauspost/compress)</summary> ### [`v1.16.6`](https://togithub.com/klauspost/compress/releases/tag/v1.16.6) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.5...v1.16.6) #### What's Changed - zstd: correctly ignore WithEncoderPadding(1) by [@​ianlancetaylor](https://togithub.com/ianlancetaylor) in [klauspost/compress#806 - gzhttp: Handle informational headers by [@​rtribotte](https://togithub.com/rtribotte) in [klauspost/compress#815 - zstd: Add amd64 match length assembly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#824 - s2: Improve Better compression slightly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#663 - s2: Clean up matchlen assembly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#825 #### New Contributors - [@​rtribotte](https://togithub.com/rtribotte) made their first contribution in [klauspost/compress#815 - [@​dveeden](https://togithub.com/dveeden) made their first contribution in [klauspost/compress#816 **Full Changelog**: klauspost/compress@v1.16.5...v1.16.6 ### [`v1.16.5`](https://togithub.com/klauspost/compress/releases/tag/v1.16.5) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.4...v1.16.5) #### What's Changed - zstd: readByte needs to use io.ReadFull by [@​jnoxon](https://togithub.com/jnoxon) in [klauspost/compress#802 - gzip: Fix WriterTo after initial read by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#804 #### New Contributors - [@​jnoxon](https://togithub.com/jnoxon) made their first contribution in [klauspost/compress#802 **Full Changelog**: klauspost/compress@v1.16.4...v1.16.5 ### [`v1.16.4`](https://togithub.com/klauspost/compress/releases/tag/v1.16.4) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.3...v1.16.4) #### What's Changed - s2: Fix huge block overflow by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#779 - s2: Allow CustomEncoder fallback by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#780 - zstd: Fix amd64 not always detecting corrupt data by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#785 - zstd: Improve zstd best efficiency by [@​klauspost](https://togithub.com/klauspost) and [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#784 - zstd: Make load(32|64)32 safer and smaller by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#788 - zstd: Fix quick reject on long backmatches by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#787 - zstd: Revert table size change by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#789 - zstd: Respect WithAllLitEntropyCompression by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#792 - zstd: Fix back-referenced offset by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#793 - zstd: Load source value at start of loop by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#794 - zstd: Shorten checksum code by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#795 - zstd: Fix fallback on incompressible block by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#798 - gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by [@​jgimenez](https://togithub.com/jgimenez) in [klauspost/compress#799 #### New Contributors - [@​jgimenez](https://togithub.com/jgimenez) made their first contribution in [klauspost/compress#799 **Full Changelog**: klauspost/compress@v1.16.3...v1.16.4 ### [`v1.16.3`](https://togithub.com/klauspost/compress/releases/tag/v1.16.3) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.2...v1.16.3) **Full Changelog**: klauspost/compress@v1.16.2...v1.16.3 ### [`v1.16.2`](https://togithub.com/klauspost/compress/releases/tag/v1.16.2) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.1...v1.16.2) #### What's Changed - Fix Goreleaser permissions by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#777 **Full Changelog**: klauspost/compress@v1.16.1...v1.16.2 ### [`v1.16.1`](https://togithub.com/klauspost/compress/releases/tag/v1.16.1) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.0...v1.16.1) #### What's Changed - zstd: Speed up + improve best encoder by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#776 - s2: Add Intel LZ4s converter by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#766 - gzhttp: Add BREACH mitigation by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#762 - gzhttp: Remove a few unneeded allocs by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#768 - gzhttp: Fix crypto/rand.Read usage by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#770 - gzhttp: Use SHA256 as paranoid option by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#769 - gzhttp: Use strings for randomJitter to skip a copy by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#767 - zstd: Fix ineffective block size check by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#771 - zstd: Check FSE init values by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#772 - zstd: Report EOF from byteBuf.readBig by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#773 - huff0: Speed up compress1xDo by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#774 - tests: Remove fuzz printing by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#775 - tests: Add CICD Fuzz testing by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#763 - ci: set minimal permissions to GitHub Workflows by [@​diogoteles08](https://togithub.com/diogoteles08) in [klauspost/compress#765 #### New Contributors - [@​diogoteles08](https://togithub.com/diogoteles08) made their first contribution in [klauspost/compress#765 **Full Changelog**: klauspost/compress@v1.16.0...v1.16.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTEuMCIsInVwZGF0ZWRJblZlciI6IjM1LjE1MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/klauspost/compress](https://togithub.com/klauspost/compress) | indirect | minor | `v1.15.15` -> `v1.16.7` | --- ### Release Notes <details> <summary>klauspost/compress (github.com/klauspost/compress)</summary> ### [`v1.16.7`](https://togithub.com/klauspost/compress/releases/tag/v1.16.7) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.6...v1.16.7) #### What's Changed - zstd: Fix default level first dictionary encode by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#829 - docs: Fix typo in security advisory URL by [@​vcabbage](https://togithub.com/vcabbage) in [klauspost/compress#830 - s2: add GetBufferCapacity() method by [@​GiedriusS](https://togithub.com/GiedriusS) in [klauspost/compress#832 #### New Contributors - [@​vcabbage](https://togithub.com/vcabbage) made their first contribution in [klauspost/compress#830 - [@​GiedriusS](https://togithub.com/GiedriusS) made their first contribution in [klauspost/compress#832 **Full Changelog**: klauspost/compress@v1.16.6...v1.16.7 ### [`v1.16.6`](https://togithub.com/klauspost/compress/releases/tag/v1.16.6) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.5...v1.16.6) #### What's Changed - zstd: correctly ignore WithEncoderPadding(1) by [@​ianlancetaylor](https://togithub.com/ianlancetaylor) in [klauspost/compress#806 - gzhttp: Handle informational headers by [@​rtribotte](https://togithub.com/rtribotte) in [klauspost/compress#815 - zstd: Add amd64 match length assembly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#824 - s2: Improve Better compression slightly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#663 - s2: Clean up matchlen assembly by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#825 #### New Contributors - [@​rtribotte](https://togithub.com/rtribotte) made their first contribution in [klauspost/compress#815 - [@​dveeden](https://togithub.com/dveeden) made their first contribution in [klauspost/compress#816 **Full Changelog**: klauspost/compress@v1.16.5...v1.16.6 ### [`v1.16.5`](https://togithub.com/klauspost/compress/releases/tag/v1.16.5) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.4...v1.16.5) #### What's Changed - zstd: readByte needs to use io.ReadFull by [@​jnoxon](https://togithub.com/jnoxon) in [klauspost/compress#802 - gzip: Fix WriterTo after initial read by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#804 #### New Contributors - [@​jnoxon](https://togithub.com/jnoxon) made their first contribution in [klauspost/compress#802 **Full Changelog**: klauspost/compress@v1.16.4...v1.16.5 ### [`v1.16.4`](https://togithub.com/klauspost/compress/releases/tag/v1.16.4) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.3...v1.16.4) #### What's Changed - s2: Fix huge block overflow by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#779 - s2: Allow CustomEncoder fallback by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#780 - zstd: Fix amd64 not always detecting corrupt data by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#785 - zstd: Improve zstd best efficiency by [@​klauspost](https://togithub.com/klauspost) and [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#784 - zstd: Make load(32|64)32 safer and smaller by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#788 - zstd: Fix quick reject on long backmatches by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#787 - zstd: Revert table size change by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#789 - zstd: Respect WithAllLitEntropyCompression by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#792 - zstd: Fix back-referenced offset by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#793 - zstd: Load source value at start of loop by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#794 - zstd: Shorten checksum code by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#795 - zstd: Fix fallback on incompressible block by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#798 - gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by [@​jgimenez](https://togithub.com/jgimenez) in [klauspost/compress#799 #### New Contributors - [@​jgimenez](https://togithub.com/jgimenez) made their first contribution in [klauspost/compress#799 **Full Changelog**: klauspost/compress@v1.16.3...v1.16.4 ### [`v1.16.3`](https://togithub.com/klauspost/compress/releases/tag/v1.16.3) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.2...v1.16.3) **Full Changelog**: klauspost/compress@v1.16.2...v1.16.3 ### [`v1.16.2`](https://togithub.com/klauspost/compress/releases/tag/v1.16.2) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.1...v1.16.2) #### What's Changed - Fix Goreleaser permissions by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#777 **Full Changelog**: klauspost/compress@v1.16.1...v1.16.2 ### [`v1.16.1`](https://togithub.com/klauspost/compress/releases/tag/v1.16.1) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.16.0...v1.16.1) #### What's Changed - zstd: Speed up + improve best encoder by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#776 - s2: Add Intel LZ4s converter by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#766 - gzhttp: Add BREACH mitigation by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#762 - gzhttp: Remove a few unneeded allocs by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#768 - gzhttp: Fix crypto/rand.Read usage by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#770 - gzhttp: Use SHA256 as paranoid option by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#769 - gzhttp: Use strings for randomJitter to skip a copy by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#767 - zstd: Fix ineffective block size check by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#771 - zstd: Check FSE init values by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#772 - zstd: Report EOF from byteBuf.readBig by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#773 - huff0: Speed up compress1xDo by [@​greatroar](https://togithub.com/greatroar) in [klauspost/compress#774 - tests: Remove fuzz printing by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#775 - tests: Add CICD Fuzz testing by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#763 - ci: set minimal permissions to GitHub Workflows by [@​diogoteles08](https://togithub.com/diogoteles08) in [klauspost/compress#765 #### New Contributors - [@​diogoteles08](https://togithub.com/diogoteles08) made their first contribution in [klauspost/compress#765 **Full Changelog**: klauspost/compress@v1.16.0...v1.16.1 ### [`v1.16.0`](https://togithub.com/klauspost/compress/releases/tag/v1.16.0) [Compare Source](https://togithub.com/klauspost/compress/compare/v1.15.15...v1.16.0) #### What's Changed - s2: Add Dictionary support by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#685 - s2: Add Compression Size Estimate by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#752 - s2: Add support for custom stream encoder by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#755 - s2: Add LZ4 block converter by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#748 - s2: Support io.ReaderAt in ReadSeeker by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#747 - s2c/s2sx: Use concurrent decoding by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#746 - tests: Upgrade to Go 1.20 by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#749 - Update all (command) dependencies by [@​klauspost](https://togithub.com/klauspost) in [klauspost/compress#758 **Full Changelog**: klauspost/compress@v1.15.15...v1.16.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzYuMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->
load3232 and load6432 now limit their slice to its length. This improves safety, since encoders can no longer look at the part beyond the length. It also produces several dozen fewer instructions for bounds checks.