Skip to content

Potentially optimizing build_huffman_tree #57

@okaneco

Description

@okaneco

I came across this article and was wondering if an approach like this was tried for the following tree building code with repeated SIMD min lookups instead of maintaining a min-heap.
https://www.intel.com/content/www/us/en/developer/articles/technical/fast-computation-of-huffman-codes.html

let mut lengths = [0u8; 286];
let mut codes = [0u16; 286];
build_huffman_tree(&frequencies, &mut lengths, &mut codes, 15);

If I understand correctly, they found above ~140 elements seemed to be where the vector method was preferred over the heap. However, they're using AVX2 and u16 instead of u32 which I think the current code uses. I'm not sure if it's possible to efficiently get the min position. with implicit autovectorization.

I don't know the impact this would have on overall runtime since they numbers they report are just for the tree building.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions