linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Truncate regression due to commit 69b6c1319b6
@ 2019-02-26 16:56 Jan Kara
  2019-02-26 17:27 ` Matthew Wilcox
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kara @ 2019-02-26 16:56 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-mm, mgorman

[-- 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;
}

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-08-29 11:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26 16:56 Truncate regression due to commit 69b6c1319b6 Jan Kara
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).