Skip to content

Commit

Permalink
add multi-threading toggle, fix binary caching string
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck committed May 16, 2024
1 parent 9c60830 commit 2934d4a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
25 changes: 24 additions & 1 deletion server/app/query/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function IPAForm({
CommitSpecifier.BRANCH,
);
const [stallDetectionEnabled, setStallDetectionEnabled] = useState(true);
const [multiThreadingEnabled, setMultiThreadingEnabled] = useState(true);
const disableBranch = commitSpecifier != CommitSpecifier.BRANCH;
const disableCommitHash = commitSpecifier != CommitSpecifier.COMMIT_HASH;
const filteredCommitHashes =
Expand Down Expand Up @@ -298,7 +299,7 @@ function IPAForm({

<div className="relative pt-4">
<div className="block text-sm font-medium leading-6 text-gray-900">
Size
Input Size
</div>

<input
Expand Down Expand Up @@ -355,6 +356,28 @@ function IPAForm({
</div>
</div>

<div className="items-center pt-4">
<div className="block text-sm font-medium leading-6 text-gray-900">
Multi-threading
</div>
<div className="block pt-1 text-sm font-medium leading-6 text-gray-900">
<Switch
checked={multiThreadingEnabled}
onChange={setMultiThreadingEnabled}
name="multi_threading"
className={`${
multiThreadingEnabled ? "bg-blue-600" : "bg-gray-200"
} relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`}
>
<span
className={`${
multiThreadingEnabled ? "translate-x-6" : "translate-x-1"
} inline-block h-4 w-4 transform rounded-full bg-white transition-transform`}
/>
</Switch>
</div>
</div>

<button
type="submit"
className={clsx(
Expand Down
4 changes: 2 additions & 2 deletions sidecar/app/local_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Paths:
repo_path: Path
config_path: Path
commit_hash: str
compiled_id: str
_test_data_path: Optional[Path] = None

@property
Expand All @@ -22,7 +22,7 @@ def test_data_path(self, test_data_path: Path):

@property
def target_path(self) -> Path:
return self.repo_path / Path(f"target-{self.commit_hash}")
return self.repo_path / Path(f"target-{self.compiled_id}")

@property
def helper_binary_path(self) -> Path:
Expand Down
21 changes: 11 additions & 10 deletions sidecar/app/query/ipa.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class GateType(StrEnum):
@dataclass(kw_only=True)
class IPAQuery(Query):
paths: Paths
commit_hash: str

def send_kill_signals(self):
self.logger.info("sending kill signals")
Expand Down Expand Up @@ -119,7 +120,7 @@ class IPACheckoutCommitStep(LoggerOutputCommandStep):
def build_from_query(cls, query: IPAQuery):
return cls(
repo_path=query.paths.repo_path,
commit_hash=query.paths.commit_hash,
commit_hash=query.commit_hash,
logger=query.logger,
)

Expand All @@ -140,10 +141,9 @@ class IPACorrdinatorCompileStep(LoggerOutputCommandStep):
@classmethod
def build_from_query(cls, query: IPAQuery):
manifest_path = query.paths.repo_path / Path("Cargo.toml")
target_path = query.paths.repo_path / Path(f"target-{query.paths.commit_hash}")
return cls(
manifest_path=manifest_path,
target_path=target_path,
target_path=query.paths.target_path,
logger=query.logger,
)

Expand All @@ -163,6 +163,7 @@ class IPAHelperCompileStep(LoggerOutputCommandStep):
target_path: Path
gate_type: GateType
stall_detection: bool
multi_threading: bool
logger: loguru.Logger = field(repr=False)
status: ClassVar[Status] = Status.COMPILING

Expand All @@ -171,23 +172,22 @@ def build_from_query(cls, query: IPAHelperQuery):
manifest_path = query.paths.repo_path / Path("Cargo.toml")
gate_type = query.gate_type
stall_detection = query.stall_detection
target_path = query.paths.repo_path / Path(
f"target-{query.paths.commit_hash}-{gate_type}"
f"{'-stall-detection' if stall_detection else ''}"
)
multi_threading = query.multi_threading
return cls(
manifest_path=manifest_path,
target_path=target_path,
target_path=query.paths.target_path,
gate_type=gate_type,
stall_detection=stall_detection,
multi_threading=multi_threading,
logger=query.logger,
)

def build_command(self) -> LoggerOutputCommand:
return LoggerOutputCommand(
cmd=f"cargo build --bin helper --manifest-path={self.manifest_path} "
f'--features="web-app real-world-infra {self.gate_type} '
f"{'stall-detection' if self.stall_detection else ''}\" "
f'--features="web-app real-world-infra {self.gate_type}'
f"{' stall-detection' if self.stall_detection else ''}"
f"{' multi-threading' if self.multi_threading else ''}\" "
f"--no-default-features --target-dir={self.target_path} "
f"--release",
logger=self.logger,
Expand Down Expand Up @@ -401,6 +401,7 @@ class IPAHelperQuery(IPAQuery):
port: int
gate_type: GateType
stall_detection: bool
multi_threading: bool

step_classes: ClassVar[list[type[Step]]] = [
IPACloneStep,
Expand Down
15 changes: 13 additions & 2 deletions sidecar/app/routes/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,32 @@ def start_ipa_helper(
commit_hash: Annotated[str, Form()],
gate_type: Annotated[str, Form()],
stall_detection: Annotated[bool, Form()],
multi_threading: Annotated[bool, Form()],
background_tasks: BackgroundTasks,
):
# pylint: disable=too-many-arguments
role = settings.role
if not role or role == role.COORDINATOR:
raise Exception("Cannot start helper without helper role.")

compiled_id = (
f"{commit_hash}_{gate_type}"
f"{'_stall-detection' if stall_detection else ''}"
f"{'_multi-threading' if multi_threading else ''}"
)

paths = Paths(
repo_path=settings.root_path / Path("ipa"),
config_path=settings.config_path,
commit_hash=commit_hash,
compiled_id=compiled_id,
)
query = IPAHelperQuery(
paths=paths,
commit_hash=commit_hash,
query_id=query_id,
gate_type=GateType[gate_type.upper()],
stall_detection=stall_detection,
multi_threading=multi_threading,
port=settings.helper_port,
)
background_tasks.add_task(query.start)
Expand Down Expand Up @@ -92,12 +102,13 @@ def start_ipa_test_query(
paths = Paths(
repo_path=settings.root_path / Path("ipa"),
config_path=settings.config_path,
commit_hash=commit_hash,
compiled_id=commit_hash,
)
test_data_path = paths.repo_path / Path("test_data/input")
query = IPACoordinatorQuery(
query_id=query_id,
paths=paths,
commit_hash=commit_hash,
test_data_file=test_data_path / Path(f"events-{size}.txt"),
size=size,
max_breakdown_key=max_breakdown_key,
Expand Down

0 comments on commit 2934d4a

Please sign in to comment.