Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/decompress/huf_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,28 @@ static size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t ds

#if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
typedef struct { U32 tableTime; U32 decode256Time; } algo_time_t;
#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
static const algo_time_t algoTime[16 /* Quantization */][2 /* single, double */] =
{
/* single, double, quad */
{{0,0}, {1,1}}, /* Q==0 : impossible */
{{0,0}, {1,1}}, /* Q==1 : impossible */
{{ 150,216}, { 381,119}}, /* Q == 2 : 12-18% */
{{ 314,167}, { 349,102}}, /* Q == 3 : 18-25% */
{{ 291,167}, { 448,103}}, /* Q == 4 : 25-32% */
{{ 197,194}, { 644,107}}, /* Q == 5 : 32-38% */
{{ 170,167}, { 296,102}}, /* Q == 6 : 38-44% */
{{ 173,167}, { 339,103}}, /* Q == 7 : 44-50% */
{{ 229,169}, { 539,108}}, /* Q == 8 : 50-56% */
{{ 258,168}, { 631,103}}, /* Q == 9 : 56-62% */
{{ 688,187}, {1712,122}}, /* Q ==10 : 62-69% */
{{ 825,186}, {1965,136}}, /* Q ==11 : 69-75% */
{{ 515,169}, {1327,180}}, /* Q ==12 : 75-81% */
{{ 543,169}, { 862,199}}, /* Q ==13 : 81-87% */
{{1377,185}, {1731,202}}, /* Q ==14 : 87-93% */
{{1412,185}, {1695,202}}, /* Q ==15 : 93-99% */
Comment on lines +1811 to +1824

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that Q=2,5,10,14,15 are unchanged from the x86 rows. Why is that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fitted an intercept/slope for every Q bucket using some synthetic data by measuring X1 and X2 total time on that data. After this, I replayed the selector decisions on separate synthetic datasets as well as the data in https://github.com/terrelln/huffman-sample-files. I then retain a changed row if it changes at least one decision and reduced the measured total HUF cost.

For Q2, Q5, Q11, Q14, and Q15 the decision between X1 and X2 was the same for aarch64 fitted vs. status quo for all of the samples I ran. So for those, I kept the rows unchanged.

For Q10, the fitting procedure produced a Q10 row that overwhelmingly selected X2, but when I validated the row later against some workloads it regressed so I opted to keep that untouched.

Open to suggestions on the tuning methodology!

};
#else
static const algo_time_t algoTime[16 /* Quantization */][2 /* single, double */] =
{
/* single, double, quad */
Expand All @@ -1823,6 +1845,7 @@ static const algo_time_t algoTime[16 /* Quantization */][2 /* single, double */]
{{1412,185}, {1695,202}}, /* Q ==15 : 93-99% */
};
#endif
#endif

/** HUF_selectDecoder() :
* Tells which decoder is likely to decode faster,
Expand Down