From owner-freebsd-hackers@freebsd.org Fri Jul 8 16:20:01 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D0A1B83395 for ; Fri, 8 Jul 2016 16:20:01 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f47.google.com (mail-it0-f47.google.com [209.85.214.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1BA0B1226 for ; Fri, 8 Jul 2016 16:20:00 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f47.google.com with SMTP id h190so13109794ith.1 for ; Fri, 08 Jul 2016 09:20:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=UNL5m55Wd9TBiws/ufa44O9Q7Of0TVuTF3jTudwKjdw=; b=UI5rRechDOR1LwHBwc4dnlbnD9oACJkcTSRldnt7JEmE1uaZkvZOXe4lzrSSvtDJ1v Wue9lNg+BBktFnnc1XiXfW0Gr3PuA/6zd+f7pGmHswOzRD2bGr8I4Ixcmt3BjF+PcMHX 1YfMp2gihmye5WGLN5xE7fN52omJQJ/JYPeHN9RTr2lFF8oA9R6IQvQGwwRbqn6bgJXV a+aA2SAIw+LGxog9kMwSwLGUtm7ogUdICJunz5yCE7UfSTcP4QKDxt6X+zAJc7cqIRFS zqLaUc9rPfK9qln3W9/Koubony42HFMKw24ZcQzuxHTCKBqCxahZselRh5QzkcqKs7/4 fVSQ== X-Gm-Message-State: ALyK8tKkZh12+cY+mX8SJOlARoUSv8lqStCK7WxOLf0daTsGIKgiUDBcL4l2frhuwKtqNA== X-Received: by 10.36.58.13 with SMTP id m13mr4076460itm.81.1467993744677; Fri, 08 Jul 2016 09:02:24 -0700 (PDT) Received: from mail-io0-f176.google.com (mail-io0-f176.google.com. [209.85.223.176]) by smtp.gmail.com with ESMTPSA id o139sm1490481ito.4.2016.07.08.09.02.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jul 2016 09:02:24 -0700 (PDT) Received: by mail-io0-f176.google.com with SMTP id s93so4922600ioi.3 for ; Fri, 08 Jul 2016 09:02:24 -0700 (PDT) X-Received: by 10.107.46.162 with SMTP id u34mr9443035iou.162.1467993744071; Fri, 08 Jul 2016 09:02:24 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.36.206.2 with HTTP; Fri, 8 Jul 2016 09:02:23 -0700 (PDT) In-Reply-To: <20160708130258.7b772558@gumby.homeunix.com> References: <20160707001913.GJ38613@kib.kiev.ua> <6193bbf3-39cd-abaa-a5e4-0480c40dac55@rawbw.com> <20160708130258.7b772558@gumby.homeunix.com> From: Conrad Meyer Date: Fri, 8 Jul 2016 09:02:23 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Why kinfo_getvmmap is sometimes so expensive? To: RW Cc: FreeBSD Hackers Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2016 16:20:01 -0000 On Fri, Jul 8, 2016 at 5:02 AM, RW via freebsd-hackers wrote: > On Thu, 7 Jul 2016 15:32:28 -0700 > Yuri wrote: > >> When people raise the question of why malloc library doesn't unmap >> the memory, developers there usually say that they call >> madvise(MADV_FREE) and this is as good as unmap. > > It's better than unmapping because freed memory is commonly re-malloced > shortly after it's freed. > >> But this example >> shows that this isn't quite the case on the FreeBSD, and unmapping is >> better. > > That doesn't mean it's better in general. Additionally, it would not be difficult to make "getProcessSizeBytes()" cheaper without changing malloc. Fetching the entire VM map from the kernel when you only care about an integer RSS count is obviously inefficient. Best, Conrad