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

fix: pass config to init #303

Closed
wants to merge 2 commits into from
Closed

fix: pass config to init #303

wants to merge 2 commits into from

Conversation

hugomrdias
Copy link
Member

@hugomrdias hugomrdias commented Oct 24, 2018

This PR improves ctl daemon performance passing node config directly to init command.

- start-stop tests go and js 49 s > 38s  (go needs the same optimization)
- start-stop tests js only 27s > 18s
- full tests 2m 16s > 1m 50s

Needs:

@ghost ghost assigned hugomrdias Oct 24, 2018
@ghost ghost added the status/in-progress In progress label Oct 24, 2018
@daviddias daviddias added status/deferred Conscious decision to pause or backlog status/blocked Unable to be worked further until needs are met and removed status/in-progress In progress status/blocked Unable to be worked further until needs are met labels Oct 27, 2018
const args = ['init']
const args = [
'init',
this.opts.type === 'js' && JSON.stringify(this.opts.config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why just JS?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we haz this for Go as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i talked about this in the ipfs pr ipfs/js-ipfs#1662 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Stebalien can you check this ^^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go actually takes in an initial config as a file argument (positional). However, it won't merge it. Really, I'm not sure how I'd expect merging to work.

We also have a concept of "profiles" for patching our config.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Stebalien we added support for passing a json string has a positional arg to the init cmd like this https://github.com/ipfs/js-ipfs/pull/1662/files
We already had a config options https://github.com/ipfs/js-ipfs#optionsconfig so it was straight forward.
It's just a simple deep merge with the default config.

any chance we can get something similar in go ? we can consider other ways to do it!

we just want to reduce the number of child processes that ctl spawns

Right now we need to spawn 4 child_processes to start a node in ctl

ipfs init
ipfs config show
ipfs config replace
ipfs daemon

With this PR we would only need 2

ipfs init '{"Addresses":{"Swarm":["/ip4/0.0.0.0/tcp/4003"]}}'
ipfs daemon

Final goal is to just do

ipfs daemon --init --config "{}"

This will help a lot making our tests faster!!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A similar issue has come up with in cluster: ipfs/kubo#6262 (comment) (maybe, I may be misunderstanding the issue).

However, I believe they'll need to pass by-file. Would that work here or will we need two options.

@ghost ghost assigned daviddias Nov 2, 2018
@ghost ghost added status/in-progress In progress and removed status/deferred Conscious decision to pause or backlog labels Nov 2, 2018
@daviddias
Copy link
Member

daviddias commented Nov 2, 2018

I've rebased master onto this branch. Tests are passing with updated deps.

@daviddias daviddias added exp/novice Someone with a little familiarity can pick up P1 High: Likely tackled by core team if no one steps up labels Nov 5, 2018
const args = ['init']
const args = [
'init',
this.opts.type === 'js' && JSON.stringify(this.opts.config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we haz this for Go as well?

hugomrdias added a commit to ipfs/js-ipfs that referenced this pull request Sep 5, 2019
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.

ipfs/kubo#6489

`ipfs init` changed to accept a file path as an argument

`ipfs daemon` changed to support `--init` and `--init-config` options.

Now we can do `ipfs daemon --init --init-config /path/to/custom-config`

refs:
ipfs/js-ipfsd-ctl#303
hugomrdias added a commit to ipfs/js-ipfs that referenced this pull request Sep 5, 2019
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.

ipfs/kubo#6489

`ipfs init` changed to accept a file path as an argument

`ipfs daemon` changed to support `--init` and `--init-config` options.

Now we can do `ipfs daemon --init --init-config /path/to/custom-config`

refs:
ipfs/js-ipfsd-ctl#303
hugomrdias added a commit to ipfs/js-ipfs that referenced this pull request Sep 6, 2019
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.

ipfs/kubo#6489

`ipfs init` changed to accept a file path as an argument

`ipfs daemon` changed to support `--init` and `--init-config` options.

Now we can do `ipfs daemon --init --init-config /path/to/custom-config`

refs:
ipfs/js-ipfsd-ctl#303
@daviddias
Copy link
Member

@hugomrdias what's missing to land?

@hugomrdias
Copy link
Member Author

this change is gonna land with this #369 PR

@hugomrdias hugomrdias closed this Sep 9, 2019
@hugomrdias hugomrdias deleted the perf/pass-config-init branch September 9, 2019 09:31
hugomrdias added a commit to ipfs/js-ipfs that referenced this pull request Sep 11, 2019
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.

ipfs/kubo#6489

`ipfs init` changed to accept a file path as an argument

`ipfs daemon` changed to support `--init` and `--init-config` options.

Now we can do `ipfs daemon --init --init-config /path/to/custom-config`

refs:
ipfs/js-ipfsd-ctl#303
hugomrdias added a commit to ipfs/js-ipfs that referenced this pull request Sep 16, 2019
This PR aligns `ipfs init` and `ipfs daemon` with go-ipfs.

ipfs/kubo#6489

`ipfs init` changed to accept a file path as an argument

`ipfs daemon` changed to support `--init` and `--init-config` options.

Now we can do `ipfs daemon --init --init-config /path/to/custom-config`

refs:
ipfs/js-ipfsd-ctl#303
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up P1 High: Likely tackled by core team if no one steps up status/in-progress In progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants