-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before this PR, we'll create a new channel object when sending data. We reuse that in this PR to make code clean. Also, we did a benchmark from @fengsp(Thanks for the contribution) for this PR, and the result is not too good. The baseline(before this PR) is: ``` num calls: 10000 total time (ms) = 79241.70279502869 per task overhead (ms) = 7.924171590805054 ``` and the current result after this PR is: ``` num calls: 10000 total time (ms) = 78388.72385025024 per task overhead (ms) = 7.83887369632721 ``` --------- Signed-off-by: Qing Wang <kingchin1218@gmail.com>
- Loading branch information
1 parent
204a0a3
commit 702565d
Showing
2 changed files
with
107 additions
and
57 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2023 The RayFed Team | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import ray | ||
import time | ||
import sys | ||
import fed | ||
|
||
|
||
@fed.remote | ||
class MyActor: | ||
def run(self): | ||
return None | ||
|
||
|
||
@fed.remote | ||
class Aggregator: | ||
def aggr(self, val1, val2): | ||
return None | ||
|
||
|
||
def main(party): | ||
ray.init(address='local') | ||
|
||
cluster = { | ||
'alice': {'address': '127.0.0.1:11010'}, | ||
'bob': {'address': '127.0.0.1:11011'}, | ||
} | ||
fed.init(cluster=cluster, party=party) | ||
|
||
actor_alice = MyActor.party("alice").remote() | ||
actor_bob = MyActor.party("bob").remote() | ||
aggregator = Aggregator.party("alice").remote() | ||
|
||
start = time.time() | ||
num_calls = 10000 | ||
for i in range(num_calls): | ||
val_alice = actor_alice.run.remote() | ||
val_bob = actor_bob.run.remote() | ||
sum_val_obj = aggregator.aggr.remote(val_alice, val_bob) | ||
fed.get(sum_val_obj) | ||
if i % 100 == 0: | ||
print(f"Running {i}th call") | ||
print(f"num calls: {num_calls}") | ||
print("total time (ms) = ", (time.time() - start)*1000) | ||
print("per task overhead (ms) =", (time.time() - start)*1000/num_calls) | ||
|
||
fed.shutdown() | ||
ray.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
assert len(sys.argv) == 2, 'Please run this script with party.' | ||
main(sys.argv[1]) |
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