Skip to content

Commit

Permalink
Next (#960)
Browse files Browse the repository at this point in the history
* sync margo

* v20.02.01
  • Loading branch information
DisposaBoy authored Feb 1, 2020
1 parent f78e351 commit 8265060
Show file tree
Hide file tree
Showing 140 changed files with 4,520 additions and 2,079 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ https://margo.sh/b/motd - Get notified when GoSublime has a new release.

## Changes

## 20.02.01

This release focuses on fixing a performance issue due to a failure to resetting all cached data prematurely.

- Cache some files in memory to avoid re-reading from disk every time.

- The `&nodejs.PackageScripts{}` reducer now uses `yarn` instead of `npm` if the `yarn.lock` file is present.

## 20.01.01

This release mainly focuses on under-the-hood improvements for module support.
Expand Down
2 changes: 1 addition & 1 deletion gosubl/about.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import sublime

TAG = '20.01.01-1'
TAG = '20.02.01-1'
ANN = 'a'+TAG
VERSION = 'r'+TAG
VERSION_PAT = re.compile(r'\d{2}[.]\d{2}[.]\d{2}-\d+', re.IGNORECASE)
Expand Down
32 changes: 20 additions & 12 deletions src/margo.sh/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/margo.sh/golang/gopkg/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/rogpeppe/go-internal/module"
"github.com/rogpeppe/go-internal/semver"
"go/build"
"io/ioutil"
"margo.sh/golang/goutil"
"margo.sh/mg"
"margo.sh/mgutil"
Expand Down Expand Up @@ -405,7 +404,7 @@ func loadModSumNd(mx *mg.Ctx, dirNd *vfs.Node) (*modFile, error) {

func loadModSum(mx *mg.Ctx, dir string) (*modFile, error) {
gomod := filepath.Join(dir, "go.mod")
modSrc, err := ioutil.ReadFile(gomod)
modSrc, err := mx.VFS.ReadBlob(gomod).ReadFile()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -457,7 +456,7 @@ func loadModSum(mx *mg.Ctx, dir string) (*modFile, error) {
}

gosum := filepath.Join(dir, "go.sum")
sumSrc, err := ioutil.ReadFile(gosum)
sumSrc, err := mx.VFS.ReadBlob(gosum).ReadFile()
if err != nil {
return mf, nil
}
Expand Down
8 changes: 8 additions & 0 deletions src/margo.sh/golang/goutil/goutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func BuildContext(mx *mg.Ctx) *build.Context {
if v := mx.View; v != nil && p == v.Path {
return v.Open()
}
if v := mx.View; v != nil && v.Path != "" && filepath.Dir(v.Path) == filepath.Dir(p) {
if b := mx.VFS.ReadBlob(p); b != nil {
return b.OpenFile()
}
}
if b := mx.VFS.PeekBlob(p); b != nil {
return b.OpenFile()
}
return os.Open(p)
}
return c
Expand Down
3 changes: 1 addition & 2 deletions src/margo.sh/golang/goutil/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"go/parser"
"go/scanner"
"go/token"
"io/ioutil"
"margo.sh/mg"
)

Expand Down Expand Up @@ -39,7 +38,7 @@ func ParseFileWithMode(mx *mg.Ctx, fn string, src []byte, mode parser.Mode) *Par
if len(src) == 0 {
var err error
if fn != "" {
src, err = ioutil.ReadFile(fn)
src, err = mx.VFS.ReadBlob(fn).ReadFile()
}
if len(src) == 0 {
return &ParsedFile{
Expand Down
3 changes: 2 additions & 1 deletion src/margo.sh/golang/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"margo.sh/mg"
"margo.sh/mgpf"
"margo.sh/mgutil"
"os"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -56,7 +57,7 @@ func (tc *TypeCheck) check(mx *mg.Ctx) {
if pf.Dur().Duration < 100*time.Millisecond {
return
}
mx.Profile.Fprint(mx.Log.Dbg.Writer(), &mgpf.PrintOpts{
mx.Profile.Fprint(os.Stderr, &mgpf.PrintOpts{
MinDuration: 10 * time.Millisecond,
})
}()
Expand Down
3 changes: 1 addition & 2 deletions src/margo.sh/kimporter/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"go/build"
"go/parser"
"go/token"
"io/ioutil"
"margo.sh/mg"
"path/filepath"
"sync"
Expand All @@ -23,7 +22,7 @@ type kpFile struct {

func (kf *kpFile) init() {
if len(kf.Src) == 0 {
kf.Src, kf.Err = ioutil.ReadFile(kf.Fn)
kf.Src, kf.Err = kf.Mx.VFS.ReadBlob(kf.Fn).ReadFile()
if kf.Err != nil {
return
}
Expand Down
16 changes: 11 additions & 5 deletions src/margo.sh/memo/memo.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,24 @@ func (m *M) clear() []Sticky {
}

func (m *M) Values() map[K]V {
vals := map[K]V{}
m.Range(func(k K, v V) {
vals[k] = v
})
return vals
}

func (m *M) Range(f func(k K, v V)) {
if m == nil {
return nil
return
}

m.mu.Lock()
defer m.mu.Unlock()

vals := make(map[K]V, len(m.ml))
for k, p := range m.ml {
for _, p := range m.ml {
if v := p.value(); v != nil {
vals[k] = v
f(p.k, v)
}
}
return vals
}
56 changes: 45 additions & 11 deletions src/margo.sh/mg/vfs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mg

import (
"fmt"
hmnz "github.com/dustin/go-humanize"
"margo.sh/vfs"
"path/filepath"
"strings"
)

var (
Expand All @@ -20,21 +23,29 @@ func (vc *vfsCmd) Reduce(mx *Ctx) *State {
mx.VFS.Invalidate(v.Name)
mx.VFS.Invalidate(v.Filename())
case RunCmd:
return mx.AddBuiltinCmds(BuiltinCmd{
Name: ".vfs",
Desc: "Print a tree representing the default VFS",
Run: vc.run,
})
return mx.AddBuiltinCmds(
BuiltinCmd{
Name: ".vfs",
Desc: "Print a tree representing the default VFS",
Run: func(cx *CmdCtx) *State {
go vc.cmdVfs(cx)
return cx.State
},
},
BuiltinCmd{
Name: ".vfs-blobs",
Desc: "Print a list, and summary of, blobs (file contents) cached in the VFS.",
Run: func(cx *CmdCtx) *State {
go vc.cmdVfsBlobs(cx)
return cx.State
},
},
)
}
return mx.State
}

func (vc *vfsCmd) run(cx *CmdCtx) *State {
go vc.cmd(cx)
return cx.State
}

func (vc *vfsCmd) cmd(cx *CmdCtx) {
func (vc *vfsCmd) cmdVfs(cx *CmdCtx) {
defer cx.Output.Close()

if len(cx.Args) == 0 {
Expand All @@ -59,6 +70,29 @@ func (vc *vfsCmd) cmd(cx *CmdCtx) {
}
}

func (vc *vfsCmd) cmdVfsBlobs(cx *CmdCtx) {
defer cx.Output.Close()

files := int64(0)
size := uint64(0)
cx.VFS.PrintWithFilter(cx.Output, func(nd *vfs.Node) string {
if nd.IsBranch() {
return nd.String()
}
nm := []string{}
for _, b := range vfs.Blobs(nd) {
files++
sz := uint64(b.Len())
size += sz
nm = append(nm, fmt.Sprintf("%s (%s)", nd.String(), hmnz.IBytes(sz)))
}
return strings.Join(nm, ", ")
})
fmt.Fprintf(cx.Output, "\n%s files (%s) cached in memory.",
hmnz.Comma(files), hmnz.IBytes(size),
)
}

func init() {
DefaultReducers.Before(&vfsCmd{})
}
21 changes: 21 additions & 0 deletions src/margo.sh/vendor/github.com/dustin/go-humanize/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/margo.sh/vendor/github.com/dustin/go-humanize/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8265060

Please sign in to comment.