Add full thread-safety tests for (std concur hash) #58

Open
opened 2026-09-11 17:01:02 -04:00 by ober · 0 comments
Owner

Summary

Add comprehensive tests for the thread-safe hash table library (std concur hash).

Target

  • Library: (std concur hash)
  • Code location: lib/std/concur/hash.ss:37
  • Main constructors/API names: make-concurrent-hash, concurrent-hash-*
  • Short aliases: make-chash, chash-*

Why

The library is intended to provide thread-safe hash operations. We need tests that exercise the implementation under real concurrent access and prove that callers do not observe races, lost writes, corrupted state, or inconsistent read/modify/write behavior.

Suggested Coverage

  • Single-thread behavioral parity for constructors, predicates, reads, writes, removals, updates, size/count behavior, keys/values/pairs iteration, and clearing if available.
  • Alias parity for make-chash and all chash-* aliases against the corresponding make-concurrent-hash / concurrent-hash-* APIs.
  • Multi-thread stress tests with many readers and writers operating on shared keys and disjoint keys.
  • Read-modify-write/update tests that would expose lost updates under contention.
  • Removal and reinsertion races, including readers observing keys while other threads mutate the table.
  • Iteration/snapshot behavior under concurrent mutation, with documented expected semantics and tests that enforce them.
  • Invariant checks after concurrent workloads: expected value totals, no malformed entries, no unexpected missing keys, no duplicate/impossible states.
  • Regression tests that run enough iterations to catch timing-sensitive failures without making normal CI flaky.

Acceptance Criteria

  • The thread-safe hash API has meaningful concurrent tests in the repository test suite.
  • Tests include both long-form concurrent-hash-* names and short chash-* aliases.
  • The tests fail against a naive unsafe hash implementation or missing lock coverage.
  • The test command used in CI runs these tests automatically.
## Summary Add comprehensive tests for the thread-safe hash table library `(std concur hash)`. ## Target - Library: `(std concur hash)` - Code location: `lib/std/concur/hash.ss:37` - Main constructors/API names: `make-concurrent-hash`, `concurrent-hash-*` - Short aliases: `make-chash`, `chash-*` ## Why The library is intended to provide thread-safe hash operations. We need tests that exercise the implementation under real concurrent access and prove that callers do not observe races, lost writes, corrupted state, or inconsistent read/modify/write behavior. ## Suggested Coverage - Single-thread behavioral parity for constructors, predicates, reads, writes, removals, updates, size/count behavior, keys/values/pairs iteration, and clearing if available. - Alias parity for `make-chash` and all `chash-*` aliases against the corresponding `make-concurrent-hash` / `concurrent-hash-*` APIs. - Multi-thread stress tests with many readers and writers operating on shared keys and disjoint keys. - Read-modify-write/update tests that would expose lost updates under contention. - Removal and reinsertion races, including readers observing keys while other threads mutate the table. - Iteration/snapshot behavior under concurrent mutation, with documented expected semantics and tests that enforce them. - Invariant checks after concurrent workloads: expected value totals, no malformed entries, no unexpected missing keys, no duplicate/impossible states. - Regression tests that run enough iterations to catch timing-sensitive failures without making normal CI flaky. ## Acceptance Criteria - The thread-safe hash API has meaningful concurrent tests in the repository test suite. - Tests include both long-form `concurrent-hash-*` names and short `chash-*` aliases. - The tests fail against a naive unsafe hash implementation or missing lock coverage. - The test command used in CI runs these tests automatically.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ober/jerboa#58
No description provided.