keccak: improve perf a little (#2321)

* avoid `burnMem`
* avoid zeroing buffers
* work around `when nimvm` issue
This commit is contained in:
Jacek Sieka 2024-06-07 18:48:27 +02:00 committed by GitHub
parent 4e50b05564
commit 32c51b14a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 12 deletions

View File

@ -14,8 +14,13 @@ register_matplotlib_converters()
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
@ -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:
@ -68,15 +73,15 @@ parser.add_argument(
)
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)
@ -131,10 +136,8 @@ print(f"tpsd (mean): {df.tpsd.mean():.2%}")
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(

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit d935c0de47a69de58b37b47b601f75f8a05def00
Subproject commit c02e050db8c60010b1e779d81c9d0f033f88d410

2
vendor/nimcrypto vendored

@ -1 +1 @@
Subproject commit 485f7b3cfa83c1beecc0e31be0e964d697aa74d7
Subproject commit 71bca15508e2c0548f32b42a69bcfb1ccd9ab9ff