Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significant slowdown for each file written #17

Open
natevw opened this issue Mar 3, 2015 · 3 comments
Open

Significant slowdown for each file written #17

natevw opened this issue Mar 3, 2015 · 3 comments

Comments

@natevw
Copy link
Owner

natevw commented Mar 3, 2015

var vol = require("./img_volume.js").createDriverSync("/Users/natevw/Desktop/fat32.img"),
    fs = require("./").createFileSystem(vol, {umask:0020, uid:99, gid:42});

function writeData(data) {
  setImmediate(function () {
    var t1 = Date.now();
    fs.writeFile("sample-"+t1+".bin", data, function (e) {
      var t2 = Date.now();
      console.log(t2 - t1);
      writeData(data);
    });
  });
}
writeData(Buffer(512*1024));

The output grows steadily, starting at around 330ms for the write and growing to 2004ms after less than 50 files: https://gist.github.com/natevw/41ac4cf4f3788d4193ed

Contrary to natevw/sdcard#20, creating a new filesystem instance (or in this case: a whole new process!) does not keep the timings low.

@natevw
Copy link
Owner Author

natevw commented Mar 3, 2015

Script updated for on-device testing too:

var fs = null,
    data = Buffer(512*1024);

if (0) {
  var vol = require("./img_volume.js").createDriverSync("/Users/natevw/Desktop/fat32.img"),
      fs = require("./").createFileSystem(vol, {umask:0020, uid:99, gid:42});
  writeData();
} else {
  var sd = require('sdcard').use(require('tessel').port['A'], {getFilesystems:true}),
      fs = null;
  sd.on('ready', function(e, fss) {
    if (e) throw e;
    fs = fss[0];
    writeData();
  });
}

function writeData() {
  setImmediate(function () {
    var t1 = Date.now();
    fs.writeFile("sample-"+t1+".bin", data, function (e) {
      var t2 = Date.now();
      console.log(t2 - t1);
      writeData();
    });
  });
}

@natevw
Copy link
Owner Author

natevw commented Mar 5, 2015

Couple notes:

@natevw
Copy link
Owner Author

natevw commented Mar 6, 2015

Latest test script:

var fs = null,
    data = Buffer(60*1024);

if (0) {
  var vol = require("fatfs/img_volume.js").createDriverSync("/Users/natevw/Desktop/fat32.img"),
      fs = require('fatfs').createFileSystem(vol, {umask:0020, uid:99, gid:42});
  writeData();
} else {
  var sd = require("./").use(require('tessel').port['A'], {getFilesystems:true}),
      fs = null;
  sd.on('ready', function (fss) {
    fs = fss[0];
    writeData();
  });
}

function writeData() {
  setImmediate(function () {
    var t1 = Date.now();
    //process.stdout.write("--> Writing "+t1+"…\t");
    fs.writeFile("sample-"+t1+".bin", data, function (e) {
      var t2 = Date.now();
      console.log(t2 - t1);
      writeData();
    });
  });
}

…gives results like this on a dirty card (i.e. already lots of existing files):

25544
22281
21707
22458
22115
23038
22843
22223

So at this point there's still AFAIK a weird temporary slowdown during the first couple dozen files, but it does seem to stabilize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant