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

[Draft] Changes for having replication thread per remote host #2715

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arun-LinkedIn
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

Attention: 46 lines in your changes are missing coverage. Please review.

Comparison is base (3995085) 70.71% compared to head (36416c8) 52.89%.
Report is 1 commits behind head on master.

Files Patch % Lines
...om/github/ambry/replication/ReplicationEngine.java 17.85% 43 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #2715       +/-   ##
=============================================
- Coverage     70.71%   52.89%   -17.82%     
+ Complexity    11561     7915     -3646     
=============================================
  Files           830      830               
  Lines         70675    70719       +44     
  Branches       8499     8508        +9     
=============================================
- Hits          49978    37410    -12568     
- Misses        18074    30295    +12221     
- Partials       2623     3014      +391     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if (numOfThreadsInPool <= 0) {
return null;
}
if (!replicationConfig.replicationUseSeparateThreadForEachHost) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flip the order of the if-else; if (use-thread-per-host) {} else {}

datacenter.equals(dataNodeId.getDatacenterName()) ? replicationConfig.replicationNumOfIntraDCReplicaThreads
: replicationConfig.replicationNumOfInterDCReplicaThreads;
if (numOfThreadsInPool <= 0) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn/info down here

logger.warn("Number of replica threads is smaller or equal to 0, not starting any replica threads for {}.",
datacenter);
ReplicaThread replicaThread = getReplicaThreadForRemoteReplica(remoteReplicaInfo, startThread);
if (replicaThread == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (replicaThread != null) { do_something }

* @param startThread If thread needs to be started when created.
* @return {@link ReplicaThread} created for the remote node
*/
private ReplicaThread createThread(DataNodeId dataNodeId, boolean startThread) {
Copy link
Contributor

@snalli snalli Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should solve the issue since its usually a slow host, and not a slow partition on the host affecting repl

*/
@Config("replication.use.separate.thread.for.each.host")
@Default("true")
public final boolean replicationUseSeparateThreadForEachHost;
Copy link
Contributor

@snalli snalli Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of boolean, use an int to indicate num threads per host
0 = go the old way (default)
1 or more = 1 or more threads per host

if (numOfThreadsInPool <= 0) {
return null;
}
if (!replicationConfig.replicationUseSeparateThreadForEachHost) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order of conditions here will dictate what we prioritize - thread-per-host or the old-way

return dataNodeIdToReplicaThread.computeIfAbsent(dataNodeIdToReplicate,
key -> replicaThreads.get(getReplicaThreadIndexToUse(datacenter)));
} else {
return dataNodeIdToReplicaThread.computeIfAbsent(dataNodeIdToReplicate,
Copy link
Contributor

@snalli snalli Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have more than one thread per remote host, use round robin to assign replicas on that remote host to threads on local host

@@ -305,135 +305,135 @@ public ReplicationMetrics(MetricRegistry registry, List<? extends ReplicaId> rep
public void populateSingleColoMetrics(String datacenter) {
Meter interColoReplicationBytesRatePerDC =
registry.meter(MetricRegistry.name(ReplicaThread.class, "Inter-" + datacenter + "-ReplicationBytesRate"));
interColoReplicationBytesRate.put(datacenter, interColoReplicationBytesRatePerDC);
interColoReplicationBytesRate.putIfAbsent(datacenter, interColoReplicationBytesRatePerDC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just get rid these statements pls

* If true, replication Get requests asks for deleted and expired blobs as well to succeed in scenarios where blobs
* get deleted or expired after replication metadata exchange.
*/
@Config("replication.use.separate.thread.for.each.host")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use public static final in CAPS for this string replication.use.separate.thread.for.each.host

* get deleted or expired after replication metadata exchange.
*/
@Config("replication.use.separate.thread.for.each.host")
@Default("true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this default, not used anywhere

if (numOfThreadsInPool <= 0) {
return null;
}
protected List<ReplicaThread> getOrCreateThreadPoolIfNecessary(String datacenter, boolean startThread,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just rm this fn and merge the code above in its call site

*/
@Config("replication.use.separate.thread.for.each.host")
@Default("true")
public final boolean replicationUseSeparateThreadForEachHost;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replicationUseSeparateThreadForEachHost -> numReplicationThreadsPerRemoteHost

@Arun-LinkedIn
Copy link
Contributor Author

Arun-LinkedIn commented Feb 16, 2024

@snalli I haven't actually finished working on this pr. Want to do some WIP tests in EI to see if this change helps. That's why I put it in draft status and didn't add any reviewers :) But, thanks for initial comments!

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.

None yet

3 participants