Buffer chains optimisation

Hi,

I read the guide about the Nginx module development and I don’t find any
description about how buffer chains are processed. For example, I send a
file line by line and I would like to know if it’s optimized to create
one buffer (ngx_buf_t) and one chain (ngx_chain_t) for each line or to
concatenate entire document and send it with only one buffer/chain.

Thanks in advance

On Fri, Apr 25, 2008 at 07:17:30PM +0200, Chavelle V. wrote:

I read the guide about the Nginx module development and I don’t find any
description about how buffer chains are processed. For example, I send a
file line by line and I would like to know if it’s optimized to create
one buffer (ngx_buf_t) and one chain (ngx_chain_t) for each line or to
concatenate entire document and send it with only one buffer/chain.

nginx does some memory/file pointer gathering before passing data to
writev()/sendfile(), i.e, two neighbour memory/file blocks became one.
But nginx does not copy data to concatenate them.

Chavelle V. <[email protected]…> writes:

I read the guide about the Nginx module development and I don’t find any
description about how buffer chains are processed. For example, I send a
file line by line and I would like to know if it’s optimized to create
one buffer (ngx_buf_t) and one chain (ngx_chain_t) for each line or to
concatenate entire document and send it with only one buffer/chain.

One buffer and one chain is OK. You can use a static string to setup a
buffer
(without copying) or a dynamically allocated string (via the pool of
memory
automagically freed when the request is done); that way you can mix
buffers in a
chain with different kind of data. So in your case one buffer for the
entire
document should be a good approach.

Best regards.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs