From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27350 invoked by alias); 31 Oct 2011 06:01:40 -0000 Received: (qmail 27333 invoked by uid 22791); 31 Oct 2011 06:01:38 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Oct 2011 06:01:25 +0000 Received: by vcbfk1 with SMTP id fk1so5754320vcb.0 for ; Sun, 30 Oct 2011 23:01:24 -0700 (PDT) Received: by 10.220.199.198 with SMTP id et6mr1476294vcb.160.1320040884138; Sun, 30 Oct 2011 23:01:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.107.4 with HTTP; Sun, 30 Oct 2011 23:01:03 -0700 (PDT) From: Ulrich Drepper Date: Mon, 31 Oct 2011 06:01:00 -0000 Message-ID: Subject: network information caching To: libc-hacker@sourceware.org Content-Type: text/plain; charset=UTF-8 Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00002.txt.bz2 getaddrinfo was forever quite inefficient since it often had to had to read network information to determine the sorting. In a normal process this information cannot be cached since it can change at any time and there is no change counter. nscd can track changes, though. netlink provides a way for a userlevel process to be notified about network configuration changes. This is now used in git head. In addition to optimizing the getaddrinfo calls in nscd itself (i.e., the previous results are reused if the network configuraiton hasn't changed), the information is also exported to other processes using nscd's shared memory. You now might see that many/most getaddrinfo calls won't need a single system call. The only minimal drawback is that the nscd cache and shared memory layout changed. nscd can transparently handle this. It's just that the cache content gets lost if a new nscd is launched. That's all. The code is lightly tested.