-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:appnet-org/appnet into main
- Loading branch information
Showing
18 changed files
with
558 additions
and
71 deletions.
There are no files selected for viewing
Submodule compiler
updated
43 files
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
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
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,68 @@ | ||
state: | ||
QRIF: float | ||
num_choices: int | ||
|
||
init(): | ||
QRIF = 0.8 | ||
num_choices = 3 | ||
|
||
req(rpc): | ||
# Choose a subset of replicas | ||
backends = get_backends() | ||
sampled_backends = ramdom_choices(num_choices, 3) | ||
|
||
# Get their load and RIF information and store it in a list | ||
sorted_backend_info = sort(map(get_backend_info(), sampled_backends), RIF) | ||
index = int(len(sorted_backend_info)*QRIF) | ||
|
||
# (hot-cold lexicographic) Divide it to hot and cold backend | ||
cold_backend = slice(sorted_backend_info, 0, index) | ||
hot_backend = slice(sorted_backend_info, index, len(sorted_backend_info)) | ||
|
||
# if all probes are hot, then the one with lowest RIF is chosen. | ||
# Otherwise, the cold probe with the lowest latency is chosen | ||
match len(coldBackend) == 0: | ||
true => | ||
selected = get(hot_backend, 0) | ||
false => | ||
selected = min(cold_backend, latency) | ||
|
||
set(rpc, dst, selected) | ||
send(rpc, down) | ||
|
||
|
||
resp(rpc): | ||
send(rpc, up) | ||
|
||
|
||
state: | ||
QRIF: float | ||
num_choices: int | ||
|
||
init(): | ||
QRIF = 0.8 | ||
num_choices = 3 | ||
|
||
req(rpc): | ||
# Choose a subset of replicas | ||
backends = get_backends() | ||
sampled_backends = ramdom_choices(backends, num_choices) | ||
|
||
# Get their load and RIF information and store it in a list | ||
# get_backend_info is a built-in function that receives backend name and returns a dictionary: {"backend": xxx, "latency": xxx, "RIF": xxx} | ||
sorted_backend_info = sort(map(get_backend_info, sampled_backends), "RIF") | ||
index = int(len(sorted_backend_info) * QRIF) | ||
|
||
match index == 0: | ||
true => | ||
# all probes are hot | ||
selected = get(array_get(sorted_backend_info, 0), "backend") | ||
false => | ||
# cold probe with the lowest latency is chosen | ||
selected = get(array_min(sorted_backend_info, 0, index, "latency"), "backend") | ||
|
||
set(rpc, dst, selected) | ||
send(rpc, down) | ||
|
||
resp(rpc): | ||
send(rpc, up) |
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,19 @@ | ||
state: | ||
outstanding_req_count: int | ||
request_map<int, float> | ||
|
||
init(): | ||
outstanding_req_count = 0 | ||
|
||
req(rpc): | ||
outstanding_req_count = outstanding_req_count + 1 | ||
rpc_id = get(rpc, "id") | ||
set(request_map, rpc_id, current_time()) | ||
send(rpc, up) | ||
|
||
resp(rpc): | ||
outstanding_req_count = outstanding_req_count - 1 | ||
rpc_id = get(rpc, "id") | ||
latency = time_diff(current_time(), get(request_map, rpc_id)) | ||
send(rpc, down) | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,87 @@ | ||
state: | ||
// backend id -> queue length, timestamp | ||
load_map: Map<int, <int, float>> | ||
epsilon: float | ||
|
||
init(): | ||
epsilon = 1.0 | ||
num_choices = 3 | ||
|
||
req(rpc): | ||
shard_key = get(rpc, "key") | ||
backends = get_backends(shard_key) | ||
|
||
sampled_backends = random_choices(backends, num_choices) | ||
|
||
|
||
selected = 0 | ||
min_load = inf | ||
for each backend in sampled_backends: | ||
backend_load, last_ts = get(load_map, backend) | ||
freshness = time_diff(current_time(), last_ts) - epsilon | ||
|
||
match freshness > 0: | ||
true => | ||
pass | ||
false => | ||
backend_load = get(load_map_global, backend) | ||
set(load_map, (backendload, current_time()) | ||
|
||
match backend_load < min_load: | ||
true => | ||
selected = backend | ||
min_load = backend_load | ||
false => | ||
pass | ||
|
||
set(rpc, "dst", selected) | ||
send(rpc, down) | ||
|
||
resp(rpc): | ||
load = get(rpc, "load") | ||
dst = get(rpc, "dst") | ||
set(load_map, dst, (load, current_time())) | ||
send(rpc, up) | ||
|
||
|
||
state: | ||
load_map: Map<int, <int, float>> | ||
epsilon: float | ||
|
||
init(): | ||
epsilon = 1.0 | ||
|
||
req(rpc): | ||
shard_key = get(rpc, "key") | ||
backends = get_backends(shard_key) | ||
|
||
sampled_backends = random_choices(backends, 3) | ||
|
||
# Filter function to update freshness and backend load | ||
update_backend = lambda backend: | ||
backend_load, last_ts = get(load_map, backend) | ||
freshness = time_diff(current_time(), last_ts) - epsilon | ||
match freshness > 0: | ||
true => (backend, backend_load) | ||
false => (backend, get(load_map_global, backend)) | ||
|
||
updated_backends = map(sampled_backends, update_backend) | ||
|
||
# Reduce function to find the backend with the minimum load | ||
min_backend = reduce(updated_backends, lambda acc, backend_tuple: | ||
match backend_tuple[1] < acc[1]: | ||
true => backend_tuple | ||
false => acc, (None, inf)) | ||
|
||
selected, min_load = min_backend | ||
|
||
set(rpc, "dst", selected) | ||
send(rpc, down) | ||
|
||
resp(rpc): | ||
load = get(rpc, "load") | ||
dst = get(rpc, "dst") | ||
set(load_map, dst, (load, current_time())) | ||
send(rpc, up) | ||
|
||
|
Oops, something went wrong.