Commit a3f0bfa
Starlarkify ProtoInfo
The Starlark version needs to follow fields as they were exposed on ProtoInfoApi.
The change is slightly confusing, because native fields are sometimes named differently from Starlark ones. Here's the mapping:
Type | Native field | Starlark field
:------------------ | :--------------------- | :---
Artifact | directDescriptorSet | direct_descriptor_set
List<ProtoSource> | directSources | _direct_proto_sources (private)
List<Artifact> | directProtoSources | direct_sources = extractProtoSources(directSources)
PathFragment | directProtoSourceRoot | proto_source_root = directProtoSourceRoot.getSafePathString();
NestedSet<ProtoSource> | transitiveSources | _transitive_proto_sources (private)
NestedSet<Artifact> | transitiveProtoSources | transitive_imports, transitive_sources
NestedSet<String> | transitiveProtoSourceRoots | transitive_proto_path
NestedSet<Artifact> | strictImportableProto-SourcesForDependents | check_deps_sources
NestedSet<Artifact> | transitiveDescriptorSets | transitive_descriptor_sets
NestedSet<ProtoSource> | exportedSources | _exported_sources (private)
The fields `transitive_imports` and `transitive_sources` are duplicated in Starlark.
Native `directProtoSourceRoot` was interned using `ProtoCommon.memoryEfficientProtoSourceRoot`. There's no optimisation on `proto_source_root`, for now it doesn't seem necessary and I have ideas how to optimise `ProtoInfo` further without it.
The change introduces a slight regression in retained heap on benchmarked builds <0.1%. It's caused because of extra containers. That is in Starlark each instance needs two references and an Object array, whereas natively there's no need for references or arrays: `StarlarkInfo { ProtoInfo.class, Object[]{ f1, f2 } } > ProtoInfo { f1,f2 }`.
PiperOrigin-RevId: 511854620
Change-Id: I239aef427898e30e4f264f002e79b69eeaaa34db1 parent 32e4f23 commit a3f0bfa
17 files changed
Lines changed: 210 additions & 457 deletions
File tree
- src
- main
- java/com/google/devtools/build/lib
- bazel/rules
- rules
- objc
- proto
- starlarkbuildapi
- proto
- starlark/builtins_bzl/common
- proto
- test/java/com/google/devtools/build/lib/rules/proto
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
| |||
322 | 321 | | |
323 | 322 | | |
324 | 323 | | |
325 | | - | |
326 | 324 | | |
327 | 325 | | |
328 | 326 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
855 | | - | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
856 | 860 | | |
857 | 861 | | |
858 | 862 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
Lines changed: 0 additions & 66 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 18 | | |
27 | 19 | | |
28 | 20 | | |
29 | 21 | | |
30 | 22 | | |
31 | 23 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | 24 | | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
0 commit comments