# How about to add splice

**URL:** <https://www.ruby-forum.com/t/how-about-to-add-splice/243599>\
**Category:** NGINX\
**Created:** [December 8, 2015, 8:51pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599 "2015-12-08T20:51:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [December 8, 2015, 8:51pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/1 "2015-12-08T20:51:18Z")

</div>

Dear developer.

Do you know the splice() feature in Linux?

> **[Two new system calls: splice() and sync\_file\_range() \[LWN.net\]](https://lwn.net/Articles/178199/)**
>
> The 2.6.17 kernel will include two new system calls (splice() and
> sync\_file\_range()) 
> which expand the
> capabilities available to user-space programs in some interesting ways.
> This article (from this week's Kernel Page - subscribers only) contains...

[http://man7.org/linux/man-pages/man2/splice.2.html](http://man7.org/linux/man-pages/man2/splice.2.html)  
[http://ogris.de/howtos/splice.html](http://ogris.de/howtos/splice.html)

How about to add it 😉

BR Aleks

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 9, 2015, 12:54pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/2 "2015-12-09T12:54:35Z")

</div>

On Tuesday 08 December 2015 20:50:47 Aleksandar L. wrote:

> Dear developer.
> 
> Do you know the splice() feature in Linux?
> 
> [Two new system calls: splice() and sync\_file\_range() [LWN.net]](https://lwn.net/Articles/178199/)  
> [splice(2) - Linux manual page](http://man7.org/linux/man-pages/man2/splice.2.html)  
> [splice() on Linux](http://ogris.de/howtos/splice.html)
> 
> How about to add it 😉

[..]

Of course we know about splice(). You can find some mentions of it  
in the mailing list archive since 2006.

The problem with this syscall is that it’s not easy to implement,  
while the performance benefits are questionable (AFAIK not all network  
cards work well with splice()) and use cases are limited.

It only can be useful for proxying big amounts of data without any  
processing. But if you need compression, or TLS, or SSI, or even some  
simple substitution, then splice() cannot be used.

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 9, 2015, 9:49pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/3 "2015-12-09T21:49:07Z")

</div>

Dear Valentin.

Am 09-12-2015 12:54, schrieb Valentin V. Bartenev:

> > 
> 
> processing. But if you need compression, or TLS, or SSI, or even some  
> simple substitution, then splice() cannot be used.

Thanks for answer.

BR Aleks

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 9, 2015, 11:16pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/4 "2015-12-09T23:16:10Z")

</div>

On 12/9/15 2:54 PM, Valentin V. Bartenev wrote:

> > 
> 
> processing. But if you need compression, or TLS, or SSI, or even some  
> simple substitution, then splice() cannot be used.

It should fit in our stream quite nicely.

–  
Maxim K.

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 10, 2015, 2:18pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/5 "2015-12-10T14:18:40Z")

</div>

Hello!

On Thu, Dec 10, 2015 at 01:15:27AM +0300, Maxim K. wrote:

> > > How about to add it 😉  
> > > It only can be useful for proxying big amounts of data without any  
> > > processing. But if you need compression, or TLS, or SSI, or even some  
> > > simple substitution, then splice() cannot be used.
> 
> It should fit in our stream quite nicely.

Not really, as stream is able to do SSL encoding and decoding.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 10, 2015, 4:37pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/6 "2015-12-10T16:37:42Z")

</div>

Hello!

On Thu, Dec 10, 2015 at 03:31:23PM +0100, Lukas T. wrote:

> > > > It only can be useful for proxying big amounts of data without any  
> > > > processing. But if you need compression, or TLS, or SSI, or even some  
> > > > simple substitution, then splice() cannot be used.
> > > 
> > > It should fit in our stream quite nicely.
> > 
> > Not really, as stream is able to do SSL encoding and decoding.
> 
> We also have sendfile() in nginx despite the fact that it can’t be used  
> in every single occasion, such as TLS sessions or when gzipping.

For sure it can be handled like sendfile(), and only used when  
possible. I’m just saying that even with the stream module the  
question is still the same as outlined by Valentin - questionable  
potential benefits vs. added complexity.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![Aleksandar\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8edcca/32.png) [@Aleksandar\_L](https://www.ruby-forum.com/u/Aleksandar_L)\
**Post date:** [December 10, 2015, 3:31pm UTC](https://www.ruby-forum.com/t/how-about-to-add-splice/243599/7 "2015-12-10T15:31:41Z")

</div>

Hi Maxim,

> > > It only can be useful for proxying big amounts of data without any  
> > > processing. But if you need compression, or TLS, or SSI, or even some  
> > > simple substitution, then splice() cannot be used.
> > 
> > It should fit in our stream quite nicely.
> 
> Not really, as stream is able to do SSL encoding and decoding.

We also have sendfile() in nginx despite the fact that it can’t be used  
in every single occasion, such as TLS sessions or when gzipping.

I am aware that sendfile() is extremely useful in some configurations,  
I’m  
just saying the fact that it isn’t able to work with TLS wasn’t  
showstopper  
for it, so at the very least it shouldn’t be the only showstopper for  
splice().

splice() would do something similar than sendfile(). HAProxy doesn’t  
always  
splice() either, but when it makes sense [1].

Regarding TLS:  
There are some efforts in both linux [2] and FreeBSD [3] to implement  
TLS in-kernel; leveraging kernel features like sendfile() while sending  
it through a in-kernel crypto stack.

I’m not saying splice() is a must-have; I certainly don’t need it  
personally, but there are use-cases out there.

Regards,

Lukas

[1]

> **[4.2. Alphabetically sorted keywords reference - HAProxy version 1.5.18 -...](http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4.2-option%20splice-auto)**
>
> May be used in sections :

[2] [TLS in the kernel [LWN.net]](https://lwn.net/Articles/666509/)  
[3] [https://people.freebsd.org/~rrs/asiabsd\_2015\_tls.pdf](https://people.freebsd.org/~rrs/asiabsd_2015_tls.pdf)
