Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
xmr: sign_tx unimport optimization to reduce fragmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Sep 27, 2018
1 parent df0a1df commit c11c468
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/apps/monero/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@

async def sign_tx(ctx, received_msg):
state = State(ctx)
mods = utils.unimport_begin()

# Splitting ctx.call() to write() and read() helps to reduce memory fragmentation
# between calls.
while True:
if __debug__:
log.debug(__name__, "#### F: %s, A: %s", gc.mem_free(), gc.mem_alloc())
gc.collect()
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())

mods = utils.unimport_begin()
result_msg, accept_msgs = await sign_tx_dispatch(state, received_msg)
utils.unimport_end(mods)

if accept_msgs is None:
break
received_msg = await ctx.call(result_msg, *accept_msgs)

await ctx.write(result_msg)
del (result_msg, received_msg)
utils.unimport_end(mods)

received_msg = await ctx.read(accept_msgs)

utils.unimport_end(mods)
return result_msg


Expand Down

0 comments on commit c11c468

Please sign in to comment.