cli: remove implementation of eden strace

Summary:
This is the same as `eden trace fs`, redirect people to that. The command will
simply be removed later.

Reviewed By: fanzeyi

Differential Revision: D35483104

fbshipit-source-id: bdacda6c5e6f9d8d809f44b64b1178aacbee4228
This commit is contained in:
Xavier Deguillard 2022-04-08 12:09:27 -07:00 committed by Facebook GitHub Bot
parent ab764ac950
commit d6f5cad598

View File

@ -972,99 +972,8 @@ class StraceCmd(Subcmd):
)
async def run(self, args: argparse.Namespace) -> int:
from eden.fs.service.streamingeden.types import (
FsEventType,
FS_EVENT_READ,
FS_EVENT_WRITE,
)
instance, checkout, _rel_path = require_checkout(args, args.checkout)
async with await instance.get_thrift_client() as client:
mask = 0
if args.reads:
mask |= FS_EVENT_READ
if args.writes:
mask |= FS_EVENT_WRITE
# Start tracing before querying outstanding fuse requests so none are missed.
trace = await client.traceFsEvents(os.fsencode(checkout.path), mask)
calls = await client.debugOutstandingFuseCalls(os.fsencode(checkout.path))
if calls:
self.print_outstanding_calls(calls)
active_requests = {}
async for event in trace:
unique = event.fuseRequest.unique
if event.type == FsEventType.START:
active_requests[unique] = event
print(
"+",
self.format_call(event.fuseRequest, arguments=event.arguments),
)
elif event.type == FsEventType.FINISH:
formatted_call = self.format_call(
event.fuseRequest, result=event.result
)
if unique in active_requests:
print(
"-",
formatted_call,
"in",
self.format_time(
event.monotonic_time_ns
- active_requests[unique].monotonic_time_ns
),
)
else:
print("-", formatted_call)
print(f"{checkout.path} was unmounted")
return 0
def print_outstanding_calls(self, calls: List[FuseCall]) -> None:
header = "Outstanding FUSE calls"
print(header)
print("-" * len(header))
for call in calls:
print(self.format_call(call))
print("-" * len(header))
def format_opcode(self, call: FuseCall) -> str:
if not call.opcodeName:
return f"unknown-{call.opcode}"
name = call.opcodeName
if name.startswith("FUSE_"):
return name[5:].lower()
return name
def format_call(
self,
call: FuseCall,
arguments: Optional[str] = None,
result: Optional[int] = None,
) -> str:
processName = call.processName
if processName is None:
processName = str(call.pid)
else:
processName = f"{processName.split(chr(0))[0]}({call.pid})"
opcodeName = self.format_opcode(call)
argString = ""
if arguments:
argString = f"({call.nodeid}, {arguments})"
else:
argString = f"({call.nodeid})"
tail = ""
if result is not None:
tail = f" = {result}"
return f"{call.unique} from {processName}: {opcodeName}{argString}{tail}"
def format_time(self, ns: float) -> str:
return "{:.3f} µs".format(ns / 1000.0)
print_stderr("No longer supported, use `eden trace fs` instead.")
return 1
@subcmd("top", "Monitor EdenFS accesses by process.")