From: Davide Libenzi <davidel@xmailserver.org>
To: linux-kernel@vger.kernel.org
Subject: do_select() improvement ...
Date: Thu, 21 Jun 2001 12:30:02 -0700 (PDT) [thread overview]
Message-ID: <XFMail.20010621123002.davidel@xmailserver.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2085 bytes --]
This patch can improve do_select() ==> select() performance due :
1) the load from the fd bitmap is done every __NFDBITS instead of every bit.
If You look at the BITS() macro You'll see that it's not cheap in terms
of memory operations
2) if a sequential hole of __NFDBITS is found it'll be skipped without doing a
bit by bit check
*** select.orig.c Thu Jun 21 08:52:04 2001
--- select.c Thu Jun 21 12:09:25 2001
***************
*** 164,171 ****
--- 164,172 ----
{
poll_table table, *wait;
int retval, i, off;
long __timeout = *timeout;
+ unsigned long bits;
read_lock(¤t->files->file_lock);
retval = max_select_fd(n, fds);
read_unlock(¤t->files->file_lock);
***************
*** 186,194 ****
unsigned long mask;
struct file *file;
off = i / __NFDBITS;
! if (!(bit & BITS(fds, off)))
continue;
file = fget(i);
mask = POLLNVAL;
if (file) {
--- 187,202 ----
unsigned long mask;
struct file *file;
off = i / __NFDBITS;
! if (!(i & (__NFDBITS - 1))) {
! bits = BITS(fds, off);
! if (!bits) {
! i += __NFDBITS;
! continue;
! }
! }
! if (!(bit & bits))
continue;
file = fget(i);
mask = POLLNVAL;
if (file) {
- Davide
[-- Attachment #2: select.c.diff --]
[-- Type: application/octet-stream, Size: 918 bytes --]
*** select.orig.c Thu Jun 21 08:52:04 2001
--- select.c Thu Jun 21 12:09:25 2001
***************
*** 164,171 ****
--- 164,172 ----
{
poll_table table, *wait;
int retval, i, off;
long __timeout = *timeout;
+ unsigned long bits;
read_lock(¤t->files->file_lock);
retval = max_select_fd(n, fds);
read_unlock(¤t->files->file_lock);
***************
*** 186,194 ****
unsigned long mask;
struct file *file;
off = i / __NFDBITS;
! if (!(bit & BITS(fds, off)))
continue;
file = fget(i);
mask = POLLNVAL;
if (file) {
--- 187,202 ----
unsigned long mask;
struct file *file;
off = i / __NFDBITS;
! if (!(i & (__NFDBITS - 1))) {
! bits = BITS(fds, off);
! if (!bits) {
! i += __NFDBITS;
! continue;
! }
! }
! if (!(bit & bits))
continue;
file = fget(i);
mask = POLLNVAL;
if (file) {
next reply other threads:[~2001-06-21 19:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-21 19:30 Davide Libenzi [this message]
2001-06-21 21:23 ` Davide Libenzi
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=XFMail.20010621123002.davidel@xmailserver.org \
--to=davidel@xmailserver.org \
--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
all inboxes | Powered by JetHome®