Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
1b29e2c9
Unverified
Commit
1b29e2c9
authored
May 31, 2021
by
Janoš Guljaš
Committed by
GitHub
May 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf(pullsync): release reader buffer in handler (#1917)
parent
224cdae9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
pullsync.go
pkg/pullsync/pullsync.go
+6
-1
No files found.
pkg/pullsync/pullsync.go
View file @
1b29e2c9
...
@@ -260,7 +260,7 @@ func (s *Syncer) SyncInterval(ctx context.Context, peer swarm.Address, bin uint8
...
@@ -260,7 +260,7 @@ func (s *Syncer) SyncInterval(ctx context.Context, peer swarm.Address, bin uint8
// handler handles an incoming request to sync an interval
// handler handles an incoming request to sync an interval
func
(
s
*
Syncer
)
handler
(
ctx
context
.
Context
,
p
p2p
.
Peer
,
stream
p2p
.
Stream
)
(
err
error
)
{
func
(
s
*
Syncer
)
handler
(
ctx
context
.
Context
,
p
p2p
.
Peer
,
stream
p2p
.
Stream
)
(
err
error
)
{
w
,
r
:=
protobuf
.
NewWriterAnd
Reader
(
stream
)
r
:=
protobuf
.
New
Reader
(
stream
)
defer
func
()
{
defer
func
()
{
if
err
!=
nil
{
if
err
!=
nil
{
_
=
stream
.
Reset
()
_
=
stream
.
Reset
()
...
@@ -311,6 +311,11 @@ func (s *Syncer) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (er
...
@@ -311,6 +311,11 @@ func (s *Syncer) handler(ctx context.Context, p p2p.Peer, stream p2p.Stream) (er
return
fmt
.
Errorf
(
"make offer: %w"
,
err
)
return
fmt
.
Errorf
(
"make offer: %w"
,
err
)
}
}
// recreate the reader to allow the first one to be garbage collected
// before the makeOffer function call, to reduce the total memory allocated
// while makeOffer is executing (waiting for the new chunks)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
if
err
:=
w
.
WriteMsgWithContext
(
ctx
,
offer
);
err
!=
nil
{
if
err
:=
w
.
WriteMsgWithContext
(
ctx
,
offer
);
err
!=
nil
{
return
fmt
.
Errorf
(
"write offer: %w"
,
err
)
return
fmt
.
Errorf
(
"write offer: %w"
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment