Ticket #585 (new enhancement)

Opened 6 years ago

Last modified 6 months ago

Include sendfile(2) support into defaultreactor and make twisted.web use it

Reported by: PenguinOfDoom Owned by: therve
Priority: normal Milestone:
Component: core Keywords:
Cc: radix, exarkun, spiv, itamarst, PenguinOfDoom, therve Branch: branches/sendfile-585-4
Author: therve Launchpad Bug:

Description


Change History

Changed 6 years ago by PenguinOfDoom

I've done a quick hack to this effect. It seems that sendfile(2)-enhanced
twisted.web is significantly closer to Apache speeds on large (5MB) files.
Benchmarks will be posted once somebody figures out how to properly measure the
speed.

Changed 6 years ago by glyph

can you upload a patch, even if it's a nasty hack?

Changed 5 years ago by spiv

Where's the patch?

Changed 4 years ago by exarkun

Yea where's the patch?

Changed 3 years ago by therve

  • cc therve added

Changed 3 years ago by therve

  • owner changed from PenguinOfDoom to therve

Changed 3 years ago by therve

For people interested, I've try to update PenguinOfDoom's work in sendfile-585, and it seems to work fine.

Changed 3 years ago by jknight

Not having looked at the patch yet, some test suggestions:

1) If the sendfile syscall is present, but fails, the code deals sanely (fallback to read/send, I suppose, or else some kind of notification?)

1b) what if it fails because the file is unreadable or has an I/O error of some kind?

2) SSL sockets don't support sendfile

3) it works, or at least, doesn't blow up on *BSD (which has a sendfile, with a different signature)

Changed 3 years ago by exarkun

From a quick skim of the branch, a couple thoughts:

  • there should be a new interface including sendfile (if having a sendfile method is the right way to expose this). hasattr/getattr calls like the one in static.py result in bugs
  • fallback should be provided if the syscall is missing too (in addition to the case where it's present but fails), so code doesn't end up with checks littered all over.

Changed 3 years ago by therve

Replying to jknight:

Not having looked at the patch yet, some test suggestions:

Thanks.

1) If the sendfile syscall is present, but fails, the code deals sanely (fallback to read/send, I suppose, or else some kind of notification?)

For now, that closes the connection.

1b) what if it fails because the file is unreadable or has an I/O error of some kind?

Same as above.

I'm interested to know what behavior we could choose.

2) SSL sockets don't support sendfile

Yes that's disabled, even thought I'm not really happy about the mecanism (value of the sendfile attribute)

3) it works, or at least, doesn't blow up on *BSD (which has a sendfile, with a different signature)

I didn't do that yet, but it's interesting.

Changed 3 years ago by therve

  • branch set to branches/sendfile-585-2
  • author set to therve

(In [22235]) Branching to 'sendfile-585-2'

Changed 3 years ago by therve

(In [22239]) Docs and cleanups.

Refs #585

Changed 2 years ago by therve

  • branch changed from branches/sendfile-585-2 to branches/sendfile-585-3

(In [23312]) Branching to 'sendfile-585-3'

Changed 2 years ago by exarkun

  • component changed from web to core

This is cool. I am going to call it a core ticket, though, since it's about extending the reactor interface.

Changed 6 months ago by therve

  • branch changed from branches/sendfile-585-3 to branches/sendfile-585-4

(In [28626]) Branching to 'sendfile-585-4'

Note: See TracTickets for help on using tickets.