From: Jan Kara <jack@suse.cz>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, mgorman@suse.de
Subject: Truncate regression due to commit 69b6c1319b6
Date: Tue, 26 Feb 2019 17:56:28 +0100 [thread overview]
Message-ID: <20190226165628.GB24711@quack2.suse.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]
Hello Matthew,
after some peripeties, I was able to bisect down to a regression in
truncate performance caused by commit 69b6c1319b6 "mm: Convert truncate to
XArray". The initial benchmark that indicated the regression was a bonnie++
file delete test (some 4-5% regression). It is however much easier (and
faster!) to see the regression with the attached benchmark. With it I can
see about 10% regression on my test machine: Average of 10 runs, time in us.
COMMIT AVG STDDEV
a97e7904c0 1431256.500000 1489.361759
69b6c1319b 1566944.000000 2252.692877
The benchmark has to be run so that the total file size is about 2x the
memory size (as the regression seems to be in trucating existing workingset
entries). So on my test machine with 32 GB of RAM I run it like:
# This prepares the environment
mkfs.xfs -f /dev/sdb1
mount -t xfs /dev/sdb1 /mnt
./trunc-bench /mnt/file 64 1
# This does the truncation
./trunc-bench /mnt/file 64 2
I've gathered also perf profiles but from the first look they don't show
anything surprising besides xas_load() and xas_store() taking up more time
than original counterparts did. I'll try to dig more into this but any idea
is appreciated.
My test machine is 8 CPU Intel(R) Xeon(R) CPU E3-1240 v5 @ 3.50GHz.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
[-- Attachment #2: trunc-bench.c --]
[-- Type: text/x-c, Size: 1478 bytes --]
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/time.h>
#define COUNT 1024
#define BUFSIZE (1024*1024)
char *buf;
void read_file(int fd)
{
int i;
if (ftruncate(fd, BUFSIZE*COUNT) < 0) {
perror("truncate");
exit(1);
}
for (i = 0; i < COUNT; i++) {
if (read(fd, buf, BUFSIZE) != BUFSIZE) {
perror("read");
exit(1);
}
}
}
int main(int argc, char **argv)
{
int fd;
int fcount, i, stages;
char fname[128];
struct timeval start, end;
if (argc != 4) {
fprintf(stderr, "Usage: trunc-bench <file> <file-count> <stages>\n");
return 1;
}
fcount = strtol(argv[2], NULL, 0);
stages = strtol(argv[3], NULL, 0);
buf = malloc(BUFSIZE);
if (!buf) {
fprintf(stderr, "Cannot allocate write buffer.\n");
return 1;
}
memset(buf, 'a', BUFSIZE);
if (stages & 1) {
fprintf(stderr, "Creating files...\n");
for (i = 0; i < fcount; i++ ) {
sprintf(fname, "%s%d", argv[1], i);
fd = open(fname, O_RDWR | O_TRUNC | O_CREAT, 0644);
if (fd < 0) {
perror("open");
return 1;
}
read_file(fd);
close(fd);
}
}
if (stages & 2) {
fprintf(stderr, "Removing files...\n");
gettimeofday(&start, NULL);
for (i = 0; i < fcount; i++ ) {
sprintf(fname, "%s%d", argv[1], i);
truncate(fname, 0);
}
gettimeofday(&end, NULL);
printf("%lu us\n", (end.tv_sec - start.tv_sec) * 1000000UL + (end.tv_usec - start.tv_usec));
}
fprintf(stderr, "Done.\n");
return 0;
}
next reply other threads:[~2019-02-26 16:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-26 16:56 Jan Kara [this message]
2019-02-26 17:27 ` Matthew Wilcox
2019-02-27 6:03 ` Nicholas Piggin
2019-02-27 12:35 ` Matthew Wilcox
2019-02-28 9:31 ` Nicholas Piggin
2019-02-27 11:27 ` Jan Kara
2019-02-27 12:24 ` Matthew Wilcox
2019-02-27 16:55 ` Jan Kara
2019-02-28 22:53 ` Matthew Wilcox
2019-03-14 11:10 ` Jan Kara
2019-05-31 19:04 ` Matthew Wilcox
2019-08-27 13:29 ` Jan Kara
2019-08-29 11:59 ` Matthew Wilcox
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=20190226165628.GB24711@quack2.suse.cz \
--to=jack@suse.cz \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=willy@infradead.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