Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vincent Pelletier
neoppod
Commits
c25e68bc
Commit
c25e68bc
authored
Dec 01, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: speed up replication by sending bigger network packets
parent
96aeb716
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
14 deletions
+36
-14
neo/lib/connection.py
neo/lib/connection.py
+10
-1
neo/lib/connector.py
neo/lib/connector.py
+4
-0
neo/lib/protocol.py
neo/lib/protocol.py
+5
-0
neo/storage/app.py
neo/storage/app.py
+2
-7
neo/storage/database/importer.py
neo/storage/database/importer.py
+2
-2
neo/storage/handlers/storage.py
neo/storage/handlers/storage.py
+13
-4
No files found.
neo/lib/connection.py
View file @
c25e68bc
...
...
@@ -305,6 +305,7 @@ class Connection(BaseConnection):
# XXX: rename isPending, hasPendingMessages & pending methods
buffering
=
False
connecting
=
True
client
=
False
server
=
False
...
...
@@ -541,7 +542,15 @@ class Connection(BaseConnection):
def
_addPacket
(
self
,
packet
):
"""Add a packet into the write buffer."""
if
self
.
connector
.
queue
(
packet
.
encode
()):
# enable polling for writing.
if
packet
.
nodelay
or
65536
<
self
.
connector
.
queue_size
:
assert
not
self
.
buffering
# enable polling for writing.
self
.
em
.
addWriter
(
self
)
else
:
self
.
buffering
=
True
elif
self
.
buffering
and
(
65536
<
self
.
connector
.
queue_size
or
packet
.
nodelay
):
self
.
buffering
=
False
self
.
em
.
addWriter
(
self
)
logging
.
packet
(
self
,
packet
,
True
)
...
...
neo/lib/connector.py
View file @
c25e68bc
...
...
@@ -72,11 +72,13 @@ class SocketConnector(object):
# disable Nagle algorithm to reduce latency
s
.
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
1
)
self
.
queued
=
[
ENCODED_VERSION
]
self
.
queue_size
=
len
(
ENCODED_VERSION
)
return
self
def
queue
(
self
,
data
):
was_empty
=
not
self
.
queued
self
.
queued
+=
data
self
.
queue_size
+=
len
(
data
)
return
was_empty
def
_error
(
self
,
op
,
exc
=
None
):
...
...
@@ -183,8 +185,10 @@ class SocketConnector(object):
# could be sent.
if
n
!=
len
(
msg
):
self
.
queued
[:]
=
msg
[
n
:],
self
.
queue_size
-=
n
return
False
del
self
.
queued
[:]
self
.
queue_size
=
0
else
:
assert
not
self
.
queued
return
True
...
...
neo/lib/protocol.py
View file @
c25e68bc
...
...
@@ -224,6 +224,7 @@ class Packet(object):
_code
=
None
_fmt
=
None
_id
=
None
nodelay
=
True
poll_thread
=
False
def
__init__
(
self
,
*
args
):
...
...
@@ -1441,6 +1442,8 @@ class AddTransaction(Packet):
"""
S -> S
"""
nodelay
=
False
_fmt
=
PStruct
(
'add_transaction'
,
PTID
(
'tid'
),
PString
(
'user'
),
...
...
@@ -1480,6 +1483,8 @@ class AddObject(Packet):
"""
S -> S
"""
nodelay
=
False
_fmt
=
PStruct
(
'add_object'
,
POID
(
'oid'
),
PTID
(
'serial'
),
...
...
neo/storage/app.py
View file @
c25e68bc
...
...
@@ -254,9 +254,8 @@ class Application(BaseApplication):
while
task_queue
:
try
:
while
isIdle
():
if
task_queue
[
-
1
].
next
():
_poll
(
0
)
task_queue
.
rotate
()
next
(
task_queue
[
-
1
])
or
task_queue
.
rotate
()
_poll
(
0
)
break
except
StopIteration
:
task_queue
.
pop
()
...
...
@@ -270,10 +269,6 @@ class Application(BaseApplication):
self
.
replicator
.
stop
()
def
newTask
(
self
,
iterator
):
try
:
iterator
.
next
()
except
StopIteration
:
return
self
.
task_queue
.
appendleft
(
iterator
)
def
closeClient
(
self
,
connection
):
...
...
neo/storage/database/importer.py
View file @
c25e68bc
...
...
@@ -388,7 +388,7 @@ class ImporterDatabaseManager(DatabaseManager):
finish
()
txn
=
z
.
transaction
tid
=
txn
.
tid
yield
1
yield
zodb
=
z
.
zodb
for
r
in
z
.
transaction
:
oid
=
p64
(
u64
(
r
.
oid
)
+
zodb
.
shift_oid
)
...
...
@@ -413,7 +413,7 @@ class ImporterDatabaseManager(DatabaseManager):
# update 'obj' with 'object_list', some rows in 'data' may be
# unreferenced. This is not a problem because the leak is
# solved when resuming the migration.
yield
1
yield
try
:
z
.
next
()
except
StopIteration
:
...
...
neo/storage/handlers/storage.py
View file @
c25e68bc
...
...
@@ -157,7 +157,7 @@ class StorageOperationHandler(EventHandler):
conn
.
send
(
Packets
.
AnswerCheckTIDRange
(
*
r
),
msg_id
)
except
(
weakref
.
ReferenceError
,
ConnectionClosed
):
pass
yield
return
;
yield
app
.
newTask
(
check
())
@
checkFeedingConnection
(
check
=
True
)
...
...
@@ -173,7 +173,7 @@ class StorageOperationHandler(EventHandler):
conn
.
send
(
Packets
.
AnswerCheckSerialRange
(
*
r
),
msg_id
)
except
(
weakref
.
ReferenceError
,
ConnectionClosed
):
pass
yield
return
;
yield
app
.
newTask
(
check
())
@
checkFeedingConnection
(
check
=
False
)
...
...
@@ -209,9 +209,17 @@ class StorageOperationHandler(EventHandler):
%
partition
),
msg_id
)
return
oid_list
,
user
,
desc
,
ext
,
packed
,
ttid
=
t
# Sending such packet does not mark the connection
# for writing if there's too little data in the buffer.
conn
.
send
(
Packets
.
AddTransaction
(
tid
,
user
,
desc
,
ext
,
packed
,
ttid
,
oid_list
),
msg_id
)
yield
# To avoid delaying several connections simultaneously,
# and also prevent the backend from scanning different
# parts of the DB at the same time, we ask the
# scheduler not to switch to another background task.
# Ideally, we are filling a buffer while the kernel
# is flushing another one for a concurrent connection.
yield
conn
.
buffering
conn
.
send
(
Packets
.
AnswerFetchTransactions
(
pack_tid
,
next_tid
,
peer_tid_set
),
msg_id
)
yield
...
...
@@ -253,9 +261,10 @@ class StorageOperationHandler(EventHandler):
"partition %u dropped or truncated"
%
partition
),
msg_id
)
return
# Same as in askFetchTransactions.
conn
.
send
(
Packets
.
AddObject
(
oid
,
serial
,
*
object
[
2
:]),
msg_id
)
yield
yield
conn
.
buffering
conn
.
send
(
Packets
.
AnswerFetchObjects
(
pack_tid
,
next_tid
,
next_oid
,
object_dict
),
msg_id
)
yield
...
...
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