Repository navigation
Build the predefined sequence tables at compile time (Part of #118) - #123
Open
zcsizmadia wants to merge 1 commit into
Open
zcsizmadia wants to merge 1 commit into
zcsizmadia wants to merge 1 commit into
Conversation
libzstd's ZSTD_buildCTable builds the predefined LL/OF/ML FSE tables (set_basic) again for every block that uses them. On small frames most blocks do (1 KiB frames: 60-90% of the table builds), and the table build was a quarter of the time (C: FSE_buildCTable_wksp 27%). FseCTable::predefined builds them at compile time (static LL_PREDEFINED / OF_PREDEFINED / ML_PREDEFINED), and build_ctable copies the used part (copy_used: the header, 1 << tableLog next states and maxSymbolValue + 1 transforms, exactly what build writes; the predefined distributions have no zero counts, whose delta_find_state build leaves as it was). Same tables, same output. Tests: predefined equals build on the random distributions of build_matches_reference_spread (both spread paths), and copying each predefined table over a fresh, an RLE and a larger table leaves exactly what building it leaves. Workspace and portable test suites pass. EPYC 7543 (bd-au1-jz001g3v), 16 lanes, 3 rounds, 2 binary copies of each side interleaved, medians; all 12 Silesia files; output sizes identical in every case. Speed branch/main (geomean over the files): chunk L-5 L-1 L1 L3 L5 L9 L16 L19 1 KiB 1.426 1.222 1.084 1.053 1.021 1.014 1.007 1.006 4 KiB 1.055 1.017 1.009 1.006 1.005 1.003 1.002 1.002 16 KiB 1.012 1.005 1.001 1.004 1.001 1.003 1.002 1.003 64 KiB 1.001 1.002 1.003 1.005 1.002 1.002 1.003 1.001 full 1.002 1.002 1.000 1.000 0.998 0.997 Full files rerun with fresh copies: one branch copy ran sao L-1 at 0.78x with the same instruction count as the others (copy placement); fresh copies of the same file ran at main's speed. nci L5/L9 full (0.986) have identical instruction counts, cycles within the copy spread. perf stat, mozilla L-1 1 KiB: instructions 21.59G -> 15.45G, cycles 6.65G -> 5.07G, 588 -> 785 MiB/s (zrip L-1: 770 at ratio 1.743; zstd-native 1.762). Against C libzstd 1.6.0 at the same level: 1.25x on 1 KiB frames (was 1.14x), 1.11x on full files.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
libzstd's ZSTD_buildCTable builds the predefined LL/OF/ML FSE tables
(set_basic) again for every block that uses them. On small frames most
blocks do (1 KiB frames: 60-90% of the table builds), and the table
build was a quarter of the time (C: FSE_buildCTable_wksp 27%).
FseCTable::predefined builds them at compile time (static
LL_PREDEFINED / OF_PREDEFINED / ML_PREDEFINED), and build_ctable copies
the used part (copy_used: the header, 1 << tableLog next states and
maxSymbolValue + 1 transforms, exactly what build writes; the predefined
distributions have no zero counts, whose delta_find_state build leaves
as it was). Same tables, same output.
Tests: predefined equals build on the random distributions of
build_matches_reference_spread (both spread paths), and copying each
predefined table over a fresh, an RLE and a larger table leaves exactly
what building it leaves. Workspace and portable test suites pass.
EPYC 7543 (bd-au1-jz001g3v), 16 lanes, 3 rounds, 2 binary copies of each
side interleaved, medians; all 12 Silesia files; output sizes identical
in every case. Speed branch/main (geomean over the files):
chunk L-5 L-1 L1 L3 L5 L9 L16 L19
1 KiB 1.426 1.222 1.084 1.053 1.021 1.014 1.007 1.006
4 KiB 1.055 1.017 1.009 1.006 1.005 1.003 1.002 1.002
16 KiB 1.012 1.005 1.001 1.004 1.001 1.003 1.002 1.003
64 KiB 1.001 1.002 1.003 1.005 1.002 1.002 1.003 1.001
full 1.002 1.002 1.000 1.000 0.998 0.997
Full files rerun with fresh copies: one branch copy ran sao L-1 at
0.78x with the same instruction count as the others (copy placement);
fresh copies of the same file ran at main's speed. nci L5/L9 full
(0.986) have identical instruction counts, cycles within the copy
spread. perf stat, mozilla L-1 1 KiB: instructions 21.59G -> 15.45G,
cycles 6.65G -> 5.07G, 588 -> 785 MiB/s (zrip L-1: 770 at ratio 1.743;
zstd-native 1.762). Against C libzstd 1.6.0 at the same level: 1.25x
on 1 KiB frames (was 1.14x), 1.11x on full files.