From owner-freebsd-questions@freebsd.org Thu Apr 12 03:09:43 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7B0BAF875D8 for ; Thu, 12 Apr 2018 03:09:43 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from outgoing.tristatelogic.com (segfault.tristatelogic.com [69.62.255.118]) by mx1.freebsd.org (Postfix) with ESMTP id 0E1B770FA6 for ; Thu, 12 Apr 2018 03:09:42 +0000 (UTC) (envelope-from rfg@tristatelogic.com) Received: from segfault-nmh-helo.tristatelogic.com (localhost [127.0.0.1]) by segfault.tristatelogic.com (Postfix) with ESMTP id E38203AEF8 for ; Wed, 11 Apr 2018 20:03:07 -0700 (PDT) From: "Ronald F. Guilmette" To: freebsd-questions@freebsd.org Subject: Two questions --- SSD block sizes and buffering Date: Wed, 11 Apr 2018 20:03:07 -0700 Message-ID: <23423.1523502187@segfault.tristatelogic.com> X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2018 03:09:43 -0000 Two rather simple questions: 1) I don't know much, generally speaking, but I have certainly read that the underyling hardware of flash memory products (which I guess includes both USB sticks and also SSDs) all effectively have "physical" block sizes on the order of 128 KiB. So anyway, I'm just curious to know to what extent, if any, FreeBSD, when running with, on, or from any such (flash-memory based) mass storage device does things specifically with these larger physical block sizes (of flash memory) in mind. Does FreeBSD automagically sense that it is dealing with an SSD, and does it then adjust the way it operates on the relevant filesystem(s) accordingly, for maximal performance? Or must the system administrator tweek something explicitly (e.g. tunefs parameters, or perhaps newfs parameters) in order to get optimal performance on/with an SSD? 2) I have written some modest C programs that output lots and lots of very short little tidbits of data, one per line. In some cases these programs output millions of lines. For reasons that I can explain, these programs explicitly call setvbuf() on stdout during startup, and they set the buffering type for stdout to _IOLBF (i.e. line buffering). My question is just this: Assme that one of these programs is called "xyz". Now, if I run the program thusly: xyz > xyz.output i.e. so that stdout is redirected to a file, will there be one actual write to disk for each and every line that is written to stdout by xyz? In other words, will my act of explicitly setting line buffering (for stdout) in a case like this cause the xyz program to beat the living hell out of my disk drive? I hope not, but I'd like to know if it will, or know why it won't, if it won't.