zstd-native-ruby 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (651) hide show
  1. checksums.yaml +7 -0
  2. data/CLAUDE.md +101 -0
  3. data/LICENSE +19 -0
  4. data/README.md +47 -0
  5. data/ext/zstd_ruby/extconf.rb +35 -0
  6. data/ext/zstd_ruby/zstd_ruby.c +221 -0
  7. data/lib/zstd_ruby.rb +68 -0
  8. data/vendor/zstd/CHANGELOG +863 -0
  9. data/vendor/zstd/CMakeLists.txt +11 -0
  10. data/vendor/zstd/CODE_OF_CONDUCT.md +5 -0
  11. data/vendor/zstd/CONTRIBUTING.md +494 -0
  12. data/vendor/zstd/COPYING +339 -0
  13. data/vendor/zstd/LICENSE +30 -0
  14. data/vendor/zstd/Makefile +470 -0
  15. data/vendor/zstd/Package.swift +36 -0
  16. data/vendor/zstd/README.md +244 -0
  17. data/vendor/zstd/SECURITY.md +15 -0
  18. data/vendor/zstd/TESTING.md +43 -0
  19. data/vendor/zstd/build/LICENSE +0 -0
  20. data/vendor/zstd/build/README.md +56 -0
  21. data/vendor/zstd/build/VS2008/fullbench/fullbench.vcproj +549 -0
  22. data/vendor/zstd/build/VS2008/fuzzer/fuzzer.vcproj +585 -0
  23. data/vendor/zstd/build/VS2008/zstd/zstd.vcproj +677 -0
  24. data/vendor/zstd/build/VS2008/zstd.sln +56 -0
  25. data/vendor/zstd/build/VS2008/zstdlib/zstdlib.vcproj +635 -0
  26. data/vendor/zstd/build/VS2010/CompileAsCpp.props +8 -0
  27. data/vendor/zstd/build/VS2010/datagen/datagen.vcxproj +170 -0
  28. data/vendor/zstd/build/VS2010/fullbench/fullbench.vcxproj +220 -0
  29. data/vendor/zstd/build/VS2010/fuzzer/fuzzer.vcxproj +224 -0
  30. data/vendor/zstd/build/VS2010/libzstd/libzstd.vcxproj +243 -0
  31. data/vendor/zstd/build/VS2010/libzstd-dll/libzstd-dll.rc +51 -0
  32. data/vendor/zstd/build/VS2010/libzstd-dll/libzstd-dll.vcxproj +250 -0
  33. data/vendor/zstd/build/VS2010/zstd/zstd.rc +51 -0
  34. data/vendor/zstd/build/VS2010/zstd/zstd.vcxproj +266 -0
  35. data/vendor/zstd/build/VS2010/zstd.sln +84 -0
  36. data/vendor/zstd/build/VS_scripts/README.md +64 -0
  37. data/vendor/zstd/build/VS_scripts/build.VS2010.cmd +7 -0
  38. data/vendor/zstd/build/VS_scripts/build.VS2012.cmd +6 -0
  39. data/vendor/zstd/build/VS_scripts/build.VS2013.cmd +7 -0
  40. data/vendor/zstd/build/VS_scripts/build.VS2015.cmd +7 -0
  41. data/vendor/zstd/build/VS_scripts/build.VS2017.cmd +7 -0
  42. data/vendor/zstd/build/VS_scripts/build.VS2017Community.cmd +7 -0
  43. data/vendor/zstd/build/VS_scripts/build.VS2017Enterprise.cmd +7 -0
  44. data/vendor/zstd/build/VS_scripts/build.VS2017Professional.cmd +7 -0
  45. data/vendor/zstd/build/VS_scripts/build.VSPreview.cmd +7 -0
  46. data/vendor/zstd/build/VS_scripts/build.generic.cmd +67 -0
  47. data/vendor/zstd/build/cmake/CMakeLists.txt +81 -0
  48. data/vendor/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake +138 -0
  49. data/vendor/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake +49 -0
  50. data/vendor/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake +10 -0
  51. data/vendor/zstd/build/cmake/CMakeModules/JoinPaths.cmake +23 -0
  52. data/vendor/zstd/build/cmake/CMakeModules/ZstdBuild.cmake +42 -0
  53. data/vendor/zstd/build/cmake/CMakeModules/ZstdDependencies.cmake +30 -0
  54. data/vendor/zstd/build/cmake/CMakeModules/ZstdOptions.cmake +68 -0
  55. data/vendor/zstd/build/cmake/CMakeModules/ZstdPackage.cmake +42 -0
  56. data/vendor/zstd/build/cmake/CMakeModules/ZstdVersion.cmake +31 -0
  57. data/vendor/zstd/build/cmake/README.md +155 -0
  58. data/vendor/zstd/build/cmake/contrib/CMakeLists.txt +13 -0
  59. data/vendor/zstd/build/cmake/contrib/gen_html/CMakeLists.txt +30 -0
  60. data/vendor/zstd/build/cmake/contrib/pzstd/CMakeLists.txt +39 -0
  61. data/vendor/zstd/build/cmake/lib/CMakeLists.txt +298 -0
  62. data/vendor/zstd/build/cmake/lib/cmake_uninstall.cmake.in +22 -0
  63. data/vendor/zstd/build/cmake/programs/CMakeLists.txt +144 -0
  64. data/vendor/zstd/build/cmake/tests/CMakeLists.txt +118 -0
  65. data/vendor/zstd/build/cmake/zstdConfig.cmake.in +10 -0
  66. data/vendor/zstd/build/meson/GetZstdLibraryVersion.py +39 -0
  67. data/vendor/zstd/build/meson/InstallSymlink.py +55 -0
  68. data/vendor/zstd/build/meson/README.md +38 -0
  69. data/vendor/zstd/build/meson/contrib/gen_html/meson.build +30 -0
  70. data/vendor/zstd/build/meson/contrib/meson.build +12 -0
  71. data/vendor/zstd/build/meson/contrib/pzstd/meson.build +25 -0
  72. data/vendor/zstd/build/meson/lib/meson.build +175 -0
  73. data/vendor/zstd/build/meson/meson.build +155 -0
  74. data/vendor/zstd/build/meson/meson_options.txt +36 -0
  75. data/vendor/zstd/build/meson/programs/meson.build +124 -0
  76. data/vendor/zstd/build/meson/tests/meson.build +217 -0
  77. data/vendor/zstd/build/meson/tests/valgrindTest.py +90 -0
  78. data/vendor/zstd/build/single_file_libs/README.md +33 -0
  79. data/vendor/zstd/build/single_file_libs/build_decoder_test.sh +91 -0
  80. data/vendor/zstd/build/single_file_libs/build_library_test.sh +98 -0
  81. data/vendor/zstd/build/single_file_libs/combine.py +234 -0
  82. data/vendor/zstd/build/single_file_libs/combine.sh +249 -0
  83. data/vendor/zstd/build/single_file_libs/create_single_file_decoder.sh +19 -0
  84. data/vendor/zstd/build/single_file_libs/create_single_file_library.sh +19 -0
  85. data/vendor/zstd/build/single_file_libs/examples/README.md +11 -0
  86. data/vendor/zstd/build/single_file_libs/examples/emscripten.c +340 -0
  87. data/vendor/zstd/build/single_file_libs/examples/roundtrip.c +83 -0
  88. data/vendor/zstd/build/single_file_libs/examples/shell.html +31 -0
  89. data/vendor/zstd/build/single_file_libs/examples/simple.c +75 -0
  90. data/vendor/zstd/build/single_file_libs/examples/testcard-dxt1.inl +2731 -0
  91. data/vendor/zstd/build/single_file_libs/examples/testcard-zstd.inl +261 -0
  92. data/vendor/zstd/build/single_file_libs/examples/testcard.png +0 -0
  93. data/vendor/zstd/build/single_file_libs/zstd-in.c +91 -0
  94. data/vendor/zstd/build/single_file_libs/zstddeclib-in.c +62 -0
  95. data/vendor/zstd/contrib/VS2005/README.md +3 -0
  96. data/vendor/zstd/contrib/VS2005/fullbench/fullbench.vcproj +440 -0
  97. data/vendor/zstd/contrib/VS2005/fuzzer/fuzzer.vcproj +488 -0
  98. data/vendor/zstd/contrib/VS2005/zstd/zstd.vcproj +552 -0
  99. data/vendor/zstd/contrib/VS2005/zstd.sln +55 -0
  100. data/vendor/zstd/contrib/VS2005/zstdlib/zstdlib.vcproj +546 -0
  101. data/vendor/zstd/contrib/cleanTabs +2 -0
  102. data/vendor/zstd/contrib/diagnose_corruption/Makefile +35 -0
  103. data/vendor/zstd/contrib/diagnose_corruption/check_flipped_bits.c +400 -0
  104. data/vendor/zstd/contrib/docker/Dockerfile +20 -0
  105. data/vendor/zstd/contrib/docker/README.md +20 -0
  106. data/vendor/zstd/contrib/externalSequenceProducer/Makefile +40 -0
  107. data/vendor/zstd/contrib/externalSequenceProducer/README.md +14 -0
  108. data/vendor/zstd/contrib/externalSequenceProducer/main.c +108 -0
  109. data/vendor/zstd/contrib/externalSequenceProducer/sequence_producer.c +80 -0
  110. data/vendor/zstd/contrib/externalSequenceProducer/sequence_producer.h +26 -0
  111. data/vendor/zstd/contrib/freestanding_lib/freestanding.py +774 -0
  112. data/vendor/zstd/contrib/gen_html/Makefile +51 -0
  113. data/vendor/zstd/contrib/gen_html/README.md +31 -0
  114. data/vendor/zstd/contrib/gen_html/gen-zstd-manual.sh +9 -0
  115. data/vendor/zstd/contrib/gen_html/gen_html.cpp +225 -0
  116. data/vendor/zstd/contrib/largeNbDicts/Makefile +58 -0
  117. data/vendor/zstd/contrib/largeNbDicts/README.md +33 -0
  118. data/vendor/zstd/contrib/largeNbDicts/largeNbDicts.c +1087 -0
  119. data/vendor/zstd/contrib/linux-kernel/Makefile +108 -0
  120. data/vendor/zstd/contrib/linux-kernel/README.md +14 -0
  121. data/vendor/zstd/contrib/linux-kernel/btrfs-benchmark.sh +104 -0
  122. data/vendor/zstd/contrib/linux-kernel/btrfs-extract-benchmark.sh +99 -0
  123. data/vendor/zstd/contrib/linux-kernel/decompress_sources.h +34 -0
  124. data/vendor/zstd/contrib/linux-kernel/linux.mk +44 -0
  125. data/vendor/zstd/contrib/linux-kernel/linux_zstd.h +691 -0
  126. data/vendor/zstd/contrib/linux-kernel/mem.h +262 -0
  127. data/vendor/zstd/contrib/linux-kernel/squashfs-benchmark.sh +39 -0
  128. data/vendor/zstd/contrib/linux-kernel/test/Makefile +49 -0
  129. data/vendor/zstd/contrib/linux-kernel/test/include/linux/compiler.h +23 -0
  130. data/vendor/zstd/contrib/linux-kernel/test/include/linux/errno.h +15 -0
  131. data/vendor/zstd/contrib/linux-kernel/test/include/linux/kernel.h +19 -0
  132. data/vendor/zstd/contrib/linux-kernel/test/include/linux/limits.h +15 -0
  133. data/vendor/zstd/contrib/linux-kernel/test/include/linux/math64.h +15 -0
  134. data/vendor/zstd/contrib/linux-kernel/test/include/linux/module.h +20 -0
  135. data/vendor/zstd/contrib/linux-kernel/test/include/linux/printk.h +15 -0
  136. data/vendor/zstd/contrib/linux-kernel/test/include/linux/stddef.h +15 -0
  137. data/vendor/zstd/contrib/linux-kernel/test/include/linux/swab.h +16 -0
  138. data/vendor/zstd/contrib/linux-kernel/test/include/linux/types.h +16 -0
  139. data/vendor/zstd/contrib/linux-kernel/test/include/linux/unaligned.h +187 -0
  140. data/vendor/zstd/contrib/linux-kernel/test/include/linux/xxhash.h +745 -0
  141. data/vendor/zstd/contrib/linux-kernel/test/macro-test.sh +44 -0
  142. data/vendor/zstd/contrib/linux-kernel/test/static_test.c +52 -0
  143. data/vendor/zstd/contrib/linux-kernel/test/test.c +229 -0
  144. data/vendor/zstd/contrib/linux-kernel/zstd_common_module.c +29 -0
  145. data/vendor/zstd/contrib/linux-kernel/zstd_compress_module.c +286 -0
  146. data/vendor/zstd/contrib/linux-kernel/zstd_decompress_module.c +141 -0
  147. data/vendor/zstd/contrib/linux-kernel/zstd_deps.h +121 -0
  148. data/vendor/zstd/contrib/match_finders/README.md +42 -0
  149. data/vendor/zstd/contrib/match_finders/zstd_edist.c +558 -0
  150. data/vendor/zstd/contrib/match_finders/zstd_edist.h +70 -0
  151. data/vendor/zstd/contrib/premake/premake4.lua +6 -0
  152. data/vendor/zstd/contrib/premake/zstd.lua +81 -0
  153. data/vendor/zstd/contrib/pzstd/BUCK +72 -0
  154. data/vendor/zstd/contrib/pzstd/ErrorHolder.h +54 -0
  155. data/vendor/zstd/contrib/pzstd/Logging.h +73 -0
  156. data/vendor/zstd/contrib/pzstd/Makefile +265 -0
  157. data/vendor/zstd/contrib/pzstd/Options.cpp +424 -0
  158. data/vendor/zstd/contrib/pzstd/Options.h +71 -0
  159. data/vendor/zstd/contrib/pzstd/Pzstd.cpp +626 -0
  160. data/vendor/zstd/contrib/pzstd/Pzstd.h +153 -0
  161. data/vendor/zstd/contrib/pzstd/README.md +56 -0
  162. data/vendor/zstd/contrib/pzstd/SkippableFrame.cpp +30 -0
  163. data/vendor/zstd/contrib/pzstd/SkippableFrame.h +64 -0
  164. data/vendor/zstd/contrib/pzstd/images/Cspeed.png +0 -0
  165. data/vendor/zstd/contrib/pzstd/images/Dspeed.png +0 -0
  166. data/vendor/zstd/contrib/pzstd/main.cpp +27 -0
  167. data/vendor/zstd/contrib/pzstd/test/BUCK +37 -0
  168. data/vendor/zstd/contrib/pzstd/test/OptionsTest.cpp +536 -0
  169. data/vendor/zstd/contrib/pzstd/test/PzstdTest.cpp +147 -0
  170. data/vendor/zstd/contrib/pzstd/test/RoundTrip.h +86 -0
  171. data/vendor/zstd/contrib/pzstd/test/RoundTripTest.cpp +84 -0
  172. data/vendor/zstd/contrib/pzstd/utils/BUCK +75 -0
  173. data/vendor/zstd/contrib/pzstd/utils/Buffer.h +99 -0
  174. data/vendor/zstd/contrib/pzstd/utils/FileSystem.h +96 -0
  175. data/vendor/zstd/contrib/pzstd/utils/Likely.h +28 -0
  176. data/vendor/zstd/contrib/pzstd/utils/Portability.h +16 -0
  177. data/vendor/zstd/contrib/pzstd/utils/Range.h +133 -0
  178. data/vendor/zstd/contrib/pzstd/utils/ResourcePool.h +96 -0
  179. data/vendor/zstd/contrib/pzstd/utils/ScopeGuard.h +50 -0
  180. data/vendor/zstd/contrib/pzstd/utils/ThreadPool.h +58 -0
  181. data/vendor/zstd/contrib/pzstd/utils/WorkQueue.h +182 -0
  182. data/vendor/zstd/contrib/pzstd/utils/test/BUCK +35 -0
  183. data/vendor/zstd/contrib/pzstd/utils/test/BufferTest.cpp +89 -0
  184. data/vendor/zstd/contrib/pzstd/utils/test/RangeTest.cpp +82 -0
  185. data/vendor/zstd/contrib/pzstd/utils/test/ResourcePoolTest.cpp +72 -0
  186. data/vendor/zstd/contrib/pzstd/utils/test/ScopeGuardTest.cpp +28 -0
  187. data/vendor/zstd/contrib/pzstd/utils/test/ThreadPoolTest.cpp +71 -0
  188. data/vendor/zstd/contrib/pzstd/utils/test/WorkQueueTest.cpp +282 -0
  189. data/vendor/zstd/contrib/recovery/Makefile +35 -0
  190. data/vendor/zstd/contrib/recovery/recover_directory.c +152 -0
  191. data/vendor/zstd/contrib/seekable_format/README.md +42 -0
  192. data/vendor/zstd/contrib/seekable_format/examples/Makefile +55 -0
  193. data/vendor/zstd/contrib/seekable_format/examples/parallel_compression.c +254 -0
  194. data/vendor/zstd/contrib/seekable_format/examples/parallel_processing.c +191 -0
  195. data/vendor/zstd/contrib/seekable_format/examples/seekable_compression.c +136 -0
  196. data/vendor/zstd/contrib/seekable_format/examples/seekable_decompression.c +141 -0
  197. data/vendor/zstd/contrib/seekable_format/examples/seekable_decompression_mem.c +147 -0
  198. data/vendor/zstd/contrib/seekable_format/tests/Makefile +58 -0
  199. data/vendor/zstd/contrib/seekable_format/tests/seekable_tests.c +375 -0
  200. data/vendor/zstd/contrib/seekable_format/zstd_seekable.h +226 -0
  201. data/vendor/zstd/contrib/seekable_format/zstd_seekable_compression_format.md +116 -0
  202. data/vendor/zstd/contrib/seekable_format/zstdseek_compress.c +365 -0
  203. data/vendor/zstd/contrib/seekable_format/zstdseek_decompress.c +600 -0
  204. data/vendor/zstd/contrib/seqBench/Makefile +58 -0
  205. data/vendor/zstd/contrib/seqBench/seqBench.c +53 -0
  206. data/vendor/zstd/contrib/snap/snapcraft.yaml +28 -0
  207. data/vendor/zstd/doc/README.md +26 -0
  208. data/vendor/zstd/doc/decompressor_errata.md +148 -0
  209. data/vendor/zstd/doc/decompressor_permissive.md +80 -0
  210. data/vendor/zstd/doc/educational_decoder/Makefile +62 -0
  211. data/vendor/zstd/doc/educational_decoder/README.md +36 -0
  212. data/vendor/zstd/doc/educational_decoder/harness.c +119 -0
  213. data/vendor/zstd/doc/educational_decoder/zstd_decompress.c +2323 -0
  214. data/vendor/zstd/doc/educational_decoder/zstd_decompress.h +61 -0
  215. data/vendor/zstd/doc/images/CSpeed2.png +0 -0
  216. data/vendor/zstd/doc/images/DCspeed5.png +0 -0
  217. data/vendor/zstd/doc/images/DSpeed3.png +0 -0
  218. data/vendor/zstd/doc/images/cdict_v136.png +0 -0
  219. data/vendor/zstd/doc/images/dict-cr.png +0 -0
  220. data/vendor/zstd/doc/images/dict-cs.png +0 -0
  221. data/vendor/zstd/doc/images/dict-ds.png +0 -0
  222. data/vendor/zstd/doc/images/zstd_cdict_v1_3_5.png +0 -0
  223. data/vendor/zstd/doc/images/zstd_logo86.png +0 -0
  224. data/vendor/zstd/doc/zstd_compression_format.md +1772 -0
  225. data/vendor/zstd/doc/zstd_manual.html +2244 -0
  226. data/vendor/zstd/examples/Makefile +93 -0
  227. data/vendor/zstd/examples/README.md +46 -0
  228. data/vendor/zstd/examples/common.h +246 -0
  229. data/vendor/zstd/examples/dictionary_compression.c +107 -0
  230. data/vendor/zstd/examples/dictionary_decompression.c +99 -0
  231. data/vendor/zstd/examples/multiple_simple_compression.c +116 -0
  232. data/vendor/zstd/examples/multiple_streaming_compression.c +133 -0
  233. data/vendor/zstd/examples/simple_compression.c +68 -0
  234. data/vendor/zstd/examples/simple_decompression.c +65 -0
  235. data/vendor/zstd/examples/streaming_compression.c +146 -0
  236. data/vendor/zstd/examples/streaming_compression_thread_pool.c +180 -0
  237. data/vendor/zstd/examples/streaming_decompression.c +100 -0
  238. data/vendor/zstd/examples/streaming_memory_usage.c +137 -0
  239. data/vendor/zstd/lib/BUCK +232 -0
  240. data/vendor/zstd/lib/Makefile +389 -0
  241. data/vendor/zstd/lib/README.md +267 -0
  242. data/vendor/zstd/lib/common/allocations.h +55 -0
  243. data/vendor/zstd/lib/common/bits.h +205 -0
  244. data/vendor/zstd/lib/common/bitstream.h +454 -0
  245. data/vendor/zstd/lib/common/compiler.h +482 -0
  246. data/vendor/zstd/lib/common/cpu.h +249 -0
  247. data/vendor/zstd/lib/common/debug.c +30 -0
  248. data/vendor/zstd/lib/common/debug.h +107 -0
  249. data/vendor/zstd/lib/common/debug.o +0 -0
  250. data/vendor/zstd/lib/common/entropy_common.c +340 -0
  251. data/vendor/zstd/lib/common/entropy_common.o +0 -0
  252. data/vendor/zstd/lib/common/error_private.c +64 -0
  253. data/vendor/zstd/lib/common/error_private.h +158 -0
  254. data/vendor/zstd/lib/common/error_private.o +0 -0
  255. data/vendor/zstd/lib/common/fse.h +625 -0
  256. data/vendor/zstd/lib/common/fse_decompress.c +315 -0
  257. data/vendor/zstd/lib/common/fse_decompress.o +0 -0
  258. data/vendor/zstd/lib/common/huf.h +277 -0
  259. data/vendor/zstd/lib/common/mem.h +422 -0
  260. data/vendor/zstd/lib/common/pool.c +371 -0
  261. data/vendor/zstd/lib/common/pool.h +81 -0
  262. data/vendor/zstd/lib/common/pool.o +0 -0
  263. data/vendor/zstd/lib/common/portability_macros.h +190 -0
  264. data/vendor/zstd/lib/common/threading.c +196 -0
  265. data/vendor/zstd/lib/common/threading.h +142 -0
  266. data/vendor/zstd/lib/common/threading.o +0 -0
  267. data/vendor/zstd/lib/common/xxhash.c +18 -0
  268. data/vendor/zstd/lib/common/xxhash.h +7094 -0
  269. data/vendor/zstd/lib/common/xxhash.o +0 -0
  270. data/vendor/zstd/lib/common/zstd_common.c +57 -0
  271. data/vendor/zstd/lib/common/zstd_common.o +0 -0
  272. data/vendor/zstd/lib/common/zstd_deps.h +123 -0
  273. data/vendor/zstd/lib/common/zstd_internal.h +326 -0
  274. data/vendor/zstd/lib/common/zstd_trace.h +156 -0
  275. data/vendor/zstd/lib/compress/clevels.h +134 -0
  276. data/vendor/zstd/lib/compress/fse_compress.c +625 -0
  277. data/vendor/zstd/lib/compress/fse_compress.o +0 -0
  278. data/vendor/zstd/lib/compress/hist.c +446 -0
  279. data/vendor/zstd/lib/compress/hist.h +86 -0
  280. data/vendor/zstd/lib/compress/hist.o +0 -0
  281. data/vendor/zstd/lib/compress/huf_compress.c +1465 -0
  282. data/vendor/zstd/lib/compress/huf_compress.o +0 -0
  283. data/vendor/zstd/lib/compress/zstd_compress.c +8362 -0
  284. data/vendor/zstd/lib/compress/zstd_compress.o +0 -0
  285. data/vendor/zstd/lib/compress/zstd_compress_internal.h +1636 -0
  286. data/vendor/zstd/lib/compress/zstd_compress_literals.c +235 -0
  287. data/vendor/zstd/lib/compress/zstd_compress_literals.h +39 -0
  288. data/vendor/zstd/lib/compress/zstd_compress_literals.o +0 -0
  289. data/vendor/zstd/lib/compress/zstd_compress_sequences.c +442 -0
  290. data/vendor/zstd/lib/compress/zstd_compress_sequences.h +55 -0
  291. data/vendor/zstd/lib/compress/zstd_compress_sequences.o +0 -0
  292. data/vendor/zstd/lib/compress/zstd_compress_superblock.c +688 -0
  293. data/vendor/zstd/lib/compress/zstd_compress_superblock.h +32 -0
  294. data/vendor/zstd/lib/compress/zstd_compress_superblock.o +0 -0
  295. data/vendor/zstd/lib/compress/zstd_cwksp.h +765 -0
  296. data/vendor/zstd/lib/compress/zstd_double_fast.c +778 -0
  297. data/vendor/zstd/lib/compress/zstd_double_fast.h +42 -0
  298. data/vendor/zstd/lib/compress/zstd_double_fast.o +0 -0
  299. data/vendor/zstd/lib/compress/zstd_fast.c +985 -0
  300. data/vendor/zstd/lib/compress/zstd_fast.h +30 -0
  301. data/vendor/zstd/lib/compress/zstd_fast.o +0 -0
  302. data/vendor/zstd/lib/compress/zstd_lazy.c +2243 -0
  303. data/vendor/zstd/lib/compress/zstd_lazy.h +193 -0
  304. data/vendor/zstd/lib/compress/zstd_lazy.o +0 -0
  305. data/vendor/zstd/lib/compress/zstd_ldm.c +745 -0
  306. data/vendor/zstd/lib/compress/zstd_ldm.h +109 -0
  307. data/vendor/zstd/lib/compress/zstd_ldm.o +0 -0
  308. data/vendor/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  309. data/vendor/zstd/lib/compress/zstd_opt.c +1572 -0
  310. data/vendor/zstd/lib/compress/zstd_opt.h +72 -0
  311. data/vendor/zstd/lib/compress/zstd_opt.o +0 -0
  312. data/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
  313. data/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
  314. data/vendor/zstd/lib/compress/zstd_preSplit.o +0 -0
  315. data/vendor/zstd/lib/compress/zstdmt_compress.c +1924 -0
  316. data/vendor/zstd/lib/compress/zstdmt_compress.h +102 -0
  317. data/vendor/zstd/lib/compress/zstdmt_compress.o +0 -0
  318. data/vendor/zstd/lib/decompress/huf_decompress.c +1953 -0
  319. data/vendor/zstd/lib/decompress/huf_decompress.o +0 -0
  320. data/vendor/zstd/lib/decompress/huf_decompress_amd64.S +766 -0
  321. data/vendor/zstd/lib/decompress/zstd_ddict.c +244 -0
  322. data/vendor/zstd/lib/decompress/zstd_ddict.h +44 -0
  323. data/vendor/zstd/lib/decompress/zstd_ddict.o +0 -0
  324. data/vendor/zstd/lib/decompress/zstd_decompress.c +2410 -0
  325. data/vendor/zstd/lib/decompress/zstd_decompress.o +0 -0
  326. data/vendor/zstd/lib/decompress/zstd_decompress_block.c +2311 -0
  327. data/vendor/zstd/lib/decompress/zstd_decompress_block.h +73 -0
  328. data/vendor/zstd/lib/decompress/zstd_decompress_block.o +0 -0
  329. data/vendor/zstd/lib/decompress/zstd_decompress_internal.h +240 -0
  330. data/vendor/zstd/lib/deprecated/zbuff.h +214 -0
  331. data/vendor/zstd/lib/deprecated/zbuff_common.c +26 -0
  332. data/vendor/zstd/lib/deprecated/zbuff_compress.c +167 -0
  333. data/vendor/zstd/lib/deprecated/zbuff_decompress.c +77 -0
  334. data/vendor/zstd/lib/dictBuilder/cover.c +1333 -0
  335. data/vendor/zstd/lib/dictBuilder/cover.h +152 -0
  336. data/vendor/zstd/lib/dictBuilder/divsufsort.c +1913 -0
  337. data/vendor/zstd/lib/dictBuilder/divsufsort.h +57 -0
  338. data/vendor/zstd/lib/dictBuilder/fastcover.c +765 -0
  339. data/vendor/zstd/lib/dictBuilder/zdict.c +1137 -0
  340. data/vendor/zstd/lib/dll/example/Makefile +48 -0
  341. data/vendor/zstd/lib/dll/example/README.md +63 -0
  342. data/vendor/zstd/lib/dll/example/build_package.bat +55 -0
  343. data/vendor/zstd/lib/dll/example/fullbench-dll.sln +25 -0
  344. data/vendor/zstd/lib/dll/example/fullbench-dll.vcxproj +181 -0
  345. data/vendor/zstd/lib/install_oses.mk +17 -0
  346. data/vendor/zstd/lib/legacy/zstd_legacy.h +452 -0
  347. data/vendor/zstd/lib/legacy/zstd_v01.c +2128 -0
  348. data/vendor/zstd/lib/legacy/zstd_v01.h +94 -0
  349. data/vendor/zstd/lib/legacy/zstd_v02.c +3465 -0
  350. data/vendor/zstd/lib/legacy/zstd_v02.h +93 -0
  351. data/vendor/zstd/lib/legacy/zstd_v03.c +3105 -0
  352. data/vendor/zstd/lib/legacy/zstd_v03.h +93 -0
  353. data/vendor/zstd/lib/legacy/zstd_v04.c +3598 -0
  354. data/vendor/zstd/lib/legacy/zstd_v04.h +142 -0
  355. data/vendor/zstd/lib/legacy/zstd_v05.c +4005 -0
  356. data/vendor/zstd/lib/legacy/zstd_v05.h +162 -0
  357. data/vendor/zstd/lib/legacy/zstd_v06.c +4110 -0
  358. data/vendor/zstd/lib/legacy/zstd_v06.h +172 -0
  359. data/vendor/zstd/lib/legacy/zstd_v07.c +4490 -0
  360. data/vendor/zstd/lib/legacy/zstd_v07.h +187 -0
  361. data/vendor/zstd/lib/libzstd.mk +238 -0
  362. data/vendor/zstd/lib/libzstd.pc.in +17 -0
  363. data/vendor/zstd/lib/module.modulemap +35 -0
  364. data/vendor/zstd/lib/zdict.h +481 -0
  365. data/vendor/zstd/lib/zstd.h +3209 -0
  366. data/vendor/zstd/lib/zstd_errors.h +107 -0
  367. data/vendor/zstd/programs/BUCK +44 -0
  368. data/vendor/zstd/programs/Makefile +445 -0
  369. data/vendor/zstd/programs/README.md +344 -0
  370. data/vendor/zstd/programs/benchfn.c +256 -0
  371. data/vendor/zstd/programs/benchfn.h +173 -0
  372. data/vendor/zstd/programs/benchzstd.c +1270 -0
  373. data/vendor/zstd/programs/benchzstd.h +191 -0
  374. data/vendor/zstd/programs/datagen.c +186 -0
  375. data/vendor/zstd/programs/datagen.h +38 -0
  376. data/vendor/zstd/programs/dibio.c +447 -0
  377. data/vendor/zstd/programs/dibio.h +39 -0
  378. data/vendor/zstd/programs/fileio.c +3717 -0
  379. data/vendor/zstd/programs/fileio.h +171 -0
  380. data/vendor/zstd/programs/fileio_asyncio.c +663 -0
  381. data/vendor/zstd/programs/fileio_asyncio.h +195 -0
  382. data/vendor/zstd/programs/fileio_common.h +121 -0
  383. data/vendor/zstd/programs/fileio_types.h +86 -0
  384. data/vendor/zstd/programs/lorem.c +285 -0
  385. data/vendor/zstd/programs/lorem.h +32 -0
  386. data/vendor/zstd/programs/platform.h +217 -0
  387. data/vendor/zstd/programs/timefn.c +170 -0
  388. data/vendor/zstd/programs/timefn.h +59 -0
  389. data/vendor/zstd/programs/util.c +1731 -0
  390. data/vendor/zstd/programs/util.h +364 -0
  391. data/vendor/zstd/programs/windres/verrsrc.h +17 -0
  392. data/vendor/zstd/programs/windres/zstd.rc +51 -0
  393. data/vendor/zstd/programs/windres/zstd32.res +0 -0
  394. data/vendor/zstd/programs/windres/zstd64.res +0 -0
  395. data/vendor/zstd/programs/zstd.1 +580 -0
  396. data/vendor/zstd/programs/zstd.1.md +714 -0
  397. data/vendor/zstd/programs/zstdcli.c +1675 -0
  398. data/vendor/zstd/programs/zstdcli_trace.c +173 -0
  399. data/vendor/zstd/programs/zstdcli_trace.h +24 -0
  400. data/vendor/zstd/programs/zstdgrep +134 -0
  401. data/vendor/zstd/programs/zstdgrep.1 +26 -0
  402. data/vendor/zstd/programs/zstdgrep.1.md +30 -0
  403. data/vendor/zstd/programs/zstdless +8 -0
  404. data/vendor/zstd/programs/zstdless.1 +14 -0
  405. data/vendor/zstd/programs/zstdless.1.md +16 -0
  406. data/vendor/zstd/tests/DEPRECATED-test-zstd-speed.py +378 -0
  407. data/vendor/zstd/tests/Makefile +485 -0
  408. data/vendor/zstd/tests/README.md +184 -0
  409. data/vendor/zstd/tests/automated_benchmarking.py +326 -0
  410. data/vendor/zstd/tests/checkTag.c +65 -0
  411. data/vendor/zstd/tests/check_size.py +31 -0
  412. data/vendor/zstd/tests/cli-tests/README.md +258 -0
  413. data/vendor/zstd/tests/cli-tests/basic/args.sh +10 -0
  414. data/vendor/zstd/tests/cli-tests/basic/args.sh.exit +1 -0
  415. data/vendor/zstd/tests/cli-tests/basic/args.sh.stderr.glob +28 -0
  416. data/vendor/zstd/tests/cli-tests/basic/help.sh +10 -0
  417. data/vendor/zstd/tests/cli-tests/basic/help.sh.stdout.glob +34 -0
  418. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh +40 -0
  419. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh.stderr.exact +13 -0
  420. data/vendor/zstd/tests/cli-tests/basic/memlimit.sh.stdout.exact +13 -0
  421. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh +7 -0
  422. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh.stderr.exact +2 -0
  423. data/vendor/zstd/tests/cli-tests/basic/output_dir.sh.stdout.exact +2 -0
  424. data/vendor/zstd/tests/cli-tests/basic/version.sh +6 -0
  425. data/vendor/zstd/tests/cli-tests/basic/version.sh.stdout.glob +2 -0
  426. data/vendor/zstd/tests/cli-tests/bin/cmp_size +44 -0
  427. data/vendor/zstd/tests/cli-tests/bin/datagen +3 -0
  428. data/vendor/zstd/tests/cli-tests/bin/die +4 -0
  429. data/vendor/zstd/tests/cli-tests/bin/println +2 -0
  430. data/vendor/zstd/tests/cli-tests/bin/unzstd +1 -0
  431. data/vendor/zstd/tests/cli-tests/bin/zstd +9 -0
  432. data/vendor/zstd/tests/cli-tests/bin/zstdcat +1 -0
  433. data/vendor/zstd/tests/cli-tests/bin/zstdgrep +2 -0
  434. data/vendor/zstd/tests/cli-tests/bin/zstdless +2 -0
  435. data/vendor/zstd/tests/cli-tests/cltools/setup +6 -0
  436. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh +8 -0
  437. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.exit +1 -0
  438. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.stderr.exact +1 -0
  439. data/vendor/zstd/tests/cli-tests/cltools/zstdgrep.sh.stdout.glob +4 -0
  440. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh +10 -0
  441. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh.stderr.exact +2 -0
  442. data/vendor/zstd/tests/cli-tests/cltools/zstdless.sh.stdout.glob +5 -0
  443. data/vendor/zstd/tests/cli-tests/common/format.sh +19 -0
  444. data/vendor/zstd/tests/cli-tests/common/mtime.sh +13 -0
  445. data/vendor/zstd/tests/cli-tests/common/permissions.sh +18 -0
  446. data/vendor/zstd/tests/cli-tests/common/platform.sh +47 -0
  447. data/vendor/zstd/tests/cli-tests/compression/adapt.sh +14 -0
  448. data/vendor/zstd/tests/cli-tests/compression/basic.sh +36 -0
  449. data/vendor/zstd/tests/cli-tests/compression/compress-literals.sh +10 -0
  450. data/vendor/zstd/tests/cli-tests/compression/format.sh +16 -0
  451. data/vendor/zstd/tests/cli-tests/compression/golden.sh +16 -0
  452. data/vendor/zstd/tests/cli-tests/compression/gzip-compat.sh +17 -0
  453. data/vendor/zstd/tests/cli-tests/compression/levels.sh +75 -0
  454. data/vendor/zstd/tests/cli-tests/compression/levels.sh.stderr.exact +80 -0
  455. data/vendor/zstd/tests/cli-tests/compression/long-distance-matcher.sh +7 -0
  456. data/vendor/zstd/tests/cli-tests/compression/multi-threaded.sh +22 -0
  457. data/vendor/zstd/tests/cli-tests/compression/multi-threaded.sh.stderr.exact +21 -0
  458. data/vendor/zstd/tests/cli-tests/compression/multiple-files.sh +21 -0
  459. data/vendor/zstd/tests/cli-tests/compression/multiple-files.sh.stdout.exact +12 -0
  460. data/vendor/zstd/tests/cli-tests/compression/row-match-finder.sh +7 -0
  461. data/vendor/zstd/tests/cli-tests/compression/setup +7 -0
  462. data/vendor/zstd/tests/cli-tests/compression/stream-size.sh +7 -0
  463. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh +11 -0
  464. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh.stderr.glob +5 -0
  465. data/vendor/zstd/tests/cli-tests/compression/verbose-wlog.sh.stdout.glob +5 -0
  466. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh +9 -0
  467. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh.stderr.ignore +0 -0
  468. data/vendor/zstd/tests/cli-tests/compression/window-resize.sh.stdout.glob +3 -0
  469. data/vendor/zstd/tests/cli-tests/decompression/detectErrors.sh +11 -0
  470. data/vendor/zstd/tests/cli-tests/decompression/golden.sh +7 -0
  471. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh +57 -0
  472. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh.stderr.exact +11 -0
  473. data/vendor/zstd/tests/cli-tests/decompression/pass-through.sh.stdout.exact +25 -0
  474. data/vendor/zstd/tests/cli-tests/determinism/basic.sh +36 -0
  475. data/vendor/zstd/tests/cli-tests/determinism/basic.sh.stderr.exact +0 -0
  476. data/vendor/zstd/tests/cli-tests/determinism/basic.sh.stdout.exact +880 -0
  477. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh +45 -0
  478. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh.stderr.exact +0 -0
  479. data/vendor/zstd/tests/cli-tests/determinism/multithread.sh.stdout.exact +260 -0
  480. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh +44 -0
  481. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh.stderr.exact +0 -0
  482. data/vendor/zstd/tests/cli-tests/determinism/reuse.sh.stdout.exact +19 -0
  483. data/vendor/zstd/tests/cli-tests/determinism/setup +5 -0
  484. data/vendor/zstd/tests/cli-tests/determinism/setup_once +30 -0
  485. data/vendor/zstd/tests/cli-tests/dict-builder/empty-input.sh +9 -0
  486. data/vendor/zstd/tests/cli-tests/dict-builder/empty-input.sh.stderr.exact +1 -0
  487. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh +3 -0
  488. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh.exit +1 -0
  489. data/vendor/zstd/tests/cli-tests/dict-builder/no-inputs.sh.stderr.exact +5 -0
  490. data/vendor/zstd/tests/cli-tests/dictionaries/dictionary-mismatch.sh +29 -0
  491. data/vendor/zstd/tests/cli-tests/dictionaries/dictionary-mismatch.sh.stderr.exact +7 -0
  492. data/vendor/zstd/tests/cli-tests/dictionaries/golden.sh +9 -0
  493. data/vendor/zstd/tests/cli-tests/dictionaries/setup +6 -0
  494. data/vendor/zstd/tests/cli-tests/dictionaries/setup_once +24 -0
  495. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh +49 -0
  496. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh.stderr.exact +0 -0
  497. data/vendor/zstd/tests/cli-tests/file-handling/directory-mirror.sh.stdout.exact +0 -0
  498. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh +12 -0
  499. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh.stderr.exact +30 -0
  500. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-file.sh +9 -0
  501. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-file.sh.stderr.glob +46 -0
  502. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-stdout.sh +8 -0
  503. data/vendor/zstd/tests/cli-tests/file-stat/compress-file-to-stdout.sh.stderr.exact +24 -0
  504. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-file.sh +8 -0
  505. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-file.sh.stderr.glob +28 -0
  506. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-stdout.sh +8 -0
  507. data/vendor/zstd/tests/cli-tests/file-stat/compress-stdin-to-stdout.sh.stderr.exact +18 -0
  508. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-file.sh +8 -0
  509. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-file.sh.stderr.glob +42 -0
  510. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-stdout.sh +7 -0
  511. data/vendor/zstd/tests/cli-tests/file-stat/decompress-file-to-stdout.sh.stderr.exact +18 -0
  512. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-file.sh +7 -0
  513. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-file.sh.stderr.glob +24 -0
  514. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-stdout.sh +7 -0
  515. data/vendor/zstd/tests/cli-tests/file-stat/decompress-stdin-to-stdout.sh.stderr.exact +14 -0
  516. data/vendor/zstd/tests/cli-tests/progress/no-progress.sh +46 -0
  517. data/vendor/zstd/tests/cli-tests/progress/no-progress.sh.stderr.glob +96 -0
  518. data/vendor/zstd/tests/cli-tests/progress/progress.sh +41 -0
  519. data/vendor/zstd/tests/cli-tests/progress/progress.sh.stderr.glob +62 -0
  520. data/vendor/zstd/tests/cli-tests/run.py +732 -0
  521. data/vendor/zstd/tests/cli-tests/zstd-symlinks/setup +6 -0
  522. data/vendor/zstd/tests/cli-tests/zstd-symlinks/zstdcat.sh +12 -0
  523. data/vendor/zstd/tests/cli-tests/zstd-symlinks/zstdcat.sh.stdout.exact +8 -0
  524. data/vendor/zstd/tests/datagencli.c +149 -0
  525. data/vendor/zstd/tests/decodecorpus.c +1998 -0
  526. data/vendor/zstd/tests/dict-files/zero-weight-dict +0 -0
  527. data/vendor/zstd/tests/external_matchfinder.c +140 -0
  528. data/vendor/zstd/tests/external_matchfinder.h +39 -0
  529. data/vendor/zstd/tests/fullbench.c +1210 -0
  530. data/vendor/zstd/tests/fuzz/Makefile +278 -0
  531. data/vendor/zstd/tests/fuzz/README.md +161 -0
  532. data/vendor/zstd/tests/fuzz/block_decompress.c +53 -0
  533. data/vendor/zstd/tests/fuzz/block_round_trip.c +103 -0
  534. data/vendor/zstd/tests/fuzz/decompress_cross_format.c +130 -0
  535. data/vendor/zstd/tests/fuzz/decompress_dstSize_tooSmall.c +74 -0
  536. data/vendor/zstd/tests/fuzz/dictionary_decompress.c +77 -0
  537. data/vendor/zstd/tests/fuzz/dictionary_loader.c +106 -0
  538. data/vendor/zstd/tests/fuzz/dictionary_round_trip.c +155 -0
  539. data/vendor/zstd/tests/fuzz/dictionary_stream_round_trip.c +209 -0
  540. data/vendor/zstd/tests/fuzz/fse_read_ncount.c +100 -0
  541. data/vendor/zstd/tests/fuzz/fuzz.h +57 -0
  542. data/vendor/zstd/tests/fuzz/fuzz.py +910 -0
  543. data/vendor/zstd/tests/fuzz/fuzz_data_producer.c +95 -0
  544. data/vendor/zstd/tests/fuzz/fuzz_data_producer.h +66 -0
  545. data/vendor/zstd/tests/fuzz/fuzz_helpers.c +47 -0
  546. data/vendor/zstd/tests/fuzz/fuzz_helpers.h +82 -0
  547. data/vendor/zstd/tests/fuzz/fuzz_third_party_seq_prod.h +116 -0
  548. data/vendor/zstd/tests/fuzz/generate_sequences.c +88 -0
  549. data/vendor/zstd/tests/fuzz/huf_decompress.c +68 -0
  550. data/vendor/zstd/tests/fuzz/huf_round_trip.c +137 -0
  551. data/vendor/zstd/tests/fuzz/raw_dictionary_round_trip.c +119 -0
  552. data/vendor/zstd/tests/fuzz/regression_driver.c +90 -0
  553. data/vendor/zstd/tests/fuzz/seekable_roundtrip.c +88 -0
  554. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/Makefile +16 -0
  555. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/README.md +12 -0
  556. data/vendor/zstd/tests/fuzz/seq_prod_fuzz_example/example_seq_prod.c +52 -0
  557. data/vendor/zstd/tests/fuzz/sequence_compression_api.c +452 -0
  558. data/vendor/zstd/tests/fuzz/simple_compress.c +60 -0
  559. data/vendor/zstd/tests/fuzz/simple_decompress.c +59 -0
  560. data/vendor/zstd/tests/fuzz/simple_round_trip.c +182 -0
  561. data/vendor/zstd/tests/fuzz/stream_decompress.c +119 -0
  562. data/vendor/zstd/tests/fuzz/stream_round_trip.c +218 -0
  563. data/vendor/zstd/tests/fuzz/zstd_frame_info.c +43 -0
  564. data/vendor/zstd/tests/fuzz/zstd_helpers.c +208 -0
  565. data/vendor/zstd/tests/fuzz/zstd_helpers.h +56 -0
  566. data/vendor/zstd/tests/fuzzer.c +5482 -0
  567. data/vendor/zstd/tests/golden-compression/PR-3517-block-splitter-corruption-test +1 -0
  568. data/vendor/zstd/tests/golden-compression/http +1 -0
  569. data/vendor/zstd/tests/golden-compression/huffman-compressed-larger +0 -0
  570. data/vendor/zstd/tests/golden-compression/large-literal-and-match-lengths +0 -0
  571. data/vendor/zstd/tests/golden-decompression/block-128k.zst +0 -0
  572. data/vendor/zstd/tests/golden-decompression/empty-block.zst +0 -0
  573. data/vendor/zstd/tests/golden-decompression/rle-first-block.zst +0 -0
  574. data/vendor/zstd/tests/golden-decompression/zeroSeq_2B.zst +0 -0
  575. data/vendor/zstd/tests/golden-decompression-errors/off0.bin.zst +0 -0
  576. data/vendor/zstd/tests/golden-decompression-errors/truncated_huff_state.zst +0 -0
  577. data/vendor/zstd/tests/golden-decompression-errors/zeroSeq_extraneous.zst +0 -0
  578. data/vendor/zstd/tests/golden-dictionaries/http-dict-missing-symbols +0 -0
  579. data/vendor/zstd/tests/gzip/Makefile +45 -0
  580. data/vendor/zstd/tests/gzip/gzip-env.sh +46 -0
  581. data/vendor/zstd/tests/gzip/helin-segv.sh +31 -0
  582. data/vendor/zstd/tests/gzip/help-version.sh +270 -0
  583. data/vendor/zstd/tests/gzip/hufts-segv.gz +0 -0
  584. data/vendor/zstd/tests/gzip/hufts.sh +34 -0
  585. data/vendor/zstd/tests/gzip/init.cfg +5 -0
  586. data/vendor/zstd/tests/gzip/init.sh +616 -0
  587. data/vendor/zstd/tests/gzip/keep.sh +51 -0
  588. data/vendor/zstd/tests/gzip/list.sh +31 -0
  589. data/vendor/zstd/tests/gzip/memcpy-abuse.sh +34 -0
  590. data/vendor/zstd/tests/gzip/mixed.sh +68 -0
  591. data/vendor/zstd/tests/gzip/null-suffix-clobber.sh +35 -0
  592. data/vendor/zstd/tests/gzip/stdin.sh +31 -0
  593. data/vendor/zstd/tests/gzip/test-driver.sh +150 -0
  594. data/vendor/zstd/tests/gzip/trailing-nul.sh +37 -0
  595. data/vendor/zstd/tests/gzip/unpack-invalid.sh +36 -0
  596. data/vendor/zstd/tests/gzip/z-suffix.sh +30 -0
  597. data/vendor/zstd/tests/gzip/zdiff.sh +48 -0
  598. data/vendor/zstd/tests/gzip/zgrep-context.sh +47 -0
  599. data/vendor/zstd/tests/gzip/zgrep-f.sh +43 -0
  600. data/vendor/zstd/tests/gzip/zgrep-signal.sh +64 -0
  601. data/vendor/zstd/tests/gzip/znew-k.sh +40 -0
  602. data/vendor/zstd/tests/invalidDictionaries.c +61 -0
  603. data/vendor/zstd/tests/largeDictionary.c +131 -0
  604. data/vendor/zstd/tests/legacy.c +262 -0
  605. data/vendor/zstd/tests/libzstd_builds.sh +104 -0
  606. data/vendor/zstd/tests/longmatch.c +123 -0
  607. data/vendor/zstd/tests/loremOut.c +50 -0
  608. data/vendor/zstd/tests/loremOut.h +15 -0
  609. data/vendor/zstd/tests/paramgrill.c +2965 -0
  610. data/vendor/zstd/tests/playTests.sh +1926 -0
  611. data/vendor/zstd/tests/poolTests.c +271 -0
  612. data/vendor/zstd/tests/rateLimiter.py +41 -0
  613. data/vendor/zstd/tests/regression/Makefile +60 -0
  614. data/vendor/zstd/tests/regression/README.md +28 -0
  615. data/vendor/zstd/tests/regression/config.c +404 -0
  616. data/vendor/zstd/tests/regression/config.h +91 -0
  617. data/vendor/zstd/tests/regression/data.c +631 -0
  618. data/vendor/zstd/tests/regression/data.h +121 -0
  619. data/vendor/zstd/tests/regression/levels.h +59 -0
  620. data/vendor/zstd/tests/regression/method.c +701 -0
  621. data/vendor/zstd/tests/regression/method.h +65 -0
  622. data/vendor/zstd/tests/regression/result.c +30 -0
  623. data/vendor/zstd/tests/regression/result.h +103 -0
  624. data/vendor/zstd/tests/regression/results.csv +1480 -0
  625. data/vendor/zstd/tests/regression/test.c +362 -0
  626. data/vendor/zstd/tests/roundTripCrash.c +241 -0
  627. data/vendor/zstd/tests/seqgen.c +260 -0
  628. data/vendor/zstd/tests/seqgen.h +58 -0
  629. data/vendor/zstd/tests/test-license.py +156 -0
  630. data/vendor/zstd/tests/test-variants.sh +115 -0
  631. data/vendor/zstd/tests/test-zstd-versions.py +308 -0
  632. data/vendor/zstd/tests/test_process_substitution.bash +92 -0
  633. data/vendor/zstd/tests/zstreamtest.c +3467 -0
  634. data/vendor/zstd/zlibWrapper/BUCK +22 -0
  635. data/vendor/zstd/zlibWrapper/Makefile +120 -0
  636. data/vendor/zstd/zlibWrapper/README.md +163 -0
  637. data/vendor/zstd/zlibWrapper/examples/example.c +598 -0
  638. data/vendor/zstd/zlibWrapper/examples/example_original.c +599 -0
  639. data/vendor/zstd/zlibWrapper/examples/fitblk.c +254 -0
  640. data/vendor/zstd/zlibWrapper/examples/fitblk_original.c +233 -0
  641. data/vendor/zstd/zlibWrapper/examples/minigzip.c +605 -0
  642. data/vendor/zstd/zlibWrapper/examples/zwrapbench.c +1018 -0
  643. data/vendor/zstd/zlibWrapper/gzclose.c +26 -0
  644. data/vendor/zstd/zlibWrapper/gzcompatibility.h +68 -0
  645. data/vendor/zstd/zlibWrapper/gzguts.h +229 -0
  646. data/vendor/zstd/zlibWrapper/gzlib.c +587 -0
  647. data/vendor/zstd/zlibWrapper/gzread.c +637 -0
  648. data/vendor/zstd/zlibWrapper/gzwrite.c +632 -0
  649. data/vendor/zstd/zlibWrapper/zstd_zlibwrapper.c +1200 -0
  650. data/vendor/zstd/zlibWrapper/zstd_zlibwrapper.h +91 -0
  651. metadata +738 -0
@@ -0,0 +1,1270 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under both the BSD-style license (found in the
6
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
+ * in the COPYING file in the root directory of this source tree).
8
+ * You may select, at your option, one of the above-listed licenses.
9
+ */
10
+
11
+ /* **************************************
12
+ * Tuning parameters
13
+ ****************************************/
14
+ #ifndef BMK_TIMETEST_DEFAULT_S /* default minimum time per test */
15
+ # define BMK_TIMETEST_DEFAULT_S 3
16
+ #endif
17
+
18
+ /* *************************************
19
+ * Includes
20
+ ***************************************/
21
+ /* this must be included first */
22
+ #include "platform.h" /* Large Files support, compiler specifics */
23
+
24
+ /* then following system includes */
25
+ #include <assert.h> /* assert */
26
+ #include <errno.h>
27
+ #include <stdio.h> /* fprintf, fopen */
28
+ #include <stdlib.h> /* malloc, free */
29
+ #include <string.h> /* memset, strerror */
30
+ #include "util.h" /* UTIL_getFileSize, UTIL_sleep */
31
+ #include "../lib/common/mem.h"
32
+ #include "benchfn.h"
33
+ #include "timefn.h" /* UTIL_time_t */
34
+ #ifndef ZSTD_STATIC_LINKING_ONLY
35
+ # define ZSTD_STATIC_LINKING_ONLY
36
+ #endif
37
+ #include "../lib/zstd.h"
38
+ #include "datagen.h" /* RDG_genBuffer */
39
+ #include "lorem.h" /* LOREM_genBuffer */
40
+ #ifndef XXH_INLINE_ALL
41
+ # define XXH_INLINE_ALL
42
+ #endif
43
+ #include "../lib/common/xxhash.h"
44
+ #include "../lib/zstd_errors.h"
45
+ #include "benchzstd.h"
46
+
47
+ /* *************************************
48
+ * Constants
49
+ ***************************************/
50
+ #ifndef ZSTD_GIT_COMMIT
51
+ # define ZSTD_GIT_COMMIT_STRING ""
52
+ #else
53
+ # define ZSTD_GIT_COMMIT_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_GIT_COMMIT)
54
+ #endif
55
+
56
+ #define TIMELOOP_MICROSEC (1 * 1000000ULL) /* 1 second */
57
+ #define TIMELOOP_NANOSEC (1 * 1000000000ULL) /* 1 second */
58
+ #define ACTIVEPERIOD_MICROSEC (70 * TIMELOOP_MICROSEC) /* 70 seconds */
59
+ #define COOLPERIOD_SEC 10
60
+
61
+ #define KB *(1 << 10)
62
+ #define MB *(1 << 20)
63
+ #define GB *(1U << 30)
64
+
65
+ #define BMK_RUNTEST_DEFAULT_MS 1000
66
+
67
+ static const size_t maxMemory = (sizeof(size_t) == 4)
68
+ ?
69
+ /* 32-bit */ (2 GB - 64 MB)
70
+ :
71
+ /* 64-bit */ (size_t)(1ULL << ((sizeof(size_t) * 8) - 31));
72
+
73
+ /* *************************************
74
+ * console display
75
+ ***************************************/
76
+ #define DISPLAY(...) \
77
+ { \
78
+ fprintf(stderr, __VA_ARGS__); \
79
+ fflush(NULL); \
80
+ }
81
+ #define DISPLAYLEVEL(l, ...) \
82
+ if (displayLevel >= l) { \
83
+ DISPLAY(__VA_ARGS__); \
84
+ }
85
+ /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : +
86
+ * progression; 4 : + information */
87
+ #define OUTPUT(...) \
88
+ { \
89
+ fprintf(stdout, __VA_ARGS__); \
90
+ fflush(NULL); \
91
+ }
92
+ #define OUTPUTLEVEL(l, ...) \
93
+ if (displayLevel >= l) { \
94
+ OUTPUT(__VA_ARGS__); \
95
+ }
96
+
97
+ /* *************************************
98
+ * Exceptions
99
+ ***************************************/
100
+ #ifndef DEBUG
101
+ # define DEBUG 0
102
+ #endif
103
+ #define DEBUGOUTPUT(...) \
104
+ { \
105
+ if (DEBUG) \
106
+ DISPLAY(__VA_ARGS__); \
107
+ }
108
+
109
+ #define RETURN_ERROR_INT(errorNum, ...) \
110
+ { \
111
+ DEBUGOUTPUT("%s: %i: \n", __FILE__, __LINE__); \
112
+ DISPLAYLEVEL(1, "Error %i : ", errorNum); \
113
+ DISPLAYLEVEL(1, __VA_ARGS__); \
114
+ DISPLAYLEVEL(1, " \n"); \
115
+ return errorNum; \
116
+ }
117
+
118
+ #define CHECK_Z(zf) \
119
+ { \
120
+ size_t const zerr = zf; \
121
+ if (ZSTD_isError(zerr)) { \
122
+ DEBUGOUTPUT("%s: %i: \n", __FILE__, __LINE__); \
123
+ DISPLAY("Error : "); \
124
+ DISPLAY("%s failed : %s", #zf, ZSTD_getErrorName(zerr)); \
125
+ DISPLAY(" \n"); \
126
+ exit(1); \
127
+ } \
128
+ }
129
+
130
+ #define RETURN_ERROR(errorNum, retType, ...) \
131
+ { \
132
+ retType r; \
133
+ memset(&r, 0, sizeof(retType)); \
134
+ DEBUGOUTPUT("%s: %i: \n", __FILE__, __LINE__); \
135
+ DISPLAYLEVEL(1, "Error %i : ", errorNum); \
136
+ DISPLAYLEVEL(1, __VA_ARGS__); \
137
+ DISPLAYLEVEL(1, " \n"); \
138
+ r.tag = errorNum; \
139
+ return r; \
140
+ }
141
+
142
+ static size_t uintSize(unsigned value)
143
+ {
144
+ size_t size = 1;
145
+ while (value >= 10) {
146
+ size++;
147
+ value /= 10;
148
+ }
149
+ return size;
150
+ }
151
+
152
+ /* Note: presume @buffer is large enough */
153
+ static void writeUint_varLen(char* buffer, size_t capacity, unsigned value)
154
+ {
155
+ int endPos = (int)uintSize(value) - 1;
156
+ assert(uintSize(value) >= 1);
157
+ assert(uintSize(value) < capacity); (void)capacity;
158
+ while (endPos >= 0) {
159
+ char c = '0' + (char)(value % 10);
160
+ buffer[endPos--] = c;
161
+ value /= 10;
162
+ }
163
+ }
164
+
165
+ /* replacement for snprintf(), which is not supported by C89.
166
+ * sprintf() would be the supported one, but it's labelled unsafe:
167
+ * modern static analyzer will flag sprintf() as dangerous, making it unusable.
168
+ * formatString_u() replaces snprintf() for the specific case where there is only one %u argument */
169
+ static int formatString_u(char* buffer, size_t buffer_size, const char* formatString, unsigned int value)
170
+ {
171
+ size_t const valueSize = uintSize(value);
172
+ size_t written = 0;
173
+ int i;
174
+
175
+ for (i = 0; formatString[i] != '\0' && written < buffer_size - 1; i++) {
176
+ if (formatString[i] != '%') {
177
+ buffer[written++] = formatString[i];
178
+ continue;
179
+ }
180
+
181
+ i++;
182
+ if (formatString[i] == 'u') {
183
+ if (written + valueSize >= buffer_size) abort(); /* buffer not large enough */
184
+ writeUint_varLen(buffer + written, buffer_size - written, value);
185
+ written += valueSize;
186
+ } else if (formatString[i] == '%') { /* Check for escaped percent sign */
187
+ buffer[written++] = '%';
188
+ } else {
189
+ abort(); /* unsupported format */
190
+ }
191
+ }
192
+
193
+ if (written < buffer_size) {
194
+ buffer[written] = '\0';
195
+ } else {
196
+ abort(); /* buffer not large enough */
197
+ }
198
+
199
+ return (int)written;
200
+ }
201
+
202
+ /* *************************************
203
+ * Benchmark Parameters
204
+ ***************************************/
205
+
206
+ BMK_advancedParams_t BMK_initAdvancedParams(void)
207
+ {
208
+ BMK_advancedParams_t const res = {
209
+ BMK_both, /* mode */
210
+ BMK_TIMETEST_DEFAULT_S, /* nbSeconds */
211
+ 0, /* chunkSizeMax */
212
+ 0, /* targetCBlockSize */
213
+ 0, /* nbWorkers */
214
+ 0, /* realTime */
215
+ 0, /* additionalParam */
216
+ 0, /* ldmFlag */
217
+ 0, /* ldmMinMatch */
218
+ 0, /* ldmHashLog */
219
+ 0, /* ldmBuckSizeLog */
220
+ 0, /* ldmHashRateLog */
221
+ ZSTD_ps_auto, /* literalCompressionMode */
222
+ 0 /* useRowMatchFinder */
223
+ };
224
+ return res;
225
+ }
226
+
227
+ /* ********************************************************
228
+ * Bench functions
229
+ **********************************************************/
230
+ #undef MIN
231
+ #undef MAX
232
+ #define MIN(a, b) ((a) < (b) ? (a) : (b))
233
+ #define MAX(a, b) ((a) > (b) ? (a) : (b))
234
+
235
+ static void BMK_initCCtx(
236
+ ZSTD_CCtx* ctx,
237
+ const void* dictBuffer,
238
+ size_t dictBufferSize,
239
+ int cLevel,
240
+ const ZSTD_compressionParameters* comprParams,
241
+ const BMK_advancedParams_t* adv)
242
+ {
243
+ ZSTD_CCtx_reset(ctx, ZSTD_reset_session_and_parameters);
244
+ if (adv->nbWorkers == 1) {
245
+ CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_nbWorkers, 0));
246
+ } else {
247
+ CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_nbWorkers, adv->nbWorkers));
248
+ }
249
+ CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_compressionLevel, cLevel));
250
+ CHECK_Z(ZSTD_CCtx_setParameter(
251
+ ctx, ZSTD_c_useRowMatchFinder, adv->useRowMatchFinder));
252
+ CHECK_Z(ZSTD_CCtx_setParameter(
253
+ ctx, ZSTD_c_enableLongDistanceMatching, adv->ldmFlag));
254
+ CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmMinMatch, adv->ldmMinMatch));
255
+ CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmHashLog, adv->ldmHashLog));
256
+ CHECK_Z(ZSTD_CCtx_setParameter(
257
+ ctx, ZSTD_c_ldmBucketSizeLog, adv->ldmBucketSizeLog));
258
+ CHECK_Z(ZSTD_CCtx_setParameter(
259
+ ctx, ZSTD_c_ldmHashRateLog, adv->ldmHashRateLog));
260
+ CHECK_Z(ZSTD_CCtx_setParameter(
261
+ ctx, ZSTD_c_windowLog, (int)comprParams->windowLog));
262
+ CHECK_Z(ZSTD_CCtx_setParameter(
263
+ ctx, ZSTD_c_hashLog, (int)comprParams->hashLog));
264
+ CHECK_Z(ZSTD_CCtx_setParameter(
265
+ ctx, ZSTD_c_chainLog, (int)comprParams->chainLog));
266
+ CHECK_Z(ZSTD_CCtx_setParameter(
267
+ ctx, ZSTD_c_searchLog, (int)comprParams->searchLog));
268
+ CHECK_Z(ZSTD_CCtx_setParameter(
269
+ ctx, ZSTD_c_minMatch, (int)comprParams->minMatch));
270
+ CHECK_Z(ZSTD_CCtx_setParameter(
271
+ ctx, ZSTD_c_targetLength, (int)comprParams->targetLength));
272
+ CHECK_Z(ZSTD_CCtx_setParameter(
273
+ ctx,
274
+ ZSTD_c_literalCompressionMode,
275
+ (int)adv->literalCompressionMode));
276
+ CHECK_Z(ZSTD_CCtx_setParameter(
277
+ ctx, ZSTD_c_strategy, (int)comprParams->strategy));
278
+ CHECK_Z(ZSTD_CCtx_setParameter(
279
+ ctx, ZSTD_c_targetCBlockSize, (int)adv->targetCBlockSize));
280
+ CHECK_Z(ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize));
281
+ }
282
+
283
+ static void
284
+ BMK_initDCtx(ZSTD_DCtx* dctx, const void* dictBuffer, size_t dictBufferSize)
285
+ {
286
+ CHECK_Z(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_and_parameters));
287
+ CHECK_Z(ZSTD_DCtx_loadDictionary(dctx, dictBuffer, dictBufferSize));
288
+ }
289
+
290
+ typedef struct {
291
+ ZSTD_CCtx* cctx;
292
+ const void* dictBuffer;
293
+ size_t dictBufferSize;
294
+ int cLevel;
295
+ const ZSTD_compressionParameters* comprParams;
296
+ const BMK_advancedParams_t* adv;
297
+ } BMK_initCCtxArgs;
298
+
299
+ static size_t local_initCCtx(void* payload)
300
+ {
301
+ BMK_initCCtxArgs* ag = (BMK_initCCtxArgs*)payload;
302
+ BMK_initCCtx(
303
+ ag->cctx,
304
+ ag->dictBuffer,
305
+ ag->dictBufferSize,
306
+ ag->cLevel,
307
+ ag->comprParams,
308
+ ag->adv);
309
+ return 0;
310
+ }
311
+
312
+ typedef struct {
313
+ ZSTD_DCtx* dctx;
314
+ const void* dictBuffer;
315
+ size_t dictBufferSize;
316
+ } BMK_initDCtxArgs;
317
+
318
+ static size_t local_initDCtx(void* payload)
319
+ {
320
+ BMK_initDCtxArgs* ag = (BMK_initDCtxArgs*)payload;
321
+ BMK_initDCtx(ag->dctx, ag->dictBuffer, ag->dictBufferSize);
322
+ return 0;
323
+ }
324
+
325
+ /* `addArgs` is the context */
326
+ static size_t local_defaultCompress(
327
+ const void* srcBuffer,
328
+ size_t srcSize,
329
+ void* dstBuffer,
330
+ size_t dstSize,
331
+ void* addArgs)
332
+ {
333
+ ZSTD_CCtx* const cctx = (ZSTD_CCtx*)addArgs;
334
+ return ZSTD_compress2(cctx, dstBuffer, dstSize, srcBuffer, srcSize);
335
+ }
336
+
337
+ /* `addArgs` is the context */
338
+ static size_t local_defaultDecompress(
339
+ const void* srcBuffer,
340
+ size_t srcSize,
341
+ void* dstBuffer,
342
+ size_t dstCapacity,
343
+ void* addArgs)
344
+ {
345
+ size_t moreToFlush = 1;
346
+ ZSTD_DCtx* const dctx = (ZSTD_DCtx*)addArgs;
347
+ ZSTD_inBuffer in;
348
+ ZSTD_outBuffer out;
349
+ in.src = srcBuffer;
350
+ in.size = srcSize;
351
+ in.pos = 0;
352
+ out.dst = dstBuffer;
353
+ out.size = dstCapacity;
354
+ out.pos = 0;
355
+ while (moreToFlush) {
356
+ if (out.pos == out.size) {
357
+ return (size_t)-ZSTD_error_dstSize_tooSmall;
358
+ }
359
+ moreToFlush = ZSTD_decompressStream(dctx, &out, &in);
360
+ if (ZSTD_isError(moreToFlush)) {
361
+ return moreToFlush;
362
+ }
363
+ }
364
+ return out.pos;
365
+ }
366
+
367
+ /* ================================================================= */
368
+ /* Benchmark Zstandard, mem-to-mem scenarios */
369
+ /* ================================================================= */
370
+
371
+ int BMK_isSuccessful_benchOutcome(BMK_benchOutcome_t outcome)
372
+ {
373
+ return outcome.tag == 0;
374
+ }
375
+
376
+ BMK_benchResult_t BMK_extract_benchResult(BMK_benchOutcome_t outcome)
377
+ {
378
+ assert(outcome.tag == 0);
379
+ return outcome.internal_never_use_directly;
380
+ }
381
+
382
+ static BMK_benchOutcome_t BMK_benchOutcome_error(void)
383
+ {
384
+ BMK_benchOutcome_t b;
385
+ memset(&b, 0, sizeof(b));
386
+ b.tag = 1;
387
+ return b;
388
+ }
389
+
390
+ static BMK_benchOutcome_t BMK_benchOutcome_setValidResult(
391
+ BMK_benchResult_t result)
392
+ {
393
+ BMK_benchOutcome_t b;
394
+ b.tag = 0;
395
+ b.internal_never_use_directly = result;
396
+ return b;
397
+ }
398
+
399
+ /* benchMem with no allocation */
400
+ static BMK_benchOutcome_t BMK_benchMemAdvancedNoAlloc(
401
+ const void** srcPtrs,
402
+ size_t* srcSizes,
403
+ void** cPtrs,
404
+ size_t* cCapacities,
405
+ size_t* cSizes,
406
+ void** resPtrs,
407
+ size_t* resSizes,
408
+ void** resultBufferPtr,
409
+ void* compressedBuffer,
410
+ size_t maxCompressedSize,
411
+ BMK_timedFnState_t* timeStateCompress,
412
+ BMK_timedFnState_t* timeStateDecompress,
413
+
414
+ const void* srcBuffer,
415
+ size_t srcSize,
416
+ const size_t* fileSizes,
417
+ unsigned nbFiles,
418
+ const int cLevel,
419
+ const ZSTD_compressionParameters* comprParams,
420
+ const void* dictBuffer,
421
+ size_t dictBufferSize,
422
+ ZSTD_CCtx* cctx,
423
+ ZSTD_DCtx* dctx,
424
+ int displayLevel,
425
+ const char* displayName,
426
+ const BMK_advancedParams_t* adv)
427
+ {
428
+ size_t const chunkSizeMax =
429
+ ((adv->chunkSizeMax >= 32 && (adv->mode != BMK_decodeOnly))
430
+ ? adv->chunkSizeMax
431
+ : srcSize)
432
+ + (!srcSize); /* avoid div by 0 */
433
+ BMK_benchResult_t benchResult;
434
+ size_t const loadedCompressedSize = srcSize;
435
+ size_t cSize = 0;
436
+ double ratio = 0.;
437
+ U32 nbChunks = 0;
438
+
439
+ assert(cctx != NULL);
440
+ assert(dctx != NULL);
441
+
442
+ /* init */
443
+ memset(&benchResult, 0, sizeof(benchResult));
444
+ if (strlen(displayName) > 17)
445
+ displayName +=
446
+ strlen(displayName) - 17; /* display last 17 characters */
447
+ if (adv->mode == BMK_decodeOnly) {
448
+ /* benchmark only decompression : source must be already compressed */
449
+ const char* srcPtr = (const char*)srcBuffer;
450
+ U64 totalDSize64 = 0;
451
+ U32 fileNb;
452
+ for (fileNb = 0; fileNb < nbFiles; fileNb++) {
453
+ U64 const fSize64 =
454
+ ZSTD_findDecompressedSize(srcPtr, fileSizes[fileNb]);
455
+ if (fSize64 == ZSTD_CONTENTSIZE_UNKNOWN) {
456
+ RETURN_ERROR(
457
+ 32,
458
+ BMK_benchOutcome_t,
459
+ "Decompressed size cannot be determined: cannot benchmark");
460
+ }
461
+ if (fSize64 == ZSTD_CONTENTSIZE_ERROR) {
462
+ RETURN_ERROR(
463
+ 32,
464
+ BMK_benchOutcome_t,
465
+ "Error while trying to assess decompressed size: data may be invalid");
466
+ }
467
+ totalDSize64 += fSize64;
468
+ srcPtr += fileSizes[fileNb];
469
+ }
470
+ {
471
+ size_t const decodedSize = (size_t)totalDSize64;
472
+ assert((U64)decodedSize == totalDSize64); /* check overflow */
473
+ free(*resultBufferPtr);
474
+ if (totalDSize64 > decodedSize) { /* size_t overflow */
475
+ RETURN_ERROR(
476
+ 32,
477
+ BMK_benchOutcome_t,
478
+ "decompressed size is too large for local system");
479
+ }
480
+ *resultBufferPtr = malloc(decodedSize);
481
+ if (!(*resultBufferPtr)) {
482
+ RETURN_ERROR(
483
+ 33,
484
+ BMK_benchOutcome_t,
485
+ "allocation error: not enough memory");
486
+ }
487
+ cSize = srcSize;
488
+ srcSize = decodedSize;
489
+ ratio = (double)srcSize / (double)cSize;
490
+ }
491
+ }
492
+
493
+ /* Init data chunks */
494
+ {
495
+ const char* srcPtr = (const char*)srcBuffer;
496
+ char* cPtr = (char*)compressedBuffer;
497
+ char* resPtr = (char*)(*resultBufferPtr);
498
+ U32 fileNb, chunkID;
499
+ for (chunkID = 0, fileNb = 0; fileNb < nbFiles; fileNb++) {
500
+ size_t remaining = fileSizes[fileNb];
501
+ U32 const nbChunksforThisFile = (adv->mode == BMK_decodeOnly)
502
+ ? 1
503
+ : (U32)((remaining + (chunkSizeMax - 1)) / chunkSizeMax);
504
+ U32 const chunkIdEnd = chunkID + nbChunksforThisFile;
505
+ for (; chunkID < chunkIdEnd; chunkID++) {
506
+ size_t const chunkSize = MIN(remaining, chunkSizeMax);
507
+ srcPtrs[chunkID] = srcPtr;
508
+ srcSizes[chunkID] = chunkSize;
509
+ cPtrs[chunkID] = cPtr;
510
+ cCapacities[chunkID] = (adv->mode == BMK_decodeOnly)
511
+ ? chunkSize
512
+ : ZSTD_compressBound(chunkSize);
513
+ resPtrs[chunkID] = resPtr;
514
+ resSizes[chunkID] = (adv->mode == BMK_decodeOnly)
515
+ ? (size_t)ZSTD_findDecompressedSize(
516
+ srcPtr, chunkSize)
517
+ : chunkSize;
518
+ srcPtr += chunkSize;
519
+ cPtr += cCapacities[chunkID];
520
+ resPtr += chunkSize;
521
+ remaining -= chunkSize;
522
+ if (adv->mode == BMK_decodeOnly) {
523
+ cSizes[chunkID] = chunkSize;
524
+ benchResult.cSize = chunkSize;
525
+ }
526
+ }
527
+ }
528
+ nbChunks = chunkID;
529
+ }
530
+
531
+ /* warming up `compressedBuffer` */
532
+ if (adv->mode == BMK_decodeOnly) {
533
+ memcpy(compressedBuffer, srcBuffer, loadedCompressedSize);
534
+ } else {
535
+ RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
536
+ }
537
+
538
+ if (!UTIL_support_MT_measurements() && adv->nbWorkers > 1) {
539
+ OUTPUTLEVEL(
540
+ 2,
541
+ "Warning : time measurements may be incorrect in multithreading mode... \n")
542
+ }
543
+
544
+ /* Bench */
545
+ {
546
+ U64 const crcOrig = (adv->mode == BMK_decodeOnly)
547
+ ? 0
548
+ : XXH64(srcBuffer, srcSize, 0);
549
+ #define NB_MARKS 4
550
+ const char* marks[NB_MARKS] = { " |", " /", " =", " \\" };
551
+ U32 markNb = 0;
552
+ int compressionCompleted = (adv->mode == BMK_decodeOnly);
553
+ int decompressionCompleted = (adv->mode == BMK_compressOnly);
554
+ BMK_benchParams_t cbp, dbp;
555
+ BMK_initCCtxArgs cctxprep;
556
+ BMK_initDCtxArgs dctxprep;
557
+
558
+ cbp.benchFn = local_defaultCompress; /* ZSTD_compress2 */
559
+ cbp.benchPayload = cctx;
560
+ cbp.initFn = local_initCCtx; /* BMK_initCCtx */
561
+ cbp.initPayload = &cctxprep;
562
+ cbp.errorFn = ZSTD_isError;
563
+ cbp.blockCount = nbChunks;
564
+ cbp.srcBuffers = srcPtrs;
565
+ cbp.srcSizes = srcSizes;
566
+ cbp.dstBuffers = cPtrs;
567
+ cbp.dstCapacities = cCapacities;
568
+ cbp.blockResults = cSizes;
569
+
570
+ cctxprep.cctx = cctx;
571
+ cctxprep.dictBuffer = dictBuffer;
572
+ cctxprep.dictBufferSize = dictBufferSize;
573
+ cctxprep.cLevel = cLevel;
574
+ cctxprep.comprParams = comprParams;
575
+ cctxprep.adv = adv;
576
+
577
+ dbp.benchFn = local_defaultDecompress;
578
+ dbp.benchPayload = dctx;
579
+ dbp.initFn = local_initDCtx;
580
+ dbp.initPayload = &dctxprep;
581
+ dbp.errorFn = ZSTD_isError;
582
+ dbp.blockCount = nbChunks;
583
+ dbp.srcBuffers = (const void* const*)cPtrs;
584
+ dbp.srcSizes = cSizes;
585
+ dbp.dstBuffers = resPtrs;
586
+ dbp.dstCapacities = resSizes;
587
+ dbp.blockResults = NULL;
588
+
589
+ dctxprep.dctx = dctx;
590
+ dctxprep.dictBuffer = dictBuffer;
591
+ dctxprep.dictBufferSize = dictBufferSize;
592
+
593
+ OUTPUTLEVEL(2, "\r%70s\r", ""); /* blank line */
594
+ assert(srcSize < UINT_MAX);
595
+ OUTPUTLEVEL(
596
+ 2,
597
+ "%2s-%-17.17s :%10u -> \r",
598
+ marks[markNb],
599
+ displayName,
600
+ (unsigned)srcSize);
601
+
602
+ while (!(compressionCompleted && decompressionCompleted)) {
603
+ if (!compressionCompleted) {
604
+ BMK_runOutcome_t const cOutcome =
605
+ BMK_benchTimedFn(timeStateCompress, cbp);
606
+
607
+ if (!BMK_isSuccessful_runOutcome(cOutcome)) {
608
+ RETURN_ERROR(30, BMK_benchOutcome_t, "compression error");
609
+ }
610
+
611
+ {
612
+ BMK_runTime_t const cResult = BMK_extract_runTime(cOutcome);
613
+ cSize = cResult.sumOfReturn;
614
+ ratio = (double)srcSize / (double)cSize;
615
+ {
616
+ BMK_benchResult_t newResult;
617
+ newResult.cSpeed =
618
+ (U64)((double)srcSize * TIMELOOP_NANOSEC
619
+ / cResult.nanoSecPerRun);
620
+ benchResult.cSize = cSize;
621
+ if (newResult.cSpeed > benchResult.cSpeed)
622
+ benchResult.cSpeed = newResult.cSpeed;
623
+ }
624
+ }
625
+
626
+ {
627
+ int const ratioDigits = 1 + (ratio < 100.) + (ratio < 10.);
628
+ assert(cSize < UINT_MAX);
629
+ OUTPUTLEVEL(
630
+ 2,
631
+ "%2s-%-17.17s :%10u ->%10u (x%5.*f), %6.*f MB/s \r",
632
+ marks[markNb],
633
+ displayName,
634
+ (unsigned)srcSize,
635
+ (unsigned)cSize,
636
+ ratioDigits,
637
+ ratio,
638
+ benchResult.cSpeed < (10 * MB_UNIT) ? 2 : 1,
639
+ (double)benchResult.cSpeed / MB_UNIT);
640
+ }
641
+ compressionCompleted =
642
+ BMK_isCompleted_TimedFn(timeStateCompress);
643
+ }
644
+
645
+ if (!decompressionCompleted) {
646
+ BMK_runOutcome_t const dOutcome =
647
+ BMK_benchTimedFn(timeStateDecompress, dbp);
648
+
649
+ if (!BMK_isSuccessful_runOutcome(dOutcome)) {
650
+ RETURN_ERROR(30, BMK_benchOutcome_t, "decompression error");
651
+ }
652
+
653
+ {
654
+ BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome);
655
+ U64 const newDSpeed =
656
+ (U64)((double)srcSize * TIMELOOP_NANOSEC
657
+ / dResult.nanoSecPerRun);
658
+ if (newDSpeed > benchResult.dSpeed)
659
+ benchResult.dSpeed = newDSpeed;
660
+ }
661
+
662
+ {
663
+ int const ratioDigits = 1 + (ratio < 100.) + (ratio < 10.);
664
+ OUTPUTLEVEL(
665
+ 2,
666
+ "%2s-%-17.17s :%10u ->%10u (x%5.*f), %6.*f MB/s, %6.1f MB/s\r",
667
+ marks[markNb],
668
+ displayName,
669
+ (unsigned)srcSize,
670
+ (unsigned)cSize,
671
+ ratioDigits,
672
+ ratio,
673
+ benchResult.cSpeed < (10 * MB_UNIT) ? 2 : 1,
674
+ (double)benchResult.cSpeed / MB_UNIT,
675
+ (double)benchResult.dSpeed / MB_UNIT);
676
+ }
677
+ decompressionCompleted =
678
+ BMK_isCompleted_TimedFn(timeStateDecompress);
679
+ }
680
+ markNb = (markNb + 1) % NB_MARKS;
681
+ } /* while (!(compressionCompleted && decompressionCompleted)) */
682
+
683
+ /* CRC Checking */
684
+ { const BYTE* resultBuffer = (const BYTE*)(*resultBufferPtr);
685
+ U64 const crcCheck = XXH64(resultBuffer, srcSize, 0);
686
+ if ((adv->mode == BMK_both) && (crcOrig != crcCheck)) {
687
+ size_t u;
688
+ DISPLAY("!!! WARNING !!! %14s : Invalid Checksum : %x != %x \n",
689
+ displayName,
690
+ (unsigned)crcOrig,
691
+ (unsigned)crcCheck);
692
+ for (u = 0; u < srcSize; u++) {
693
+ if (((const BYTE*)srcBuffer)[u] != resultBuffer[u]) {
694
+ unsigned segNb, bNb, pos;
695
+ size_t bacc = 0;
696
+ DISPLAY("Decoding error at pos %u ", (unsigned)u);
697
+ for (segNb = 0; segNb < nbChunks; segNb++) {
698
+ if (bacc + srcSizes[segNb] > u)
699
+ break;
700
+ bacc += srcSizes[segNb];
701
+ }
702
+ pos = (U32)(u - bacc);
703
+ bNb = pos / (128 KB);
704
+ DISPLAY("(sample %u, chunk %u, pos %u) \n",
705
+ segNb,
706
+ bNb,
707
+ pos);
708
+ {
709
+ size_t const lowest = (u > 5) ? 5 : u;
710
+ size_t n;
711
+ DISPLAY("origin: ");
712
+ for (n = lowest; n > 0; n--)
713
+ DISPLAY("%02X ",
714
+ ((const BYTE*)srcBuffer)[u - n]);
715
+ DISPLAY(" :%02X: ", ((const BYTE*)srcBuffer)[u]);
716
+ for (n = 1; n < 3; n++)
717
+ DISPLAY("%02X ",
718
+ ((const BYTE*)srcBuffer)[u + n]);
719
+ DISPLAY(" \n");
720
+ DISPLAY("decode: ");
721
+ for (n = lowest; n > 0; n--)
722
+ DISPLAY("%02X ", resultBuffer[u - n]);
723
+ DISPLAY(" :%02X: ", resultBuffer[u]);
724
+ for (n = 1; n < 3; n++)
725
+ DISPLAY("%02X ", resultBuffer[u + n]);
726
+ DISPLAY(" \n");
727
+ }
728
+ break;
729
+ }
730
+ if (u == srcSize - 1) { /* should never happen */
731
+ DISPLAY("no difference detected\n");
732
+ }
733
+ } /* for (u=0; u<srcSize; u++) */
734
+ } /* if ((adv->mode == BMK_both) && (crcOrig!=crcCheck)) */
735
+ } /* CRC Checking */
736
+
737
+ if (displayLevel
738
+ == 1) { /* hidden display mode -q, used by python speed benchmark */
739
+ double const cSpeed = (double)benchResult.cSpeed / MB_UNIT;
740
+ double const dSpeed = (double)benchResult.dSpeed / MB_UNIT;
741
+ if (adv->additionalParam) {
742
+ OUTPUT("-%-3i%11i (%5.3f) %6.2f MB/s %6.1f MB/s %s (param=%d)\n",
743
+ cLevel,
744
+ (int)cSize,
745
+ ratio,
746
+ cSpeed,
747
+ dSpeed,
748
+ displayName,
749
+ adv->additionalParam);
750
+ } else {
751
+ OUTPUT("-%-3i%11i (%5.3f) %6.2f MB/s %6.1f MB/s %s\n",
752
+ cLevel,
753
+ (int)cSize,
754
+ ratio,
755
+ cSpeed,
756
+ dSpeed,
757
+ displayName);
758
+ }
759
+ }
760
+
761
+ OUTPUTLEVEL(2, "%2i#\n", cLevel);
762
+ } /* Bench */
763
+
764
+ benchResult.cMem =
765
+ (1ULL << (comprParams->windowLog)) + ZSTD_sizeof_CCtx(cctx);
766
+ return BMK_benchOutcome_setValidResult(benchResult);
767
+ }
768
+
769
+ BMK_benchOutcome_t BMK_benchMemAdvanced(
770
+ const void* srcBuffer,
771
+ size_t srcSize,
772
+ void* dstBuffer,
773
+ size_t dstCapacity,
774
+ const size_t* fileSizes,
775
+ unsigned nbFiles,
776
+ int cLevel,
777
+ const ZSTD_compressionParameters* comprParams,
778
+ const void* dictBuffer,
779
+ size_t dictBufferSize,
780
+ int displayLevel,
781
+ const char* displayName,
782
+ const BMK_advancedParams_t* adv)
783
+
784
+ {
785
+ int const dstParamsError =
786
+ !dstBuffer ^ !dstCapacity; /* must be both NULL or none */
787
+
788
+ size_t const chunkSize =
789
+ ((adv->chunkSizeMax >= 32 && (adv->mode != BMK_decodeOnly))
790
+ ? adv->chunkSizeMax
791
+ : srcSize)
792
+ + (!srcSize) /* avoid div by 0 */;
793
+ U32 const nbChunksMax =
794
+ (U32)((srcSize + (chunkSize - 1)) / chunkSize) + nbFiles;
795
+
796
+ const void** const srcPtrs =
797
+ (const void**)malloc(nbChunksMax * sizeof(void*));
798
+ size_t* const srcSizes = (size_t*)malloc(nbChunksMax * sizeof(size_t));
799
+
800
+ void** const cPtrs = (void**)malloc(nbChunksMax * sizeof(void*));
801
+ size_t* const cSizes = (size_t*)malloc(nbChunksMax * sizeof(size_t));
802
+ size_t* const cCapacities = (size_t*)malloc(nbChunksMax * sizeof(size_t));
803
+
804
+ void** const resPtrs = (void**)malloc(nbChunksMax * sizeof(void*));
805
+ size_t* const resSizes = (size_t*)malloc(nbChunksMax * sizeof(size_t));
806
+
807
+ BMK_timedFnState_t* timeStateCompress = BMK_createTimedFnState(
808
+ adv->nbSeconds * 1000, BMK_RUNTEST_DEFAULT_MS);
809
+ BMK_timedFnState_t* timeStateDecompress = BMK_createTimedFnState(
810
+ adv->nbSeconds * 1000, BMK_RUNTEST_DEFAULT_MS);
811
+
812
+ ZSTD_CCtx* const cctx = ZSTD_createCCtx();
813
+ ZSTD_DCtx* const dctx = ZSTD_createDCtx();
814
+
815
+ const size_t maxCompressedSize = dstCapacity
816
+ ? dstCapacity
817
+ : ZSTD_compressBound(srcSize) + (nbChunksMax * 1024);
818
+
819
+ void* const internalDstBuffer =
820
+ dstBuffer ? NULL : malloc(maxCompressedSize);
821
+ void* const compressedBuffer = dstBuffer ? dstBuffer : internalDstBuffer;
822
+
823
+ BMK_benchOutcome_t outcome =
824
+ BMK_benchOutcome_error(); /* error by default */
825
+
826
+ void* resultBuffer = srcSize ? malloc(srcSize) : NULL;
827
+
828
+ int const allocationincomplete = !srcPtrs || !srcSizes || !cPtrs || !cSizes
829
+ || !cCapacities || !resPtrs || !resSizes || !timeStateCompress
830
+ || !timeStateDecompress || !cctx || !dctx || !compressedBuffer
831
+ || !resultBuffer;
832
+
833
+ if (!allocationincomplete && !dstParamsError) {
834
+ outcome = BMK_benchMemAdvancedNoAlloc(
835
+ srcPtrs,
836
+ srcSizes,
837
+ cPtrs,
838
+ cCapacities,
839
+ cSizes,
840
+ resPtrs,
841
+ resSizes,
842
+ &resultBuffer,
843
+ compressedBuffer,
844
+ maxCompressedSize,
845
+ timeStateCompress,
846
+ timeStateDecompress,
847
+ srcBuffer,
848
+ srcSize,
849
+ fileSizes,
850
+ nbFiles,
851
+ cLevel,
852
+ comprParams,
853
+ dictBuffer,
854
+ dictBufferSize,
855
+ cctx,
856
+ dctx,
857
+ displayLevel,
858
+ displayName,
859
+ adv);
860
+ }
861
+
862
+ /* clean up */
863
+ BMK_freeTimedFnState(timeStateCompress);
864
+ BMK_freeTimedFnState(timeStateDecompress);
865
+
866
+ ZSTD_freeCCtx(cctx);
867
+ ZSTD_freeDCtx(dctx);
868
+
869
+ free(internalDstBuffer);
870
+ free(resultBuffer);
871
+
872
+ free((void*)srcPtrs);
873
+ free(srcSizes);
874
+ free(cPtrs);
875
+ free(cSizes);
876
+ free(cCapacities);
877
+ free(resPtrs);
878
+ free(resSizes);
879
+
880
+ if (allocationincomplete) {
881
+ RETURN_ERROR(
882
+ 31, BMK_benchOutcome_t, "allocation error : not enough memory");
883
+ }
884
+
885
+ if (dstParamsError) {
886
+ RETURN_ERROR(32, BMK_benchOutcome_t, "Dst parameters not coherent");
887
+ }
888
+ return outcome;
889
+ }
890
+
891
+ BMK_benchOutcome_t BMK_benchMem(
892
+ const void* srcBuffer,
893
+ size_t srcSize,
894
+ const size_t* fileSizes,
895
+ unsigned nbFiles,
896
+ int cLevel,
897
+ const ZSTD_compressionParameters* comprParams,
898
+ const void* dictBuffer,
899
+ size_t dictBufferSize,
900
+ int displayLevel,
901
+ const char* displayName)
902
+ {
903
+ BMK_advancedParams_t const adv = BMK_initAdvancedParams();
904
+ return BMK_benchMemAdvanced(
905
+ srcBuffer,
906
+ srcSize,
907
+ NULL,
908
+ 0,
909
+ fileSizes,
910
+ nbFiles,
911
+ cLevel,
912
+ comprParams,
913
+ dictBuffer,
914
+ dictBufferSize,
915
+ displayLevel,
916
+ displayName,
917
+ &adv);
918
+ }
919
+
920
+ /* @return: 0 on success, !0 if error */
921
+ static int BMK_benchCLevels(
922
+ const void* srcBuffer,
923
+ size_t benchedSize,
924
+ const size_t* fileSizes,
925
+ unsigned nbFiles,
926
+ int startCLevel, int endCLevel,
927
+ const ZSTD_compressionParameters* comprParams,
928
+ const void* dictBuffer,
929
+ size_t dictBufferSize,
930
+ int displayLevel,
931
+ const char* displayName,
932
+ BMK_advancedParams_t const* const adv)
933
+ {
934
+ int level;
935
+ const char* pch = strrchr(displayName, '\\'); /* Windows */
936
+ if (!pch)
937
+ pch = strrchr(displayName, '/'); /* Linux */
938
+ if (pch)
939
+ displayName = pch + 1;
940
+
941
+ if (endCLevel > ZSTD_maxCLevel()) {
942
+ DISPLAYLEVEL(1, "Invalid Compression Level \n");
943
+ return 15;
944
+ }
945
+ if (endCLevel < startCLevel) {
946
+ DISPLAYLEVEL(1, "Invalid Compression Level Range \n");
947
+ return 15;
948
+ }
949
+
950
+ if (adv->realTime) {
951
+ DISPLAYLEVEL(2, "Note : switching to real-time priority \n");
952
+ SET_REALTIME_PRIORITY;
953
+ }
954
+
955
+ if (displayLevel == 1 && !adv->additionalParam) /* --quiet mode */
956
+ OUTPUT("bench %s %s: input %u bytes, %u seconds, %u KB chunks\n",
957
+ ZSTD_VERSION_STRING,
958
+ ZSTD_GIT_COMMIT_STRING,
959
+ (unsigned)benchedSize,
960
+ adv->nbSeconds,
961
+ (unsigned)(adv->chunkSizeMax >> 10));
962
+
963
+ for (level = startCLevel; level <= endCLevel; level++) {
964
+ BMK_benchOutcome_t res = BMK_benchMemAdvanced(
965
+ srcBuffer,
966
+ benchedSize,
967
+ NULL,
968
+ 0,
969
+ fileSizes,
970
+ nbFiles,
971
+ level,
972
+ comprParams,
973
+ dictBuffer,
974
+ dictBufferSize,
975
+ displayLevel,
976
+ displayName,
977
+ adv);
978
+ if (!BMK_isSuccessful_benchOutcome(res)) return 1;
979
+ }
980
+ return 0;
981
+ }
982
+
983
+ int BMK_syntheticTest(
984
+ double compressibility,
985
+ int startingCLevel, int endCLevel,
986
+ const ZSTD_compressionParameters* compressionParams,
987
+ int displayLevel,
988
+ const BMK_advancedParams_t* adv)
989
+ {
990
+ char nameBuff[20] = { 0 };
991
+ const char* name = nameBuff;
992
+ size_t const benchedSize = adv->chunkSizeMax ? adv->chunkSizeMax : 10000000;
993
+
994
+ /* Memory allocation */
995
+ void* const srcBuffer = malloc(benchedSize);
996
+ if (!srcBuffer) {
997
+ DISPLAYLEVEL(1, "allocation error : not enough memory \n");
998
+ return 16;
999
+ }
1000
+
1001
+ /* Fill input buffer */
1002
+ if (compressibility < 0.0) {
1003
+ LOREM_genBuffer(srcBuffer, benchedSize, 0);
1004
+ name = "Lorem ipsum";
1005
+ } else {
1006
+ RDG_genBuffer(srcBuffer, benchedSize, compressibility, 0.0, 0);
1007
+ formatString_u(
1008
+ nameBuff,
1009
+ sizeof(nameBuff),
1010
+ "Synthetic %u%%",
1011
+ (unsigned)(compressibility * 100));
1012
+ }
1013
+
1014
+ /* Bench */
1015
+ { int res = BMK_benchCLevels(
1016
+ srcBuffer,
1017
+ benchedSize,
1018
+ &benchedSize,
1019
+ 1,
1020
+ startingCLevel, endCLevel,
1021
+ compressionParams,
1022
+ NULL,
1023
+ 0, /* dictionary */
1024
+ displayLevel,
1025
+ name,
1026
+ adv);
1027
+ free(srcBuffer);
1028
+ return res;
1029
+ }
1030
+ }
1031
+
1032
+ static size_t BMK_findMaxMem(U64 requiredMem)
1033
+ {
1034
+ size_t const step = 64 MB;
1035
+ BYTE* testmem = NULL;
1036
+
1037
+ requiredMem = (((requiredMem >> 26) + 1) << 26);
1038
+ requiredMem += step;
1039
+ if (requiredMem > maxMemory)
1040
+ requiredMem = maxMemory;
1041
+
1042
+ do {
1043
+ testmem = (BYTE*)malloc((size_t)requiredMem);
1044
+ requiredMem -= step;
1045
+ } while (!testmem && requiredMem > 0);
1046
+
1047
+ free(testmem);
1048
+ return (size_t)(requiredMem);
1049
+ }
1050
+
1051
+ /*! BMK_loadFiles() :
1052
+ * Loads `buffer` with content of files listed within `fileNamesTable`.
1053
+ * At most, fills `buffer` entirely. */
1054
+ static int BMK_loadFiles(
1055
+ void* buffer,
1056
+ size_t bufferSize,
1057
+ size_t* fileSizes,
1058
+ const char* const* fileNamesTable,
1059
+ unsigned nbFiles,
1060
+ int displayLevel)
1061
+ {
1062
+ size_t pos = 0, totalSize = 0;
1063
+ unsigned n;
1064
+ for (n = 0; n < nbFiles; n++) {
1065
+ const char* const filename = fileNamesTable[n];
1066
+ U64 fileSize = UTIL_getFileSize(
1067
+ filename); /* last file may be shortened */
1068
+ if (UTIL_isDirectory(filename)) {
1069
+ DISPLAYLEVEL(
1070
+ 2, "Ignoring %s directory... \n", filename);
1071
+ fileSizes[n] = 0;
1072
+ continue;
1073
+ }
1074
+ if (fileSize == UTIL_FILESIZE_UNKNOWN) {
1075
+ DISPLAYLEVEL(
1076
+ 2,
1077
+ "Cannot evaluate size of %s, ignoring ... \n",
1078
+ filename);
1079
+ fileSizes[n] = 0;
1080
+ continue;
1081
+ }
1082
+ if (fileSize > bufferSize - pos) {
1083
+ /* buffer too small - limit quantity loaded */
1084
+ fileSize = bufferSize - pos;
1085
+ nbFiles = n; /* stop after this file */
1086
+ }
1087
+
1088
+ { FILE* const f = fopen(filename, "rb");
1089
+ if (f == NULL) {
1090
+ RETURN_ERROR_INT(
1091
+ 10, "cannot open file %s", filename);
1092
+ }
1093
+ OUTPUTLEVEL(2, "Loading %s... \r", filename);
1094
+ { size_t const readSize =
1095
+ fread(((char*)buffer) + pos, 1, (size_t)fileSize, f);
1096
+ if (readSize != (size_t)fileSize) {
1097
+ fclose(f);
1098
+ RETURN_ERROR_INT(
1099
+ 11, "invalid read %s", filename);
1100
+ }
1101
+ pos += readSize;
1102
+ }
1103
+ fileSizes[n] = (size_t)fileSize;
1104
+ totalSize += (size_t)fileSize;
1105
+ fclose(f);
1106
+ }
1107
+ }
1108
+
1109
+ if (totalSize == 0)
1110
+ RETURN_ERROR_INT(12, "no data to bench");
1111
+ return 0;
1112
+ }
1113
+
1114
+ int BMK_benchFilesAdvanced(
1115
+ const char* const* fileNamesTable,
1116
+ unsigned nbFiles,
1117
+ const char* dictFileName,
1118
+ int startCLevel, int endCLevel,
1119
+ const ZSTD_compressionParameters* compressionParams,
1120
+ int displayLevel,
1121
+ const BMK_advancedParams_t* adv)
1122
+ {
1123
+ void* srcBuffer = NULL;
1124
+ size_t benchedSize;
1125
+ void* dictBuffer = NULL;
1126
+ size_t dictBufferSize = 0;
1127
+ size_t* fileSizes = NULL;
1128
+ int res = 1;
1129
+ U64 const totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
1130
+
1131
+ if (!nbFiles) {
1132
+ DISPLAYLEVEL(1, "No Files to Benchmark");
1133
+ return 13;
1134
+ }
1135
+
1136
+ if (endCLevel > ZSTD_maxCLevel()) {
1137
+ DISPLAYLEVEL(1, "Invalid Compression Level");
1138
+ return 14;
1139
+ }
1140
+
1141
+ if (totalSizeToLoad == UTIL_FILESIZE_UNKNOWN) {
1142
+ DISPLAYLEVEL(1, "Error loading files");
1143
+ return 15;
1144
+ }
1145
+
1146
+ fileSizes = (size_t*)calloc(nbFiles, sizeof(size_t));
1147
+ if (!fileSizes) {
1148
+ DISPLAYLEVEL(1, "not enough memory for fileSizes");
1149
+ return 16;
1150
+ }
1151
+
1152
+ /* Load dictionary */
1153
+ if (dictFileName != NULL) {
1154
+ U64 const dictFileSize = UTIL_getFileSize(dictFileName);
1155
+ if (dictFileSize == UTIL_FILESIZE_UNKNOWN) {
1156
+ DISPLAYLEVEL(
1157
+ 1,
1158
+ "error loading %s : %s \n",
1159
+ dictFileName,
1160
+ strerror(errno));
1161
+ free(fileSizes);
1162
+ DISPLAYLEVEL(1, "benchmark aborted");
1163
+ return 17;
1164
+ }
1165
+ if (dictFileSize > 64 MB) {
1166
+ free(fileSizes);
1167
+ DISPLAYLEVEL(1, "dictionary file %s too large", dictFileName);
1168
+ return 18;
1169
+ }
1170
+ dictBufferSize = (size_t)dictFileSize;
1171
+ dictBuffer = malloc(dictBufferSize);
1172
+ if (dictBuffer == NULL) {
1173
+ free(fileSizes);
1174
+ DISPLAYLEVEL(
1175
+ 1,
1176
+ "not enough memory for dictionary (%u bytes)",
1177
+ (unsigned)dictBufferSize);
1178
+ return 19;
1179
+ }
1180
+
1181
+ {
1182
+ int const errorCode = BMK_loadFiles(
1183
+ dictBuffer,
1184
+ dictBufferSize,
1185
+ fileSizes,
1186
+ &dictFileName /*?*/,
1187
+ 1 /*?*/,
1188
+ displayLevel);
1189
+ if (errorCode) {
1190
+ goto _cleanUp;
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ /* Memory allocation & restrictions */
1196
+ benchedSize = BMK_findMaxMem(totalSizeToLoad * 3) / 3;
1197
+ if ((U64)benchedSize > totalSizeToLoad)
1198
+ benchedSize = (size_t)totalSizeToLoad;
1199
+ if (benchedSize < totalSizeToLoad)
1200
+ DISPLAY("Not enough memory; testing %u MB only...\n",
1201
+ (unsigned)(benchedSize >> 20));
1202
+
1203
+ srcBuffer = benchedSize ? malloc(benchedSize) : NULL;
1204
+ if (!srcBuffer) {
1205
+ free(dictBuffer);
1206
+ free(fileSizes);
1207
+ DISPLAYLEVEL(1, "not enough memory for srcBuffer");
1208
+ return 20;
1209
+ }
1210
+
1211
+ /* Load input buffer */
1212
+ {
1213
+ int const errorCode = BMK_loadFiles(
1214
+ srcBuffer,
1215
+ benchedSize,
1216
+ fileSizes,
1217
+ fileNamesTable,
1218
+ nbFiles,
1219
+ displayLevel);
1220
+ if (errorCode) {
1221
+ goto _cleanUp;
1222
+ }
1223
+ }
1224
+
1225
+ /* Bench */
1226
+ {
1227
+ char mfName[20] = { 0 };
1228
+ formatString_u(mfName, sizeof(mfName), " %u files", nbFiles);
1229
+ { const char* const displayName =
1230
+ (nbFiles > 1) ? mfName : fileNamesTable[0];
1231
+ res = BMK_benchCLevels(
1232
+ srcBuffer,
1233
+ benchedSize,
1234
+ fileSizes,
1235
+ nbFiles,
1236
+ startCLevel, endCLevel,
1237
+ compressionParams,
1238
+ dictBuffer,
1239
+ dictBufferSize,
1240
+ displayLevel,
1241
+ displayName,
1242
+ adv);
1243
+ }
1244
+ }
1245
+
1246
+ _cleanUp:
1247
+ free(srcBuffer);
1248
+ free(dictBuffer);
1249
+ free(fileSizes);
1250
+ return res;
1251
+ }
1252
+
1253
+ int BMK_benchFiles(
1254
+ const char* const* fileNamesTable,
1255
+ unsigned nbFiles,
1256
+ const char* dictFileName,
1257
+ int cLevel,
1258
+ const ZSTD_compressionParameters* compressionParams,
1259
+ int displayLevel)
1260
+ {
1261
+ BMK_advancedParams_t const adv = BMK_initAdvancedParams();
1262
+ return BMK_benchFilesAdvanced(
1263
+ fileNamesTable,
1264
+ nbFiles,
1265
+ dictFileName,
1266
+ cLevel, cLevel,
1267
+ compressionParams,
1268
+ displayLevel,
1269
+ &adv);
1270
+ }