Skip to content

Conversation

mundya
Copy link
Member

@mundya mundya commented Apr 27, 2015

Uses sliding window protocol to increase speed for bursts of SCP messages.

As of 14th May this results in reads and writes to chip (0, 0) of around 30+Mbit/s when using a window size of 8. When using a window size of 1 this drops to (a still respectable) 12ish Mbit/s on my test machine.

  • Neaten documentation
  • Rework send_scp to send a burst of one message (mostly to
    reduce duplication of code)
  • Fill in a few gaps in the tests.
  • Set the default window size to 1
  • Correctly query the window size from SC&MP For a later PR
  • Set the transient IPTag timeout correctly For a later PR

@mundya
Copy link
Member Author

mundya commented Apr 27, 2015

Looks like this will be plagued by timeouts...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default should be 1, should actually query the machine to determine what this value is.

**Supercedes #115**

Uses sliding window protocol to increase speed for bursts of SCP
messages.

Talking to a locally connection SpiNN3 I'm hitting 20+ Mb/s for both writes and
reads to (chip 0, 0).

 - [x] Neaten documentation
 - [x] Rework `send_scp` to send a burst of one message (mostly to
       reduce duplication of code)
 - [x] Fill in a few gaps in the tests.
 - [ ] Set the default window size to 1
 - [ ] Correctly query the window size from SC&MP
 - [ ] Set the transient IPTag timeout correctly
@mundya mundya force-pushed the even-faster-scp-rw2 branch from 3ebcdaf to e183fce Compare April 27, 2015 16:09
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default mask can, I think, be safely 0xffff (and should be).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unpack_from would make sense here.

mundya added 3 commits May 13, 2015 21:11
Further increases SCP performance on reads and writes by not unpacking
SCP packets unless absolutely necessary.
@mundya
Copy link
Member Author

mundya commented May 13, 2015

With tonight's changes this is pushing nearer to 27+Mib/s on 10MiB reads and writes to a locally connected Spin3 board.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good... (the padding bytes are already included in outstanding.packet) and probably explains the frequent time outs. This is also a bug in the tests.

mundya added 2 commits May 14, 2015 07:13
Previously the padding bytes were being included twice in retransmitted
packets. This fixes that bug and introduces a test to ensure that
retransmitted packets are transmitted exactly.
@mundya mundya force-pushed the even-faster-scp-rw2 branch from 4d83ffd to f25c795 Compare May 14, 2015 06:21
@mundya
Copy link
Member Author

mundya commented May 14, 2015

Cancelling running tests is a bad thing that I shouldn't do...

@mossblaser
Copy link
Member

Is it a bad thing?

@mundya
Copy link
Member Author

mundya commented May 14, 2015

With the window size set to 1 this branch gets reads and writes at around 11-12Mbit/s against my local board (0, 0) and 5Mbit/s against (1, 1). (Master is at around 8-9Mbit/s and 4Mbit/s.)

@mossblaser do we want to consider merging this now with the window size set to 1? We can investigate setting the TTO and reading the window size in an additional PR.

@mossblaser
Copy link
Member

Via a switch on my machine, window size = 1 I get:

Finished write after 11422 ms. Throughput = 7.00 Mbit/s
Finished read after 11520 ms. Throughput = 6.94 Mbit/s

Just upping the window now...

@mossblaser
Copy link
Member

..and with window size 8:

Finished write after 2441 ms. Throughput = 32.78 Mbit/s
Finished read after 2404 ms. Throughput = 33.28 Mbit/s

Very good!

@mundya
Copy link
Member Author

mundya commented May 14, 2015

Yay C-like performance :)

@mossblaser
Copy link
Member

If you want a laugh... here's the C numbers:

Writing 10485760 bytes of random data to 0x60240000...
Write completed in 2463 ms! Throughput = 32.481 Mbit/s.

Reading back 10485760 bytes from 0x60240000...
Read completed in 2619 ms! Throughput = 30.546 Mbit/s.

...so you beat rig-scp ;) :P

@mundya
Copy link
Member Author

