forked from netdata/netdata
-
Notifications
You must be signed in to change notification settings - Fork 0
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
[pull] master from netdata:master #274
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* benchmark locks; new rw-spinlock implementation; performance improvements on waitq * benchmark and stress r/w locks
Reviewer's Guide by SourceryThis pull request introduces new stress tests for locks and reimplements the reader-writer spinlock. Sequence diagram for the updated RW spinlock read locking processsequenceDiagram
participant T as Thread
participant L as RW_SPINLOCK
T->>L: rw_spinlock_read_lock()
activate L
L->>L: Increment counter atomically
Note over L: Check if WRITER_BIT is set
alt No writer holds the lock
L-->>T: Return success
else Writer holds the lock
L->>L: Decrement counter
L->>L: Exponential backoff sleep
L->>L: Retry
end
deactivate L
Sequence diagram for the updated RW spinlock write locking processsequenceDiagram
participant T as Thread
participant L as RW_SPINLOCK
T->>L: rw_spinlock_write_lock()
activate L
L->>L: Set WRITER_BIT atomically
Note over L: Check previous value
alt No readers or writers
L->>L: Set writer thread ID
L-->>T: Return success
else Readers or writer present
L->>L: Clear WRITER_BIT if readers present
L->>L: Exponential backoff sleep
L->>L: Retry
end
deactivate L
Class diagram for the updated RW_SPINLOCK implementationclassDiagram
class RW_SPINLOCK {
+pid_t writer
+uint32_t counter
+rw_spinlock_init()
+rw_spinlock_tryread_lock()
+rw_spinlock_read_lock()
+rw_spinlock_read_unlock()
+rw_spinlock_trywrite_lock()
+rw_spinlock_write_lock()
+rw_spinlock_write_unlock()
}
note for RW_SPINLOCK "Changed counter from REFCOUNT to uint32_t
Added WRITER_BIT (1U << 31) for writer lock
Added READER_MASK (~WRITER_BIT) for reader count"
Class diagram for the new benchmark structuresclassDiagram
class thread_context_t {
+int thread_id
+thread_type_t type
+WAITQ_PRIORITY priority
+lock_control_t* control
+void* lock
+ND_THREAD* thread
}
class lock_control_t {
+uint64_t protected_counter
+thread_stats_t stats[MAX_THREADS]
+thread_control_t thread_controls[MAX_THREADS]
}
class thread_stats_t {
+uint64_t locks
+usec_t test_time
+volatile int ready
}
class thread_control_t {
+pthread_cond_t cond
+pthread_mutex_t cond_mutex
+uint64_t run_flag
}
thread_context_t --> lock_control_t
lock_control_t --> thread_stats_t
lock_control_t --> thread_control_t
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Tests: