-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #656 from binpash/future
PaSh version 0.12
- Loading branch information
Showing
70 changed files
with
638 additions
and
4,707 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
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,42 @@ | ||
#!/bin/bash | ||
|
||
## Contains utility function that are used by multiple pash frontends | ||
|
||
pash_wait_until_unix_socket_listening() | ||
{ | ||
local server_name=$1 | ||
local socket=$2 | ||
## Only wait for a limited amount of time. | ||
## If the daemon cannot start listening in ~ 1 second, | ||
## then it must have crashed or so. | ||
i=0 | ||
## This is a magic number to make sure that we wait enough | ||
maximum_retries=1000 | ||
## For some reason, `nc -z` doesn't work on livestar (it always returns error) | ||
## and therefore we need to send something. | ||
until echo "Daemon Start" 2> /dev/null | nc -U "$socket" >/dev/null 2>&1 ; | ||
do | ||
## TODO: Can we wait for the daemon in a better way? | ||
sleep 0.01 | ||
i=$((i+1)) | ||
if [ $i -eq $maximum_retries ]; then | ||
echo "Error: Maximum retries: $maximum_retries exceeded when waiting for server: ${server_name} to bind to socket: ${socket}!" 1>&2 | ||
echo "Exiting..." 1>&2 | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
pash_communicate_unix_socket() | ||
{ | ||
local server_name=$1 | ||
local socket=$2 | ||
local message=$3 | ||
pash_redir_output echo "Sending msg to ${server_name}: $message" | ||
daemon_response=$(echo "$message" | nc -U "${socket}") | ||
pash_redir_output echo "Got response from ${server_name}: $daemon_response" | ||
echo "$daemon_response" | ||
} | ||
|
||
export -f pash_wait_until_unix_socket_listening | ||
export -f pash_communicate_unix_socket |
48 changes: 48 additions & 0 deletions
48
compiler/orchestrator_runtime/speculative/pash_spec_init_setup.sh
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,48 @@ | ||
#!/bin/bash | ||
|
||
source "$PASH_TOP/compiler/orchestrator_runtime/pash_orch_lib.sh" | ||
|
||
pash_spec_communicate_scheduler() | ||
{ | ||
local message=$1 | ||
pash_communicate_unix_socket "PaSh-Spec-scheduler" "${PASH_SPEC_SCHEDULER_SOCKET}" "${message}" | ||
} | ||
|
||
pash_spec_communicate_scheduler_just_send() | ||
{ | ||
pash_spec_communicate_scheduler "$1" | ||
} | ||
|
||
pash_spec_wait_until_scheduler_listening() | ||
{ | ||
pash_wait_until_unix_socket_listening "PaSh-Spec-scheduler" "${PASH_SPEC_SCHEDULER_SOCKET}" | ||
} | ||
|
||
|
||
start_server() | ||
{ | ||
python3 -S "$PASH_SPEC_TOP/parallel-orch/scheduler_server.py" "$@" & | ||
export daemon_pid=$! | ||
## Wait until daemon has established connection | ||
pash_spec_wait_until_scheduler_listening | ||
} | ||
|
||
cleanup_server() | ||
{ | ||
local daemon_pid=$1 | ||
## Only wait for daemon if it lives (it might be dead, rip) | ||
if ps -p "$daemon_pid" > /dev/null | ||
then | ||
## Send and receive from daemon | ||
msg="Done" | ||
daemon_response=$(pash_spec_communicate_scheduler "$msg") | ||
wait 2> /dev/null 1>&2 | ||
fi | ||
} | ||
|
||
export -f pash_spec_communicate_scheduler | ||
export -f pash_spec_communicate_scheduler_just_send | ||
export -f pash_spec_wait_until_scheduler_listening | ||
export -f start_server | ||
export -f cleanup_server | ||
|
17 changes: 17 additions & 0 deletions
17
compiler/orchestrator_runtime/speculative/speculative_runtime.sh
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,17 @@ | ||
#!/bin/bash | ||
|
||
|
||
## TODO: Ask the scheduler to let us know when a command has been committed and what is its exit code. | ||
## TODO: Define the client in pash_spec_init_setup (which should be sourced by pash_init_setup) | ||
|
||
## TODO: Then we need to extend the scheduler to also support this protocol (unix sockets only) and | ||
## Respond when the command is actually done. | ||
|
||
export pash_speculative_command_id=$1 | ||
|
||
echo "STUB: This would call the scheduler for command with id: ${pash_speculative_command_id}" | ||
|
||
## TODO: Set this based on what the scheduler returns | ||
pash_runtime_final_status=$? | ||
|
||
## TODO: Also need to use wrap_vars maybe to `set` properly etc |
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
Oops, something went wrong.