mundya commented May 14, 2015

PyPy time :P

@mossblaser
Copy link
Member

@mossblaser do we want to consider merging this now with the window size set to 1? We can investigate setting the TTO and reading the window size in an additional PR.

I would say that seems like a good idea. Will have a look over the code as it stands first though :)

@mundya
Copy link
Member Author

mundya commented May 14, 2015

Will have a look over the code as it stands first though :)

Of course!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a closure not be sufficient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because the received packet has to be stored somewhere.

In Python 3 I can do:

packet = None
def callback(received_bytes):
    nonlocal packet
    packet = ...

But not in Python 2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the format string at the start not imply the length here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Why? The constant is the offset.

@mossblaser
Copy link
Member

Looks jolly good to me, though that excludes the busy loop(!) which should be an easy enough fix and drop the CPU loading down a fair bit. Plus would save a load of "get time" system calls (so actual performance may be ever-so-slightly improved... but that is a dubious claim ;)).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted by @mossblaser: this should be a while

@mossblaser mossblaser mentioned this pull request May 14, 2015
mundya added 3 commits May 14, 2015 09:17
 - Reduces the number of calls to create a bytestring
 - Implements @mossblaser suggestion of calling `iter` on
   `parameters_and_callbacks`.
@mundya
Copy link
Member Author

mundya commented May 14, 2015

I'm finding that select, and switching to using a while instead of an if make for a fairly significant performance hit. You're welcome to play.

@mundya
Copy link
Member Author

mundya commented May 14, 2015

Also, that 100% is not 100%... there's a branch missing in scp_connection.py.

Interprets some error codes (RC_P2P_xxx) as if they were a timeout.
With a modest window size this allows correct behaviour when talking to
anything but an ethernet connected chip.
@mundya
Copy link
Member Author

mundya commented May 14, 2015

With the exception of select, which I graciously leave open for @mossblaser to do, I'm happy that we consider this for merging soon. Tasks for SpiNNaker 1.4 are to investigate querying the correct window size and setting the TTO.

mossblaser and others added 2 commits May 15, 2015 13:48
This bizarrely introduces some overhead which, despite numerous attempts to
track down its source, has not entirely been eliminated. That said, it does
bring the CPU load *way* down.

Strangely, this patch negatively impacts write performance slightly (for both
0,0 and 1,1) and read performance for 0,0 but positively impacts read
performance for 1,1.

Further experimentation is required...
@mossblaser, I've fixed a broken test. There are still failing tests for you to
investigate.
@mundya
Copy link
Member Author

mundya commented May 29, 2015

@mossblaser, if I merge in your select work and get the tests to pass again can we consider merging this soon?

mundya added 2 commits May 29, 2015 21:27
 - Mocks out "select" so that it will work with mocks.
 - Changes tests to deal with slight change in send/receive operation.
@mundya mundya mentioned this pull request May 29, 2015
`min` doesn't have a keyword `default` earlier than Python 3.4, this
removes the requirement and adds a test that tests the newly added
branch works correctly.
@mossblaser
Copy link
Member

That sounds like a plan :) thanks!

Jonathan
On 29 May 2015 18:24, "Andrew Mundy" notifications@github.com wrote:

@mossblaser https://github.com/mossblaser, if I merge in your select
work and get the tests to pass again can we consider merging this soon?


Reply to this email directly or view it on GitHub
#117 (comment).

@mundya
Copy link
Member Author

mundya commented May 31, 2015

I'm not sure what's up with Coveralls... coverage remains at 100% though. @mossblaser, are we happy with this?

@mossblaser
Copy link
Member

Yep I'm happy. Silly Coveralls... Merge and release at will! Sorry about the delay ;)

mossblaser added a commit that referenced this pull request Jun 2, 2015
@mossblaser mossblaser merged commit fdfb28c into master Jun 2, 2015
@mossblaser mossblaser deleted the even-faster-scp-rw2 branch June 2, 2015 07:09
@mundya
Copy link
Member Author

mundya commented Jun 2, 2015

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants