Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

j s-ipfs runs on the phone but a heavy CPU load, so can it reduce power consumption? #1435

Closed
xuruijing opened this issue Jul 12, 2018 · 8 comments
Labels
kind/support A question or request for support

Comments

@xuruijing
Copy link

I'm using nodeJs for mobile in a project (react-native), mainly hoping to run IPFS on mobile. I'm experiencing performance issues on the device(iPhone 6+) and simulator, Once the code runs to the ipfs-api, the CPU surges up to 100% and persists. Is it because IPFS has too many connections? Is there a way to limit connections and reduce power consumption?

@alanshaw
Copy link
Member

In ipfs@0.30 you can manage connections with the new connection manager.

You pass connectionManager options to the IPFS constructor https://github.com/ipfs/js-ipfs#ipfs-constructor

Options for the connection manager are documented here: https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager

@alanshaw alanshaw added kind/support A question or request for support status/in-progress In progress labels Jul 12, 2018
@alanshaw
Copy link
Member

Does that answer your question @xuruijing?

@xuruijing
Copy link
Author

Thank you very much for your reply, I don't know how to use the connectionManager, how to configure the parameters, such as when to call, my goal was to reduce the power consumption of the CPU run time, and don't know how by connectionManager configuration can achieve this goal? In addition, I use ipfsd-ctl to start ipfs.

@xuruijing
Copy link
Author

Do you have an example of using connectionManager in config?

@alanshaw
Copy link
Member

Hows this:

const IPFS = require('ipfs')
const ipfs = new IPFS({
  connectionManager: {
    maxPeers: Infinity,
    minPeers: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  }
})

Info on what the options do is here: https://github.com/libp2p/js-libp2p-connection-manager#create-a-connectionmanager

js-ipfs doesn't yet have performance profiles you can pick from so I think it'll be a case of tweaking the parameters until you find something that works for your situation.

@mistakia
Copy link
Contributor

I'm having a hard time finding where connectionManager.start() is called.. tried looking in libp2p as well as in ipfs.

Or are we suppose to handle starting and stoping ourselves? Apologies if I'm missing something really obvious 😋

@xuruijing
Copy link
Author

I used the latest libp2pin ipfs, and
connectionManager: { maxPeers: 10, minPeers: 2, pollInterval: 10000 // ms }.
How can I verify that this configuration works?

@alanshaw
Copy link
Member

@mistakia the newest version of libp2p (in js-ipfs 0.31) starts the connection manager by default. Sorry about that.

@xuruijing you could verify the connection manager is doing it's job by asking the swarm.peers API.

Closing this as I think the original question has now been answered!

@ghost ghost removed the status/in-progress In progress label Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

3 participants