Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use objectpath.Encoder to amortize the cost of encoding the paths of …
…multiple objects (#140) We are using `objectpath.For` very heavily in our inference engine to construct package-independent object identifiers. However, each invocation comes with a cost of initializations (construction and traversal of the scope tree). Since x/tools v0.9.0 (we are currently on v0.11.0), there is an `objectpath.Encoder` that "[amortizes the cost of encoding the paths of multiple objects](https://pkg.go.dev/golang.org/x/tools/go/types/objectpath#Encoder)". This PR uses the encoder for better performance. There aren't/shouldn't be any functionality changes. A quick profile showing the timing before & after this PR for `accumulation.run` function (the entrypoint function for our inference engine): before: ``` 31.43s 22.49% | go.uber.org/nilaway/accumulation.run 15.69s 49.92% | go.uber.org/nilaway/inference.(*Engine).ObservePackage 8.11s 25.80% | go.uber.org/nilaway/inference.(*Engine).ObserveUpstream 3.33s 10.59% | go.uber.org/nilaway/inference.(*InferredMap).Export ... ``` after: ``` 18.34s 14.63% | go.uber.org/nilaway/accumulation.run 8.55s 46.62% | go.uber.org/nilaway/inference.(*Engine).ObserveUpstream 3.65s 19.90% | go.uber.org/nilaway/inference.(*InferredMap).Export 2.50s 13.63% | go.uber.org/nilaway/inference.(*Engine).ObservePackage ... ```
- Loading branch information