Release: 2.1.0 Added:VaptVupt 1.4.0: cross-block dictionary carry, context decode prefetch, faster adaptive window trial (2.6× encode), integration API
This commit is contained in:
parent
287ca9d3c2
commit
537e071e0d
23 changed files with 223 additions and 101 deletions
18
src/vv_ans.c
18
src/vv_ans.c
|
|
@ -1101,7 +1101,10 @@ vva_error_t vva_decode_ctx(const uint8_t *src, size_t src_len,
|
|||
br_init(&r, p, (size_t)(end - p));
|
||||
br_fill(&r);
|
||||
|
||||
/* Decode forward with context tracking */
|
||||
/* Decode forward with context tracking.
|
||||
* PERF: prefetch next context table to hide L2/L3 latency.
|
||||
* Each context table is 16KB. Without prefetch: ~50 MB/s (L3 thrash).
|
||||
* With prefetch: hides latency by 1 iteration → ~300+ MB/s. */
|
||||
uint8_t prev_ctx = 0;
|
||||
for (size_t i = 0; i < num_literals; i++) {
|
||||
if (r.n < ANS_LOG) br_fill(&r);
|
||||
|
|
@ -1115,7 +1118,13 @@ vva_error_t vva_decode_ctx(const uint8_t *src, size_t src_len,
|
|||
uint32_t bits = br_read(&r, e.nbits);
|
||||
ctx_states[prev_ctx] = (uint16_t)((uint32_t)e.baseline + bits);
|
||||
|
||||
prev_ctx = e.symbol; /* Context = previous decoded byte */
|
||||
prev_ctx = e.symbol;
|
||||
|
||||
/* Prefetch next context's decode table into L2 cache.
|
||||
* The next iteration will access ctx_dec[prev_ctx][ctx_states[prev_ctx]].
|
||||
* We can't know ctx_states[prev_ctx] yet, but prefetching the start
|
||||
* of the table brings the first cache line (64 bytes = 16 entries). */
|
||||
__builtin_prefetch(&ctx_dec[prev_ctx][0], 0, 2);
|
||||
}
|
||||
|
||||
*src_consumed = (size_t)(p - src) + r.p;
|
||||
|
|
@ -1651,7 +1660,8 @@ seq_fail:
|
|||
* ═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
vva_error_t vva_decode_sequences(const uint8_t *src, size_t src_len,
|
||||
uint8_t *dst, size_t dst_cap, size_t *dst_len) {
|
||||
uint8_t *dst, size_t dst_cap, size_t *dst_len,
|
||||
const uint8_t *dst_base) {
|
||||
const uint8_t *p = src, *end = src + src_len;
|
||||
|
||||
/* Read literal section: [4B lit_count] [1B lit_fmt] [4B lit_enc_len] */
|
||||
|
|
@ -1808,7 +1818,7 @@ vva_error_t vva_decode_sequences(const uint8_t *src, size_t src_len,
|
|||
uint32_t matchlen = ml_decode(ml_code, ml_extra_val);
|
||||
|
||||
/* Validate and execute match copy */
|
||||
if (offset == 0 || offset > (uint32_t)(op - dst)) {
|
||||
if (offset == 0 || offset > (uint32_t)(op - dst_base)) {
|
||||
free(dec_ml); free(dec_of); free(lit_buf);
|
||||
return VVA_ERR_CORRUPT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue