Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chainntnfs/btcdnotify: make copy of transactions to include in spend … #1400

Closed
wants to merge 1 commit into from

Conversation

Roasbeef
Copy link
Member

…details

In this commit, we make an attempt to fix a run away memory usage bug
that appears at times in lnd. Due to the underlying allocator when
decoding blocks, it's the case that if we hold onto a single transaction
in an object, then since it points to a buffer that's used to allocate
all scripts in a block, that buffer will never be freed. To remedy this,
we'll now copy the transaction over, in the hope that this will sever
the pointer allowing the script bytes to be de-allocated.

…details

In this commit, we make an attempt to fix a run away memory usage bug
that appears at times in lnd. Due to the underlying allocator when
decoding blocks, it's the case that if we hold onto a single transaction
in an object, then since it points to a buffer that's used to allocate
all scripts in a block, that buffer will never be freed. To remedy this,
we'll now copy the transaction over, in the hope that this will sever
the pointer allowing the script bytes to be de-allocated.
@Roasbeef
Copy link
Member Author

This PR is attempting to fix this behavior:

Fetching profile over HTTP from http://localhost:5000:/debug/pprof/heap
Saved profile in /root/pprof/pprof.lnd-debug.alloc_objects.alloc_space.inuse_objects.inuse_space.050.pb.gz
File: lnd-debug
Type: inuse_space
Time: Jun 16, 2018 at 1:50am (UTC)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top 25 -cum
Showing nodes accounting for 364.84MB, 96.67% of 377.41MB total
Dropped 112 nodes (cum <= 1.89MB)
      flat  flat%   sum%        cum   cum%
         0     0%     0%   360.16MB 95.43%  github.com/lightningnetwork/lnd/chainntnfs/btcdnotify.(*BtcdNotifier).notificationDispatcher
         0     0%     0%   330.13MB 87.47%  github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcd/rpcclient.(*Client).GetBlock
         0     0%     0%   330.13MB 87.47%  github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcd/rpcclient.FutureGetBlockResult.Receive
      23MB  6.09%  6.09%   330.13MB 87.47%  github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcd/wire.(*MsgBlock).BtcDecode
         0     0%  6.09%   330.13MB 87.47%  github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcd/wire.(*MsgBlock).Deserialize
  306.13MB 81.11% 87.21%   307.13MB 81.38%  github.com/lightningnetwork/lnd/vendor/github.com/roasbeef/btcd/wire.(*MsgTx).BtcDecode

@Roasbeef
Copy link
Member Author

Closing this for now, as have been running the latest version of master which includes some fixes for block epochs that were never cancelled. Been running for 5 days so far, and it appears to do the trick....will keep an 👀 on this

@Roasbeef Roasbeef closed this Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant