Skip to content

Optimize ZSTD_wildcopy - #2256

Merged
terrelln merged 2 commits into
facebook:devfrom
helloguo:dev
Jul 29, 2020
Merged

Optimize ZSTD_wildcopy#2256
terrelln merged 2 commits into
facebook:devfrom
helloguo:dev

Conversation

@helloguo

Copy link
Copy Markdown

Use memcpy instead of COPY16 so that the add instruction can be moved after the branch. This could save 1 instruction when compiling with gcc.

Codegen before this PR: in Basic Block 1, 4 instructions execute before jmp instruction.
gcc-new-default

Codegen after this PR: in Basic Block 1, 3 instructions execute before jmp instruction.
gcc-new-proto

@terrelln

Copy link
Copy Markdown
Contributor

Awesome! I'll run my benchmarks and post them here.

The failing Travis test seems to be just noise.

Comment thread lib/common/zstd_internal.h Outdated
@terrelln

Copy link
Copy Markdown
Contributor

Benchmarks run on silesia.tar compressed at level 3 without literal compression.

Commit Compiler Device Decompression Speed (MB/s) % change Notes
dev: 6de87b3 gcc-8 nickserv (coffeelake) 1004.8    
PR#2256: 82b0cd8     1032.5 -2.75% Much more DSB
dev: 6de87b3 clang-9   976.2    
PR#2256: 82b0cd8     976.4 -0.02%  
dev: 6de87b3 gcc-10   998.4    
PR#2256: 82b0cd8     1005.3 -0.69%  
dev: 6de87b3 clang-10   971.7    
PR#2256: 82b0cd8     969.7 0.21%  
dev: 6de87b3 gcc-10 -m32   538.5    
PR#2256: 82b0cd8     527.1 2.12%  
dev: 6de87b3 gcc-8 MBP (kabylake) 1181.7    
PR#2256: 82b0cd8     1203.1 -1.82%  
dev: 6de87b3 apple llvm-11.0.0   1091.6    
PR#2256: 82b0cd8     1099.0 -0.67%  
dev: 6de87b3 gcc-6.2.0 devbigvm (skylake) 681.5    
PR#2256: 82b0cd8     679.4 0.32%  
dev: 6de87b3 clang-3.4.2   638.4    
PR#2256: 82b0cd8     630.8 1.19%  
dev: 6de87b3 gcc.par (007)   768.0    
PR#2256: 82b0cd8     787.9 -2.60%  
dev: 6de87b3 clang.par (007)   713.7    
PR#2256: 82b0cd8     733.4 -2.77%  
dev: 6de87b3 gcc.par (009)   790.9    
PR#2256: 82b0cd8     790.9 0.00%  
dev: 6de87b3 clang.par (009)   757.0    
PR#2256: 82b0cd8     751.6 0.71%  

@terrelln

Copy link
Copy Markdown
Contributor

This seems like a merge to me. The only losses are on 32-bit mode and really old compilers. Everything else is neutral (within noise) or a 0-2% gain. Additionally, this code is closer to what we would like the compiler to generate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants