Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

feature: limit the number which download from supernode for one task #819

Merged
merged 1 commit into from
Sep 4, 2019

Conversation

starnop
Copy link
Contributor

@starnop starnop commented Aug 15, 2019

Signed-off-by: Starnop [email protected]

Ⅰ. Describe what this PR did

When dragonfly begin to distribute a new file, a large number of download requests will be dispatched to the supernode node because there are no nodes in the current P2P network owns the file. Then the load of supernode will become heavier and heavier. According to the test, sometimes one peer will cost almost 2 minutes to download a piece which is only 4M from supernode(NOTE: the network bandwidth is enough). In order to avoid this, we should add a limit which only allows a limited number of downloads from supernode for one task at the same time. And then the others will download the piece form the peers which have downloaded from the supernode.

This will greatly reduce the load of the supernode.

Ⅱ. Does this pull request fix one issue?

None.

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

None.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@starnop starnop force-pushed the supernode-task-limit branch 2 times, most recently from b3b0e6e to 17196e8 Compare August 15, 2019 06:25
@pouchrobot pouchrobot added size/L and removed size/M labels Aug 15, 2019
@starnop starnop changed the title [WIP]feature: limit the number which download from supernode for one task feature: limit the number which download from supernode for one task Aug 15, 2019
Copy link
Member

@lowzj lowzj left a comment

Choose a reason for hiding this comment

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

  • the time to decrease the load. we should consider that when to decrease it if supernode doesn't receive the message from peers that downloading piece from supernode.
  • the time to clean the load of supernode in progress manager

@starnop starnop force-pushed the supernode-task-limit branch from 17196e8 to 987d1c0 Compare August 16, 2019 10:44
@starnop starnop force-pushed the supernode-task-limit branch 3 times, most recently from f947b6e to b6ab252 Compare August 16, 2019 10:50
@starnop starnop force-pushed the supernode-task-limit branch from b6ab252 to 7f73758 Compare August 19, 2019 06:33
@starnop starnop force-pushed the supernode-task-limit branch 2 times, most recently from a13ee3b to 86aa7a8 Compare August 19, 2019 13:43
@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #819 into master will decrease coverage by 0.22%.
The diff coverage is 13.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #819      +/-   ##
==========================================
- Coverage   39.67%   39.44%   -0.23%     
==========================================
  Files         109      110       +1     
  Lines        6415     6464      +49     
==========================================
+ Hits         2545     2550       +5     
- Misses       3661     3704      +43     
- Partials      209      210       +1
Impacted Files Coverage Δ
supernode/config/config.go 66.66% <ø> (ø) ⬆️
supernode/daemon/mgr/progress/progress_state.go 0% <0%> (ø) ⬆️
supernode/daemon/mgr/task/manager.go 29.23% <0%> (-0.93%) ⬇️
supernode/daemon/mgr/progress/progress_delete.go 0% <0%> (ø) ⬆️
supernode/daemon/mgr/task/manager_util.go 24.13% <0%> (-0.17%) ⬇️
supernode/daemon/mgr/scheduler/manager.go 22.6% <0%> (-1.14%) ⬇️
supernode/daemon/mgr/progress/state_sync_map.go 4.65% <0%> (-0.91%) ⬇️
supernode/daemon/mgr/progress/progress_manager.go 26.02% <100%> (+1.02%) ⬆️
supernode/daemon/mgr/progress/superload_manager.go 13.63% <13.63%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a36ca24...718f2fc. Read the comment docs.

pm.superLoad.add(taskID, newSuperLoadState())
}

if loadState.loadValue.Add(delta) > limit && limit > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

The loadState maybe nil. It's not the object we created above when it's not exist before. We should get it again from map after adding. Otherwise we may use different objects with same taskId in multi-goroutines. It's better to make the get and add as one atomic operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@starnop starnop force-pushed the supernode-task-limit branch 3 times, most recently from 349b528 to 1d80d21 Compare August 30, 2019 05:22
// when a peer success to download a piece from supernode,
// and the load of supernode for the taskID should be decremented by one.
if tm.cfg.IsSuperPID(pieceUpdateRequest.DstPID) {
_, err := tm.progressMgr.UpdateSuperLoad(ctx, taskID, -1, -1)
Copy link
Member

@lowzj lowzj Aug 30, 2019

Choose a reason for hiding this comment

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

The load of supernode would not be decreased here because that the limit is less than zero and the if statement below would not execute the code loadState.loadValue.Add(delta).

	if limit > 0 && loadState.loadValue.Add(delta) > limit {
		loadState.loadValue.Add(-delta)
		return false, nil
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that. And I have updated it. PTAL again. THX>

@starnop starnop force-pushed the supernode-task-limit branch from 1d80d21 to 718f2fc Compare September 1, 2019 15:21
@lowzj
Copy link
Member

lowzj commented Sep 4, 2019

LGTM

@lowzj lowzj merged commit 9402c66 into dragonflyoss:master Sep 4, 2019
starnop pushed a commit to starnop/Dragonfly that referenced this pull request Nov 27, 2019
feature: limit the number which download from supernode for one task
inoc603 pushed a commit to inoc603/Dragonfly that referenced this pull request Dec 23, 2019
feature: limit the number which download from supernode for one task
sungjunyoung pushed a commit to sungjunyoung/Dragonfly that referenced this pull request May 8, 2022
* feat: support list plugin

Signed-off-by: Jim Ma <[email protected]>

* chore: optmize plugin output

Signed-off-by: Jim Ma <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants