Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make H5FL package threadsafe #5195

Open
wants to merge 695 commits into
base: develop
Choose a base branch
from
Open

Conversation

qkoziol
Copy link
Contributor

@qkoziol qkoziol commented Dec 30, 2024

Library:

  • Added mutex that obeys disable-locking-for-this-thread (DLFTT) semantics, to enable threadsafe data structures within the library that "suspend" locking when a thread has exclusive ownership of the library. (in src/H5TSdlftt_mutex.[ch])

  • Initialize the threadsafe aspects of the H5FL package at library startup, when concurrency is enabled. (in src/H5.c)

  • Added new H5_global_t type, with H5_GLOBAL_INIT macro, to hold and initialize threadsafe globals with complex initialization that needs to be performed dynamically at runtime. (in src/H5private.h)

  • Added wrapper for atomic size_t variables. (in src/H5TSprivate.h and src/H5TSatomic.c)

  • Added new H5TS_bootstrap_g DLFTT mutex in src/H5TSint.c to support new threadsafe globals. (in src/H5TSint.c)

  • H5FL package changes: (in src/H5FL.c and src/H5FLprivate.h)

    • Made free list limits atomic variables when concurrency is enabled
    • Access & modify free list limit globals through wrapper macros that work in both concurrent and non-concurrent builds of the library
    • Added DLFTT mutex and info for H5_global_t to each free list
    • Use new H5_GLOBAL_INIT macro to safely initialize each free list dynamically at runtime
    • Acquire & release free list's mutex when accessing information in the list to allocate & free objects (ifdef'd out in non-concurrent builds)
    • Added DLFTT mutex to each global list-of-lists
    • Acquire & release global list-of-list's mutex when accessing information in it, mainly to add new free lists to it, as they are initialized by use within the library (ifdef'd out in non-concurrent builds)
    • Small reworkings of the garbage collection routines to separate locking from accessing free list limits better
    • Switched free list initialization macros in private header to use named fields, to make them portable between concurrency and non-concurrency builds
    • Removed unnecessary 'init' field from a few structs
    • Minor variable and struct field renamings, to help clarify their purposes

Testing:

  • Added new h5_setup_local_rand() support routine to initialize h5_local_rand() with gettimeofday() or a predefined seed value.

  • Expand test/tmisc.c, test_misc35(), to cover additional cases.

  • Added tts_h5fl() to ttsafe test, skipped by default for non-concurrency builds.

  • The tts_h5fl() testing generates multiple random test vectors of operations for each type of free list (regular, block, factory, and array) and then spawns threads that randomly chooses a set of test vectors to execute concurrently.

qkoziol and others added 30 commits June 7, 2024 16:50
Signed-off-by: Quincey Koziol <[email protected]>
Signed-off-by: Quincey Koziol <[email protected]>
Signed-off-by: Quincey Koziol <[email protected]>
…re impl.

Also remove the "lightweight semaphore" wrappers that use atomics, they appear
to not be helping.

Signed-off-by: Quincey Koziol <[email protected]>
Signed-off-by: Quincey Koziol <[email protected]>
Signed-off-by: Quincey Koziol <[email protected]>
Signed-off-by: Quincey Koziol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants