8000 Thread safety of ALP: Should static arrays in encoder be thread_local for multithreaded compression? · Issue #41 · cwida/ALP · GitHub
[go: up one dir, main page]

Skip to content

Thread safety of ALP: Should static arrays in encoder be thread_local for multithreaded compression? #41

Open

Description

@deepakg-2203

Hi,
I am using ALP for multithreaded compression and noticed that in "encoder.hpp",the function "encode_simdized()" uses static arrays like this:

`alignas(64) static PT ENCODED_VALUE_ARR[1024];

alignas(64) static PT VALUE_ARR_WITHOUT_SPECIALS[1024];

alignas(64) static UT TMP_INDEX_ARR[1024];`

Since these are static, they are shared between threads and could cause data races during parallel compression.
Would it be correct to change these to thread_local static to make the function thread-safe? Or is there a recommended way to use ALP safely in a multithreaded context?

Thanks!

Activity

  1. azimafroozeh commented on Oct 16, 2025

    @azimafroozeh
    Contributor

    Hi,

    You are completely right. The static arrays should be changed to thread_local to make the encoder safe in multithreaded contexts. This change will not cause any issues for ALP.

    The recommended long-term approach is to allocate these buffers through a buffer manager to monitor and limit total memory usage.

    I’d be happy to review a PR that makes the initial change (static → thread_local).

    Thanks for catching this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0