-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/playground: feature request: prepopulate file system with contents of $GOROOT/src #23603
Comments
Seems reasonable. |
I'm fairly sure that fixing this would fix #19825 too. |
How to resolve playground results caching vs different Go versions ie. different $GOROOT/src contents? |
Caching is keyed off of whatever version the playground is running: https://github.com/golang/playground/blob/master/sandbox.go#L83 So bugs reported for older (or non-stable) versions of Go would not be able to use this mechanism. |
Adding the whole tree of /src into NaCl fake filesystem is expensive (100mb+ of data). Can anybody give a reasonable use case when accessing $GOROOT/src is required and will make a good example in docs, etc? I fail to see a strong reason for that. |
Some tests and examples use files within the Go tree, such as go/parser using its own Go files in an example - #19823. Although it's not a terribly strong case; they could all be rewritten to embed small sample files. |
@ysmolsky The motivating example was https://play.golang.org/p/r5oZfFZHIF8 from #23594 which made it harder to demonstrate the bug in that issue (well maybe not "harder" as much as not "extremely easy"). I've also written examples of how to use the go/* packages for people asking questions but had to explain that it didn't work on the playground and they had to go run it locally (which caused some confusion). Adding a playable example for go/build.Import would be possible with small sample files in strings but it would also need to override a lot of the hooks in the build Context to access that faux-file, to the point where the example would mostly be doing that and only a small fraction of the example code would be about the example itself. Anyway it's not like it has to download that 100mb into the browser or anything so it would only affect people running the playground. |
Fair enough. I will see what can be done and what it will cost. |
Aside: Are the nacl contents compressed? They should compress very well... |
Building playground with fake fs including everything from $GOROOT/src, except /cmd and /syscall (biggest directories) resulted in the following binary sizes in the docker image:
Compared to the original sizes:
Avg response time from When add more content to fake fs of NaCL, we add overhead in the form of time needed to unzip the file pack
|
Could we switch to lazily unzipping on a file-by-file basis? |
More DYI benchmarks for src-included build. This program takes about 1100 ms to run in local playground:
Original playground runs it for ~ 245ms |
Change https://golang.org/cl/100060 mentions this issue: |
@josharian the problem with file-by-file approach is that whenever syscall is used fake FS initialised at once in memory from big zip blog. If we were to init file on demand we would have to rebuild the whole thing from scratch. @jimmyfrasche can we reduce to packages set from /src/ to some bare minimum required for example? do we really need all of them? |
@ysmolsky it should be totally fine to ditch any testdata directory and an acceptable trade-off to dump cmd/ but I'm guessing the problem is deeper, based on your findings so far. |
Yes, my suggestion was to not initialize the whole thing at once, but instead initialize only the directory layout and contents, and initialize individual files lazily as needed. But I haven't looked at all about what would be involved in doing that. |
I took a quick look at this. In syscall/unzip_nacl.go |
Change https://golang.org/cl/100815 mentions this issue: |
Change https://golang.org/cl/101280 mentions this issue: |
Change https://golang.org/cl/101281 mentions this issue: |
Change https://golang.org/cl/101286 mentions this issue: |
@ysmolsky I've been looking through all of the stdlib examples and there are quite a few examples that access testdata but none of them would work even with this because they assume that the working directory == the package directory. |
@ysmolsky have you had a chance to investigate @josharian's suggestion? |
@jimmyfrasche I had a chance, but I do not see a way to implement this for now. :-( |
So poking at the code, if I understand things, there needs to be two changes: Change A Neither of those seem exactly easy to do, but it seems like they would be sufficient. Is that everyone else's read of the situation? |
Sounds plausible. Might also need to think about any concurrency requirements (need sync.Once?). |
It would need something, definitely. Probably that just because it's the simplest, but it looks like everything in the nacl fs has lots of locking already and everywhere this would be needed would require locks so it might just need a wasDecompressed flag or somesuch. |
Adding the $GOROOT contents to the playground file system would make it possible to use more of the
go/*
packages in the playground more easily.This would be helpful for both reporting bugs in the
go/*
packages and for sharing demonstrations of how to use thego/*
packages.The text was updated successfully, but these errors were encountered: