Question[Stress testing MFS]: How does `ipfs.files.rm` work?


go-ipfs(for local daemon) version: 0.4.19
OS: Ubuntu 16.04 LTS
ipfs-http-client version: 30.1.1

Description of Question

I was stress testing IPFS MFS. For stress testing, I used this script:

// Importing stuff

var ipfsClient = require('ipfs-http-client')
const ipfs = ipfsClient('localhost', '5001', { protocol: 'http' })

var dirName = "/write_op_stress_test"   // I already created this directory

 The below recursion creates 200 nested folders and adds a file named "hello.txt"
 in each of the 200 folders.

var count = 0
const createFolder = (name) => {
    name = name + "/" + count;
if(count < 200) {
    ipfs.files.mkdir(name, err => {
                console.log(`ERR while creating file[${Date()}]: ${name} \n ${err}`)
                console.log(`\n\n Created folder[(${Date()})]: ${name}\n\n Writing...`)
                ipfs.files.write(name+"/hello.txt", Buffer.from('Hello, world! vasa here :)'),{create: true}, (err) => {
                if (err){
    console.log("-----------------FOLDERS CREATED-------------------------")


When I ran this script for the FIRST TIME, it took a considerable amount of time as it is updating the whole tree hashes(tell me if I am right).

After running it for the first time, I REMOVED the /write_op_stress_test folder using ipfs.files.rm with recursive: true.

Then I AGAIN CREATED the /write_op_stress_test folder again using ipfs.files.mkdir.

Then I ran the above script once again.
But this time, it took way less time than before. For the record,

  • First time it took 293 seconds to complete.
  • Second time it took 5 seconds to complete.
  • Third time it took 4 seconds to complete.

Other observations:

  • If I change the content of the file, it again takes a lot of time. So, it seems like we store the file chunks in the dags, even after removing them using ipfs.files.rm.

So, my question is, are we still storing the data even after I execute ipfs.files.rm? I mean how do I justify the above observation?


weird in theory in IPFS is not possible to remove a content but in js-ipfs-http-client we have rm function : :thinking: someone have more details on that after you can check the code to be sure how it works

i hope can be help you.


That’s correct to my knowledge. You can run a repo gc after removing the mfs directory to clean slate.