-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Performance optimizations and memory management #221
Conversation
Travis build fails because sync.Pool only exists in 1.3+ |
Let's update the install instructions to Go 1.3+ |
s.BufPool.New = func() interface{} { | ||
return make([]byte, maxMsgLen) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sync.Pool
allocation should happen only on NewChan
, otherwise, i can pass use NewChanWithPool(n, something)
and if something
is nil, it would not fail, and would be really, really hard to track down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm... that is fair... What do you suggest?
|
@@ -228,3 +228,21 @@ func (n *DAGService) Remove(nd *Node) error { | |||
} | |||
return n.Blocks.DeleteBlock(k) | |||
} | |||
|
|||
func FetchGraph(ctx context.Context, root *Node, serv *DAGService) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Fetch/Get/. Fetch is weird.
And, add a comment. Get a linter package for your editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose fetch because it matches the semantics of git fetch
as this only grabs the data in this DAG and stores it locally, and doesnt update or return anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. You had me at git fetch
😄
@whyrusleeping ok, CRed |
1fd1855
to
8716912
Compare
@@ -19,13 +21,35 @@ func NewChan(chanSize int) *Chan { | |||
} | |||
} | |||
|
|||
func NewChanWithPool(chanSize int, pool *sync.Pool) *Chan { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whyrusleeping I merged jbenet/go-msgio#2 -- vendor this
@whyrusleeping very useful pr, can't wait to have it land.
|
This PR introduces (or maybe it was already there) use of |
Go 1.2 is no longer supported (we use sync.Pool).
Performance optimizations and memory management
@whyrusleeping i merged this |
<3 |
Added some benchmarks to secure channel and played around with improving its performance, also started using a sync.Pool for message buffers.