-
Notifications
You must be signed in to change notification settings - Fork 193
Performance Tuning #56
Comments
The first two points should provide a huge performance boost if handled appropriately. |
I just wanted to come here and propose point number 1 after reading your noteboook and then found out that you are already thinking about it :) I can confirm that reading a block into a buffer is a significant improvement on a proprietary TCP protocol with sized framing. Right now the buffer is a simple string which gets expanded after socket.recv. But there might be more efficient alternatives. Maybe socket.recv_info can be used with a StringIO or something like that. Do you have some ideas for an efficient buffer implementation? Anything that helps with point two would be great. :) |
On a related note, please be more thorough than if sys.platform.lower().startswith("linux"):
def _rusage():
tmp = resource.getrusage(1) # RUSAGE_THREAD
return dict(time=time.time(), # wall
utime=tmp.ru_utime, # user
stime=tmp.ru_stime, # system
switch=tmp.ru_nivcsw * 1., # cpu contention
read=tmp.ru_inblock * 512., # disk io
write=tmp.ru_oublock * 512.,
fault=tmp.ru_majflt * 1.) # memory contention |
@dimaqq Good advice, though I was running the notebook on OS X, which would have limited the utility of that function. Might be worth me going back and adding it just for those who run on other platforms though, I'll have a think. @schlamar I'm not yet sure, I don't know enough about efficient buffers in Python. Note sure that More ideally we'd like to be able to use a fixed-size buffer as a ring buffer. I've never seen this done in Python, let-alone in pure Python, and I don't know that it's possible. I'll need to think about how I'd pull it off. |
@Lukasa do you really want a ring buffer? If I remember correctly, won't it write over old data in the buffer it isn't read quickly enough? |
The general plan is no. =) Of course, that's almost certainly impossible to do without C extensions, which I can't do. So it'll be easier to do as a single linear buffer. |
For what it's worth, I can think of a way to enforce that with a |
Sadly, I don't think you can use |
guys, I think this socket reading conversation is moot. |
TLS still uses sockets. =) |
It's also totally allowed to use HTTP/2 in plaintext. =) |
Do we have any benchmarks showing the performance benefits? (Call me a pain if you will ;P) |
Not yet, but I plan to re-run my big HTTP/1.1 - HTTP/2 comparison at some point to see how the numbers change. |
In the meantime, pypy's test run speed got a big boost when I fixed the tests up, so anecdotally it 'feels' faster. |
I didn't doubt it was faster. I was just trying to pre-empt some people from finding this and complaining about lack of benchmarks. |
Agreed, I'll try to get some numbers. =) |
Support for nghttp2's HPACK implementation is now present. |
hyper
is not optimised for performance right now. While the HTTP/2 spec is changing I want to focus on correctness and the ability to easily change behaviour.However, when it does get nailed down we'll want to make some steps to improve performance. Roberto Peon has provided an awesome list of things to work on, which I've reproduced here. People should take things off this list and break them out into new issues as they go.
socket.read()
per frame, we should read into a buffer and then parse the buffer. Avoids repeated kernel-userspace transitions.nghttp2
's C HPACK implementation. (Add optional support for nghttp2's HPACK implementation #60)memoryview
objects in hyper's pure-Python HPACK implementation. (Use memoryviews in HPACK #61)Other intelligent performance optimisations should be added here.
The text was updated successfully, but these errors were encountered: