Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Speed-ups (shasum + poetry install caching) #91

Merged
merged 8 commits into from
Mar 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Log error if hashing takes more than 3 seconds
  • Loading branch information
skovhus committed Mar 3, 2021
commit 50906a8c2186b76d6bc4bfd534aa18a17b40dc9c
7 changes: 7 additions & 0 deletions brick/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,18 @@ def compute_hash_from_paths(paths: List[str]) -> str:
if not paths:
raise ValueError("Expected input paths")

t_start = time.time()
sha1_command = get_sha1_command()
cmd = f"find {' '.join(paths)} -type f -print0 | sort -z | xargs -0 {sha1_command} | {sha1_command}"
sha1_sum: str = run_shell_command(cmd=cmd, cwd=ROOT_PATH).split(" ")[0].strip()
assert len(sha1_sum) == 40, "expected sha1sum of length 40"

# Wasting more than a few seconds hashing usually means that the input dependencies
# should be tweaked.
hashing_time = time.time() - t_start
if hashing_time > 3:
logger.info(f'😴 Observed slow hashing ({hashing_time:.1f}s) for command "{cmd}"')

return sha1_sum


Expand Down