Skip to content

Commit

Permalink
keccak: improve perf a little (#2321)
Browse files Browse the repository at this point in the history
* avoid `burnMem`
* avoid zeroing buffers
* work around `when nimvm` issue
  • Loading branch information
arnetheduck committed Jun 7, 2024
1 parent 4e50b05 commit 32c51b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions scripts/block-import-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@

def readStats(name: str, min_block_number: int):
df = pd.read_csv(name).convert_dtypes()
if df.block_number.iloc[-1] > min_block_number:
cutoff = min(df.block_number.iloc[-1] - min_block_number, min_block_number)
# at least one item - let it lag in the beginning until we reach the min
# block number or the table will be empty
if df.block_number.iloc[-1] > min_block_number + df.block_number.iloc[0]:
cutoff = min(
df.block_number.iloc[-1] - min_block_number,
min_block_number,
)
df = df[df.block_number >= cutoff]
df.set_index("block_number", inplace=True)
df.time /= 1000000000
Expand Down Expand Up @@ -43,7 +48,7 @@ def prettySecs(s: float):
def formatBins(df: pd.DataFrame, bins: int):
if bins > 0:
bins = np.linspace(
df.block_number.iloc[0], df.block_number.iloc[-1], bins, dtype=int
df.block_number.iloc[0] - df.blocks.iloc[0], df.block_number.iloc[-1], bins, dtype=int
)
return df.groupby(pd.cut(df["block_number"], bins), observed=True)
else:
Expand All @@ -68,15 +73,15 @@ def formatBins(df: pd.DataFrame, bins: int):
)
args = parser.parse_args()

baseline = readStats(args.baseline, args.min_block_number)
baseline = readStats(args.baseline, 0)
contender = readStats(args.contender, args.min_block_number)

# Pick out the rows to match - a more sophisticated version of this would
# interpolate, perhaps - also, maybe should check for non-matching block/tx counts
df = baseline.merge(contender, on=("block_number", "blocks", "txs"))

df["bpsd"] = ((df.bps_y - df.bps_x) / df.bps_x).fillna(0)
df["tpsd"] = ((df.tps_y - df.tps_x) / df.tps_x).fillna(0)
df["bpsd"] = ((df.bps_y - df.bps_x) / df.bps_x)
df["tpsd"] = ((df.tps_y - df.tps_x) / df.tps_x.replace(0, 1))
df["timed"] = (df.time_y - df.time_x) / df.time_x

df.reset_index(inplace=True)
Expand Down Expand Up @@ -131,10 +136,8 @@ def formatBins(df: pd.DataFrame, bins: int):
time_xt = df.time_x.sum()
time_yt = df.time_y.sum()

timet = time_yt-df.time_x.sum()
print(
f"Time (total): {prettySecs(timet)}, {(timet/time_xt):.2%}"
)
timet = time_yt - df.time_x.sum()
print(f"Time (total): {prettySecs(timet)}, {(timet/time_xt):.2%}")

print()
print(
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-eth
2 changes: 1 addition & 1 deletion vendor/nimcrypto
Submodule nimcrypto updated 1 files
+54 −53 nimcrypto/keccak.nim

0 comments on commit 32c51b1

Please sign in to comment.