Skip to content

Conversation

@varungandhi-src
Copy link
Contributor

scip print --json is a bit slow; this change provides a noticeable speedup.

E.g. on benchmarking against flink-1.scip.

❯ hyperfine '~/Code/scip/scip-before print --json flink-1.scip' '~/Code/scip/scip-after print --json flink-1.scip'
Benchmark 1: ~/Code/scip/scip-before print --json flink-1.scip
  Time (mean ± σ):      5.786 s ±  0.547 s    [User: 7.225 s, System: 0.861 s]
  Range (min … max):    5.499 s …  7.330 s    10 runs

Benchmark 2: ~/Code/scip/scip-after print --json flink-1.scip
  Time (mean ± σ):      3.323 s ±  0.197 s    [User: 4.294 s, System: 0.685 s]
  Range (min … max):    3.180 s …  3.870 s    10 runs

Summary
  '~/Code/scip/scip-after print --json flink-1.scip' ran
    1.74 ± 0.19 times faster than '~/Code/scip/scip-before print --json flink-1.scip'

Test plan

n/a

type JsonIndex struct {
Metadata struct {
ProjectRoot string `json:"projectRoot"`
ProjectRoot string `json:"project_root"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is technically a breaking change, but scip print --json is only meant to be used for debugging, so I think this is OK. This is coming about because in scip.pb.go, the struct tags specified for protobuf's JSON encoding and the normal JSON encoding are different.

https://sourcegraph.com/github.com/sourcegraph/scip/-/blob/bindings/go/scip/scip.pb.go?L1488

	ProjectRoot string `protobuf:"bytes,3,opt,name=project_root,json=projectRoot,proto3" json:"project_root,omitempty"`

Comment on lines +66 to +68
require.Equal(t, "howdy", roundtripResult.Metadata.ProjectRoot)
require.Equal(t, 1, len(roundtripResult.Documents))
require.Equal(t, "f", roundtripResult.Documents[0].RelativePath)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this order as expected values are supposed to be on the LHS.

@varungandhi-src varungandhi-src merged commit a1696fb into main Nov 30, 2024
1 check passed
@varungandhi-src varungandhi-src deleted the vg/fast-json branch November 30, 2024 08:33
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.

2 participants