Re: [hybi] Background info: Properties of sendfile()

Greg Wilkins <gregw@webtide.com> Fri, 06 August 2010 04:18 UTC

Return-Path: <gregw@webtide.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 77F4B3A6888 for <hybi@core3.amsl.com>; Thu, 5 Aug 2010 21:18:18 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.755
X-Spam-Level:
X-Spam-Status: No, score=-1.755 tagged_above=-999 required=5 tests=[AWL=0.222, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id czY6Vz2TNHBt for <hybi@core3.amsl.com>; Thu, 5 Aug 2010 21:18:16 -0700 (PDT)
Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by core3.amsl.com (Postfix) with ESMTP id C7D2B3A68B0 for <hybi@ietf.org>; Thu, 5 Aug 2010 21:18:15 -0700 (PDT)
Received: by fxm16 with SMTP id 16so3043024fxm.31 for <hybi@ietf.org>; Thu, 05 Aug 2010 21:18:46 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.223.114.9 with SMTP id c9mr11979991faq.59.1281068326292; Thu, 05 Aug 2010 21:18:46 -0700 (PDT)
Received: by 10.223.57.12 with HTTP; Thu, 5 Aug 2010 21:18:46 -0700 (PDT)
In-Reply-To: <20100806024316.GK27827@shareable.org>
References: <4C5B1695.6070704@gmx.de> <F8E2F702-9F74-4316-B3B2-D5A731409ABF@apple.com> <4C5B2029.90403@gmx.de> <AANLkTim1WeCRfcPxXUNQcVhb4+t_TtDQDv2bXaxOQ=bk@mail.gmail.com> <01098AD0-FBF4-4A61-B565-947C95722BAA@apple.com> <AANLkTi=qQSND5BvUP5+P=wJ7E8SG6NncGZH8U8+VYwZ0@mail.gmail.com> <20100806004907.GF27827@shareable.org> <C0FC87B7-C51C-4B36-BC16-DBDB0B00A20F@gbiv.com> <20100806012845.GI27827@shareable.org> <AANLkTi=GQOmgtg23XkGSc8NG5RDJP5wVY83P1VcG2AJZ@mail.gmail.com> <20100806024316.GK27827@shareable.org>
Date: Fri, 06 Aug 2010 14:18:46 +1000
Message-ID: <AANLkTin6qt8PQ-AUWOzdFsOdG=P4zDY+b2jPrHDoSxTG@mail.gmail.com>
From: Greg Wilkins <gregw@webtide.com>
To: Jamie Lokier <jamie@shareable.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Cc: "Roy T. Fielding" <fielding@gbiv.com>, "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] Background info: Properties of sendfile()
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 06 Aug 2010 04:18:18 -0000

On 6 August 2010 12:43, Jamie Lokier <jamie@shareable.org> wrote:
> Greg Wilkins wrote:
>> On 6 August 2010 11:28, Jamie Lokier <jamie@shareable.org> wrote:

>> For jetty using java's file mapped buffers, we've encountered 2 key
>> problems that cause us to turn it off.
>
> Little note: Mapped buffers aren't sendfile (unless they aren't what
> they sound like; I don't know Java too well).  Assuming they're mmap()
> plus send(), they are a different technique that achieves _some_ of
> the same benefits.  Mapped buffers reduce memory use and some copying,
> but don't result in sockets sharing the same memory, nor eliminate
> copying, nor are they affected in the same way by NIC hardware
> acceleration constraints - unless mapped buffers can combine forces with AIO
> (which certainly isn't possible on Linux, at least).

this is a little off topic, but...

The JVM API allows for memory map buffers to be sent to a channel and
it is meant to use sendfile like mechanisms so that the file content
is sent directly to the interface device.

I think the need to memory map to a buffer is a side effect of the
java API, which is all about channels and buffers and totally hides
file descriptors.  It may be that in this case java uses the memory
mapped buffer only as a holder of a file descriptor plus offset and
length.

> For a different perspective, see Roberto Peon's message which has the
> same thread parent as yours - he says there's no gain from sendfile.

Probably the biggest benefit from the java point of view is not being
able to drive the network interface at maximum speed, but rather
avoiding using user memory and the garbage collects that result.

cheers