Would it be possible for you to test the latest upstream kernel? Refer
to https://wiki.ubuntu.com/KernelMainlineBuilds . Please test the latest
v4.18 kernel[0].

If this bug is fixed in the mainline kernel, please add the following
tag 'kernel-fixed-upstream'.

If the mainline kernel does not fix this bug, please add the tag:
'kernel-bug-exists-upstream'.

Once testing of the upstream kernel is complete, please mark this bug as
"Confirmed".


Thanks in advance.

[0] http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.18-rc7

** Changed in: linux (Ubuntu)
   Importance: Undecided => Medium

** Changed in: linux (Ubuntu)
       Status: Confirmed => Incomplete

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1785020

Title:
  fsync is slow on later kernels with ext4 filesystms

Status in linux package in Ubuntu:
  Incomplete

Bug description:
  
  So this is a simple one, if I run the following code (see below) on Ubuntu 
18.04 (4.15.0-29-generic ) and against Ubuntu 16.04 ( 4.4.0-87-generic) I get 
two different results ; The question is why? It seems that fsync may be broken 
in the latest kernel and may well be broken as early as 4.10 ? This has huge 
implications around performance sensitive applications like mysql. 

  It also so worth noting that I'm running this against an ext4 filesystem with 
the following mount options
  rw,noatime,nodiratime,nobarrier,data=journal 

  
  4.4.0-87-generic - # time ./fsync 
  real 0m7.537s <-----
  user 0m0.000s
  sys 0m1.060s <-----

  
  4.15.0-29-generic - # time ./fsync
  real 1m38.299s <-----
  user 0m0.013s
  sys 0m0.893s <-----

  
  Linux buntu-1804 4.15.0-29-generic

  no sync() seconds:0.024438   writes per second:0.000000
     sync() seconds:1.705764   writes per second:0.000000

  real    3m6.475s
  user    0m0.006s
  sys     0m1.725s

  
  Linux ubuntu 4.4.0-87-generic

  no sync() seconds:0.012887   writes per second:0.000001
     sync() seconds:0.736563   writes per second:0.000000

  real    0m8.945s
  user    0m0.016s
  sys     0m0.732s



  
  #!/usr/bin/python
  import os, sys, mmap
  # Open a file
  fd = os.open( "/a/testfile", os.O_RDWR|os.O_CREAT|os.O_DIRECT )
  m = mmap.mmap(-1, 512)
  for i in range (1,10000):
     os.lseek(fd,os.SEEK_SET,0)
     m[1] = "1"
     os.write(fd, m)
     os.fsync(fd)
  # Close opened file
  os.close( fd )

  
  #define _GNU_SOURCE
  #include <stdio.h>
  #include <fcntl.h>
  #include <time.h>
  #include <unistd.h>

  void withSync() {
      int f = open( "/a/t8" , O_RDWR | O_CREAT |O_DIRECT );
      lseek (f, 0, SEEK_SET );
      int records = 10*1000;
      clock_t ustart = clock();
      for(int i = 0; i < records; i++) {
          write(f, "012345678901234567890123456789" , 30);
          fsync(f);
      }
      clock_t uend = clock();
      close (f);
      printf("   sync() seconds:%lf   writes per second:%lf\n", 
((double)(uend-ustart))/(CLOCKS_PER_SEC), 
((double)records)/((double)(uend-ustart))/(CLOCKS_PER_SEC));
  }

  void withoutSync() {
      int f = open( "/a/t10" , O_RDWR | O_CREAT | O_DIRECT );
      lseek (f, 0, SEEK_SET );
      int records = 10*1000;
      clock_t ustart = clock();
      for(int i = 0; i < records; i++) {
          write(f, "012345678901234567890123456789" , 30 );
      }
      clock_t uend = clock();
      close (f);
      printf("no sync() seconds:%lf   writes per second:%lf \n", 
((double)(uend-ustart))/(CLOCKS_PER_SEC), 
((double)records)/((double)(uend-ustart))/(CLOCKS_PER_SEC));
  }

  int main(int argc, const char * argv[])
  {
      withoutSync();
      withSync();
      return 0;
  }

  
  Linux buntu-1804 4.15.0-29-generic

  no sync() seconds:0.024438   writes per second:0.000000
     sync() seconds:1.705764   writes per second:0.000000

  real    3m6.475s
  user    0m0.006s
  sys     0m1.725s

  
  Linux ubuntu 4.4.0-87-generic

  no sync() seconds:0.012887   writes per second:0.000001
     sync() seconds:0.736563   writes per second:0.000000

  real     0m8.945s
  user    0m0.016s
  sys      0m0.732s

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1785020/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to