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

improved gateway directory listing for sharded nodes #3897

Merged
merged 1 commit into from
May 7, 2017

Conversation

whyrusleeping
Copy link
Member

License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com

@@ -227,92 +229,102 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
return
}

links, err := i.api.Unixfs().Ls(ctx, resolvedPath)
nd, err := i.api.ResolveNode(ctx, resolvedPath)
Copy link

Choose a reason for hiding this comment

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

Now that we get the whole node here, we can meld this call and i.api.Unixfs().Cat(ctx, resolvedPath) further above into one

@whyrusleeping
Copy link
Member Author

I would love to get this reviewed ASAP so we can sneak it into 0.4.9. It makes viewing indexes in large directories on the gateway possible.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

I am still trying to figure out what this is doing. I think I know what is going on in core/commands/files/files.go can you give me a one or two sentence overview of what you are doing in core/corehttp/gateway_handler.go?

out.Size = d.GetFilesize()
out.CumulativeSize = cumulsize

case *dag.RawNode:
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: There is a lot of code movement in this file. From what I can tell all that is really going on is there is an optimization for RawNode so that it doesn't have the get the block associated with the RawNode. Is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, yeah. Though im going to remove the changes to the files code from this PR. Its a separate changeset

@kevina kevina requested review from kevina and removed request for kevina May 5, 2017 06:43
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping
Copy link
Member Author

Previously, to find if the directory had an index.html, we enumerated all the links, and iterated over them and looked for one named 'index.html'. That worked okay previously, but for large sharded directories, its realy slow. I've switched it to using Find on a unixfs directory, which does an efficient lookup.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

One minor style issue, but otherwise LGTM.

http.ServeContent(w, r, "index.html", modtime, dr)
return
default:
internalWebError(w, err)
Copy link
Contributor

@kevina kevina May 5, 2017

Choose a reason for hiding this comment

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

Not sure what the official go style is here, but I would put the default as the last case, although I have seen it as the first case in go code, just don't put in the middle.

Copy link
Member

Choose a reason for hiding this comment

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

In this case it isn't about keyword but its meaning. In this case default error is still an error, below it there is non-error handler.

@whyrusleeping whyrusleeping merged commit afa0c34 into master May 7, 2017
@whyrusleeping whyrusleeping deleted the feat/faster-listing branch May 7, 2017 03:29
@whyrusleeping whyrusleeping removed the status/in-progress In progress label May 7, 2017
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
improved gateway directory listing for sharded nodes

This commit was moved from ipfs/kubo@afa0c34
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

Successfully merging this pull request may close these issues.

3 participants