]> Cypherpunks repositories - gostls13.git/commit
go/ast: use token.Pos instead of token.Position; adjust all dependent code
authorRobert Griesemer <gri@golang.org>
Mon, 6 Dec 2010 22:23:18 +0000 (14:23 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 6 Dec 2010 22:23:18 +0000 (14:23 -0800)
commit5a9ad8b9e3a5835c3dc051fff97c1d81844260f6
treeaf0a99f94a56c077b06729cb1bc087aeb979a6e1
parent92bfd850e0b1d7740042d4983ea787592877082d
go/ast: use token.Pos instead of token.Position; adjust all dependent code

Specifically:

* lib/godoc:
- provide file set (FSet) argument to formatters where needed

* src/cmd:
- cgo, ebnflint, godoc, gofmt, goinstall: provide file set (fset) where needed
- godoc: remove local binary search with sort.Search (change by rsc),
  extract file set for formatters

* src/pkg:
- exp/eval: remove embedded token.Position fields from nodes and replace
  with named token.Pos fields; add corresponding Pos() accessor methods
- go/token: added file.Line(), changed signature of File.Position()

* test/fixedbugs/:
- bug206.go: change test to not rely on token.Pos details

* added various extra comments
* Runs all.bash
* gofmt formats all of src, misc w/o changes
* godoc runs

* performance:
- The new version of godoc consumes about the same space after indexing
  has completed, but indexing is half the speed. Significant space savings
  are expected from smaller ASTs, but since they are thrown away after a
  file has been indexed, this is not visible anymore. The slower indexing
  time is due to the much more expensive computation of line information.
  However, with the new compressed position information, indexing can be
  rewritten and simplified. Furthermore, computing the line info can be
  done more efficiently.

        New godoc, immediately after indexing completed (best of three runs):

  PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
44381 godoc        0.0%  0:38.00   4    19    149  145M   184K   148M   176M

2010/12/03 17:58:35 index updated (39.231s, 18505 unique words, 386387 spots)
2010/12/03 17:58:35 bytes=90858456 footprint=199182584
2010/12/03 17:58:36 bytes=47858568 footprint=167295224

Old godoc, immediately after indexing completed (best of three runs):

  PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE
23167 godoc        0.0%  0:22.02   4    17    132  129M   184K   132M   173M

2010/12/03 14:51:32 index updated (24.892s, 18765 unique words, 393830 spots)
2010/12/03 14:51:32 bytes=66404528 footprint=163907832
2010/12/03 14:51:32 bytes=46282224 footprint=163907832

The different numbers for unique words/spots stem from the fact the the
two workspaces are not exactly identical. The new godoc maintains a large
file set data structure during indexing which (probably) is the reason
for the larger heap (90858456 vs 66404528) before garbage collection.

R=rsc, r
CC=golang-dev
https://golang.org/cl/3050041
51 files changed:
lib/godoc/package.html
lib/godoc/package.txt
src/cmd/cgo/ast.go
src/cmd/cgo/gcc.go
src/cmd/cgo/main.go
src/cmd/cgo/out.go
src/cmd/cgo/util.go
src/cmd/ebnflint/ebnflint.go
src/cmd/godoc/dirtrees.go
src/cmd/godoc/godoc.go
src/cmd/godoc/index.go
src/cmd/godoc/main.go
src/cmd/godoc/snippet.go
src/cmd/godoc/spec.go
src/cmd/gofmt/gofmt.go
src/cmd/gofmt/rewrite.go
src/cmd/goinstall/main.go
src/cmd/goinstall/parse.go
src/pkg/ebnf/ebnf.go
src/pkg/ebnf/ebnf_test.go
src/pkg/ebnf/parser.go
src/pkg/exp/datafmt/datafmt_test.go
src/pkg/exp/datafmt/parser.go
src/pkg/exp/eval/bridge.go
src/pkg/exp/eval/compiler.go
src/pkg/exp/eval/eval_test.go
src/pkg/exp/eval/expr.go
src/pkg/exp/eval/main.go
src/pkg/exp/eval/scope.go
src/pkg/exp/eval/stmt.go
src/pkg/exp/eval/type.go
src/pkg/exp/eval/typec.go
src/pkg/exp/eval/world.go
src/pkg/exp/ogle/cmd.go
src/pkg/go/ast/ast.go
src/pkg/go/ast/filter.go
src/pkg/go/doc/doc.go
src/pkg/go/parser/interface.go
src/pkg/go/parser/parser.go
src/pkg/go/parser/parser_test.go
src/pkg/go/printer/nodes.go
src/pkg/go/printer/printer.go
src/pkg/go/printer/printer_test.go
src/pkg/go/scanner/scanner.go
src/pkg/go/scanner/scanner_test.go
src/pkg/go/token/position.go
src/pkg/go/token/position_test.go
src/pkg/go/typechecker/scope.go
src/pkg/go/typechecker/typechecker.go
src/pkg/go/typechecker/typechecker_test.go
test/fixedbugs/bug206.go