public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andi Kleen <ak@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Shrinks sizeof(files_struct) and better layout
Date: Wed, 04 Jan 2006 12:13:25 +0100	[thread overview]
Message-ID: <43BBADD5.3070706@cosmosbay.com> (raw)
In-Reply-To: <p733bk4z2z0.fsf@verdi.suse.de>

Andi Kleen a écrit :
> Eric Dumazet <dada1@cosmosbay.com> writes:
>> 1) Reduces the size of (struct fdtable) to exactly 64 bytes on 32bits
>> platforms, lowering kmalloc() allocated space by 50%.
> 
> It should be probably a kmem_cache_alloc() instead of a kmalloc
> in the first place anyways. This would reduce fragmentation.

Well in theory yes, if you really expect thousand of tasks running...
But for most machines, number of concurrent tasks is < 200, and using a 
special cache for this is not a win.

> 
>> +   * read mostly part
>> +   */
>>  	atomic_t count;
>>  	struct fdtable *fdt;
>>  	struct fdtable fdtab;
>> -	fd_set close_on_exec_init;
>> -	fd_set open_fds_init;
>> +  /*
>> +   * written part on a separate cache line in SMP
>> +   */
>> +	spinlock_t file_lock ____cacheline_aligned_in_smp;
>> +	int next_fd;
>> +	embedded_fd_set close_on_exec_init;
>> +	embedded_fd_set open_fds_init;
> 
> You didn't describe that change, but unless it's clear the separate cache lines
> are a win I would not do it and save memory again. Was this split based on
> actual measurements or more theoretical considerations? 

As it is a refinement on a previous patch (that was integrated in 2.6.15) that 
put spin_lock after the array[] (so cleary using a separate cache line), I 
omited to describe it.

Yes, this part is really important because some multi-threaded benchmarks get 
a nice speedup with this separation in two parts.

Threads that are doing read()/write() (reading the first part of files_struct) 
are not slowed by others that do open()/close() syscalls (writing the second 
part), no false sharing (and no locking thanks to RCU of course).

Big Apache 2.0 servers, database servers directly benefit from this.

Note that process that tend to create/destroy a lot of threads per second are 
writing into 'count' field and might dirty the 'read mostly' part, but we can 
expect that well writen high performance programs wont do this.

Eric

  reply	other threads:[~2006-01-04 11:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20051108185349.6e86cec3.akpm@osdl.org>
     [not found] ` <437226B1.4040901@cosmosbay.com>
     [not found]   ` <20051109220742.067c5f3a.akpm@osdl.org>
     [not found]     ` <4373698F.9010608@cosmosbay.com>
2006-01-04  0:06       ` [PATCH] Shrinks sizeof(files_struct) and better layout Eric Dumazet
2006-01-04  9:11         ` Jan Engelhardt
2006-01-04 10:12           ` Eric Dumazet
2006-01-04 10:28             ` Folkert van Heusden
2006-01-04 10:45         ` Andi Kleen
2006-01-04 11:13           ` Eric Dumazet [this message]
2006-01-04 11:15             ` Andi Kleen
2006-01-04 11:19               ` Eric Dumazet
2006-01-04 11:22                 ` Andi Kleen
2006-01-04 11:41                   ` Eric Dumazet
2006-01-04 11:58                     ` Andi Kleen
2006-01-06  3:01             ` David Lang
2006-01-06  6:35               ` Eric Dumazet
2006-01-06  7:26                 ` David Lang
2006-01-06  7:37                   ` Eric Dumazet
2006-01-06  8:28                     ` David Lang
2006-01-04 11:45         ` Andrew Morton
2006-01-04 13:14           ` Eric Dumazet
2006-01-04 23:24           ` [2.6 patch] Define BITS_PER_BYTE Adrian Bunk
2006-01-05  7:03             ` Jan Engelhardt
2006-01-05 15:18               ` Bryan O'Sullivan
2006-01-05 19:19                 ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43BBADD5.3070706@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox