From owner-freebsd-hackers@FreeBSD.ORG Sun Apr 22 11:54:18 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8A83106566B for ; Sun, 22 Apr 2012 11:54:18 +0000 (UTC) (envelope-from shen.elf@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 49AEA8FC0C for ; Sun, 22 Apr 2012 11:54:18 +0000 (UTC) Received: by yhgm50 with SMTP id m50so6883664yhg.13 for ; Sun, 22 Apr 2012 04:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=nwZeb2Sa9Bw4UJ7n0jlwwHVpVpupeaAUIm7v+2K61ZM=; b=gEpw4h8Uzh6C0Ec5nJ7kmi6UuHCoCvLoDku75L2XuL3hJPxVF+kKEzntA4Abj7CCu2 p93IcuVmZ9IrajSoiif6fpvnzgttWlJzdhzUnG2x1yyQk9uI7ElZHPpQyPvQqhZ3Zzua vL7NTryi9ofQZ1eBsdQZrWaK835xIzDgbEXve3GswIu1hw5UT+vgt4Az16CilbbVTnQ9 5e2xOvokbgKx5o66RF5YR9fA+c5l6yVZ1dZHMuAXC5DYQ+Uj60a3QzVnpKiAJA8A/wSO KA4PTVSPJRIN7ir/P+CDLmVtPxZmHtUj527WgC83FMwyARhy9IuqbPTiWUUSdesiIsIS poRQ== MIME-Version: 1.0 Received: by 10.236.181.39 with SMTP id k27mr11830734yhm.52.1335095652128; Sun, 22 Apr 2012 04:54:12 -0700 (PDT) Received: by 10.236.29.199 with HTTP; Sun, 22 Apr 2012 04:54:12 -0700 (PDT) Date: Sun, 22 Apr 2012 19:54:12 +0800 Message-ID: From: Yanhui Shen To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: CPU usage so high, fread() on the FILE wrapped by libfetch's fetchXGetURL() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Apr 2012 11:54:18 -0000 Hi, I found the CPU usage is pretty high while running 'pkg update', 'pkg install [fooapp]'. Seems it was caused by fread() on the FILE wrapped by libfetch's fetchXGetURL() , maybe fetch_read() in common.c. Here is a simple test code: http://pastebin.com/2sP1f4Wv I want to know whether it is a bug, or misuse of libfetch API, or any other matter? Run and look about its CPU usage (HTTP url has this issue, FTP url has not): % ./a.out http://mirrors.163.com/FreeBSD/ISO-IMAGES-amd64/8.3/FreeBSD-8.3-RELEASE-amd64-bootonly.iso Env: % uname -a FreeBSD ThinkPad 9.0-STABLE FreeBSD 9.0-STABLE #1: Tue Apr 10 12:46:50 CST 2012 shen@ThinkPad:/usr/obj/usr/src/sys/ThinkPad amd64 -- Best regards, Yanhui Shen