You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Alexey Serbin (Code Review)" <ge...@cloudera.org> on 2020/04/09 22:56:20 UTC

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Alexey Serbin has uploaded this change for review. ( http://gerrit.cloudera.org:8080/15698


Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................

[catalog_manager] reduce contention in ScopedLeaderSharedLock

While troubleshooting one performance issue if running a big cluster
with large number of tables and high rate of ConnectToMaster requests,
in the logs I noticed many reports like the following:

  0323 03:59:31.091198 (+607857us) spinlock_profiling.cc:243]
  Waited 492 ms on lock 0x4cb0960. stack:
    0000000002398852
    0000000000ad8c69
    0000000000aa62ba
    000000000221aaa8
    ...

which translates into
    (anonymous namespace)::SubmitSpinLockProfileData()
    master::CatalogManager::ScopedLeaderSharedLock::ScopedLeaderSharedLock()
    master::MasterServiceImpl::ConnectToMaster()
    rpc::GeneratedServiceIf::Handle()
    ...

From the code it became apparent that the lock is question was
  std::lock_guard<simple_spinlock> l(catalog_->state_lock_);
in ScopedLeaderSharedLock() constructor.

As far as I can see, there is no need to access master's Raft consensus
information (which itself might wait on its internal locks if there is
corresponding Raft-consensus activity) under the catalog's state lock.

This patch shortens the critical section with catalog's state lock held
when constructing CatalogManager::ScopedLeaderSharedLock instance.

Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
---
M src/kudu/master/catalog_manager.cc
1 file changed, 11 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/98/15698/1
-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................


Patch Set 2: Code-Review+2

(1 comment)

http://gerrit.cloudera.org:8080/#/c/15698/2//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/15698/2//COMMIT_MSG@28
PS2, Line 28: is
nit: in



-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Thu, 09 Apr 2020 23:56:03 +0000
Gerrit-HasComments: Yes

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................

[catalog_manager] reduce contention in ScopedLeaderSharedLock

While troubleshooting one performance issue if running a big cluster
with large number of tables and high rate of ConnectToMaster requests,
in the logs I noticed many reports like the following:

  0323 03:59:31.091198 (+607857us) spinlock_profiling.cc:243]
  Waited 492 ms on lock 0x4cb0960. stack:
    0000000002398852
    0000000000ad8c69
    0000000000aa62ba
    000000000221aaa8
    ...

which translates into
    (anonymous namespace)::SubmitSpinLockProfileData()
    master::CatalogManager::ScopedLeaderSharedLock::ScopedLeaderSharedLock()
    master::MasterServiceImpl::ConnectToMaster()
    rpc::GeneratedServiceIf::Handle()
    ...

From the code it became apparent that the lock in question was
  std::lock_guard<simple_spinlock> l(catalog_->state_lock_);
in ScopedLeaderSharedLock() constructor.

As far as I can see, there is no need to access master's Raft consensus
information (which itself might wait on its internal locks if there is
corresponding Raft-consensus activity) under the catalog's state lock.

This patch shortens the critical section with catalog's state lock held
when constructing CatalogManager::ScopedLeaderSharedLock instance.

Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Reviewed-on: http://gerrit.cloudera.org:8080/15698
Reviewed-by: Andrew Wong <aw...@cloudera.com>
Tested-by: Kudu Jenkins
---
M src/kudu/master/catalog_manager.cc
1 file changed, 11 insertions(+), 7 deletions(-)

Approvals:
  Andrew Wong: Looks good to me, approved
  Kudu Jenkins: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................


Patch Set 1:

(1 comment)

Good catch!

http://gerrit.cloudera.org:8080/#/c/15698/1/src/kudu/master/catalog_manager.cc
File src/kudu/master/catalog_manager.cc:

http://gerrit.cloudera.org:8080/#/c/15698/1/src/kudu/master/catalog_manager.cc@5319
PS1, Line 5319:   int64_t leader_ready_term = -1;
Don't need to initialize?



-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Thu, 09 Apr 2020 23:01:41 +0000
Gerrit-HasComments: Yes

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Andrew Wong (Code Review)" <ge...@cloudera.org>.
Andrew Wong has posted comments on this change. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................


Patch Set 3: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Fri, 10 Apr 2020 00:43:07 +0000
Gerrit-HasComments: No

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins, Andrew Wong, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/15698

to look at the new patch set (#3).

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................

[catalog_manager] reduce contention in ScopedLeaderSharedLock

While troubleshooting one performance issue if running a big cluster
with large number of tables and high rate of ConnectToMaster requests,
in the logs I noticed many reports like the following:

  0323 03:59:31.091198 (+607857us) spinlock_profiling.cc:243]
  Waited 492 ms on lock 0x4cb0960. stack:
    0000000002398852
    0000000000ad8c69
    0000000000aa62ba
    000000000221aaa8
    ...

which translates into
    (anonymous namespace)::SubmitSpinLockProfileData()
    master::CatalogManager::ScopedLeaderSharedLock::ScopedLeaderSharedLock()
    master::MasterServiceImpl::ConnectToMaster()
    rpc::GeneratedServiceIf::Handle()
    ...

From the code it became apparent that the lock in question was
  std::lock_guard<simple_spinlock> l(catalog_->state_lock_);
in ScopedLeaderSharedLock() constructor.

As far as I can see, there is no need to access master's Raft consensus
information (which itself might wait on its internal locks if there is
corresponding Raft-consensus activity) under the catalog's state lock.

This patch shortens the critical section with catalog's state lock held
when constructing CatalogManager::ScopedLeaderSharedLock instance.

Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
---
M src/kudu/master/catalog_manager.cc
1 file changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/98/15698/3
-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/15698

to look at the new patch set (#2).

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................

[catalog_manager] reduce contention in ScopedLeaderSharedLock

While troubleshooting one performance issue if running a big cluster
with large number of tables and high rate of ConnectToMaster requests,
in the logs I noticed many reports like the following:

  0323 03:59:31.091198 (+607857us) spinlock_profiling.cc:243]
  Waited 492 ms on lock 0x4cb0960. stack:
    0000000002398852
    0000000000ad8c69
    0000000000aa62ba
    000000000221aaa8
    ...

which translates into
    (anonymous namespace)::SubmitSpinLockProfileData()
    master::CatalogManager::ScopedLeaderSharedLock::ScopedLeaderSharedLock()
    master::MasterServiceImpl::ConnectToMaster()
    rpc::GeneratedServiceIf::Handle()
    ...

From the code it became apparent that the lock is question was
  std::lock_guard<simple_spinlock> l(catalog_->state_lock_);
in ScopedLeaderSharedLock() constructor.

As far as I can see, there is no need to access master's Raft consensus
information (which itself might wait on its internal locks if there is
corresponding Raft-consensus activity) under the catalog's state lock.

This patch shortens the critical section with catalog's state lock held
when constructing CatalogManager::ScopedLeaderSharedLock instance.

Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
---
M src/kudu/master/catalog_manager.cc
1 file changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/98/15698/2
-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/15698/1/src/kudu/master/catalog_manager.cc
File src/kudu/master/catalog_manager.cc:

http://gerrit.cloudera.org:8080/#/c/15698/1/src/kudu/master/catalog_manager.cc@5319
PS1, Line 5319:   int64_t leader_ready_term = -1;
> Don't need to initialize?
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Thu, 09 Apr 2020 23:11:55 +0000
Gerrit-HasComments: Yes

[kudu-CR] [catalog manager] reduce contention in ScopedLeaderSharedLock

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/15698 )

Change subject: [catalog_manager] reduce contention in ScopedLeaderSharedLock
......................................................................


Patch Set 2:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/15698/2//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/15698/2//COMMIT_MSG@28
PS2, Line 28: is
> nit: in
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/15698
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3b2e6866a8a0d5bda9e2b1f01e0668427de60868
Gerrit-Change-Number: 15698
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Comment-Date: Fri, 10 Apr 2020 00:24:26 +0000
Gerrit-HasComments: Yes