improve locks in docker info#26668
Conversation
e8a2d86 to
7d76eb6
Compare
|
RWMutex will be really helpful, thanks! |
|
I'm not sure what the read lock is really helping here. The way I see it, read lock is useful for:
All these operations are really fast, and unless I'm mistaken we aren't really doing any recursive locking here. |
|
Slow reads are not necessarily a good indicator to use read locks. A good indicator is the level of read contention. If there are fast reads but they happen a lot frequently then it results in high contention. If there is contention and kernel(and go scheduler) had to be involved then it does result in poor performance. So if there is high read contention and number of reads far outweigh the number of writes, I'd say RWMutex is a pretty good optimization. |
|
I don't think that's the case here. Very unlikely to have more than a few things reading at the same time. |
|
Even if at least two go routines contend for this lock very frequently for just reading then this PR will help. But that can be known only by profiling. |
|
I think there can be multiple concurrent calls to |
|
Personally I don't mind this being an RWMutex even if there are less frequent reads. But looks like @cpuguy83 had some experience doing the same some time before. So it depends on what his experience was. |
|
I think it's unnecessary and will probably do more harm than good. |
7d76eb6 to
a8af12a
Compare
|
OK, reverted RWMutex to normal Mutex |
|
Thanks. Thinking about this.. the PR will make calls to |
a8af12a to
b7d6b79
Compare
docker info
|
Updated, please revert the label to |
b7d6b79 to
4270133
Compare
4270133 to
1e6299c
Compare
Signed-off-by: Akihiro Suda <[email protected]>
1e6299c to
cae8daa
Compare
|
ping @LK4D4 @tonistiigi ptal! |
|
I don't think monitor is the right place for storing the state from the cache. It should be covered by the methods that modify state. The same optimization should cover |
|
@tonistiigi Thank you for looking into this. So I'm closing this PR at the moment. PTAL @cpuguy83 |
Fix #26666