lutaml-model 0.8.71 → 0.8.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bench/bench_common.rb +11 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/plan_compiler.rb +24 -11
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95182bda9669da0320508b55f43356fede1a292ce745cf3909f8f1caa9b07b42
|
|
4
|
+
data.tar.gz: 9d28efcea7784103991d992e3e85a4fd4f00b8caf90ec3edf137bea4b2fdc768
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '03994dc9b1069fc2fdb00f41b2ee949a0a9b9f0845673847af0b5c2ffff9d63e6a6d72078f03938f65e657dbb27b8fe29e426c9f6764b7ee692f49ce5b9cd3af'
|
|
7
|
+
data.tar.gz: 24f6867bb3851091561f98fbff70566f7734d58da18fa8ce2d9b220fb99d4a0ee87db1f497ce69278aa12462a7addb1e0bbccd726dfeb8e139aeb5c98c761c6d
|
data/bench/bench_common.rb
CHANGED
|
@@ -12,6 +12,17 @@
|
|
|
12
12
|
# bundle exec ruby bench/bench_uniword.rb
|
|
13
13
|
|
|
14
14
|
require "bundler/setup"
|
|
15
|
+
|
|
16
|
+
# TODO.perf/15: run any benchmark with PLAN_COMPILE_STATS=1 to append
|
|
17
|
+
# the plan-compiler opt-out histogram (which clauses keep a corpus on
|
|
18
|
+
# the interpretive path) after the benchmark output.
|
|
19
|
+
if ENV["PLAN_COMPILE_STATS"]
|
|
20
|
+
at_exit do
|
|
21
|
+
require "pp"
|
|
22
|
+
puts "\nPlanCompiler opt-out histogram:"
|
|
23
|
+
pp(Lutaml::Xml::PlanCompiler.stats)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
15
26
|
require "benchmark"
|
|
16
27
|
require "fileutils"
|
|
17
28
|
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -24,6 +24,19 @@ module Lutaml
|
|
|
24
24
|
# full semantics audit (parent links, consolidation, ordering
|
|
25
25
|
# metadata) completes.
|
|
26
26
|
module PlanCompiler
|
|
27
|
+
# TODO.perf/15: env-gated histogram of why models opt out of the
|
|
28
|
+
# plan path. Set PLAN_COMPILE_STATS=1 and read PlanCompiler.stats
|
|
29
|
+
# after a parse. Zero cost when disabled.
|
|
30
|
+
def self.stats
|
|
31
|
+
@stats ||= Hash.new(0)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.opt_out!(clause)
|
|
35
|
+
@plan_stats ||= Hash.new(0)
|
|
36
|
+
@plan_stats[clause] += 1 if ENV["PLAN_COMPILE_STATS"]
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
27
40
|
# Isolated holder: suites freeze model classes; a cache on a
|
|
28
41
|
# frozen constant would be immutable (TypeProbeCache precedent).
|
|
29
42
|
PLAN_CACHE = ::Class.new do
|
|
@@ -103,8 +116,8 @@ module Lutaml
|
|
|
103
116
|
else
|
|
104
117
|
model_class.attributes(register)[rule.to]
|
|
105
118
|
end
|
|
106
|
-
return
|
|
107
|
-
return
|
|
119
|
+
return opt_out!(:attr_nil) if attr.nil?
|
|
120
|
+
return opt_out!(:derived) if attr.derived?
|
|
108
121
|
|
|
109
122
|
# Partition rows (TODO 34 step 2) ride native predicates
|
|
110
123
|
# only in the plain-capture shape; any other when_attribute
|
|
@@ -118,7 +131,7 @@ module Lutaml
|
|
|
118
131
|
!attr.polymorphic? && !attr.union? &&
|
|
119
132
|
!(t.is_a?(Class) &&
|
|
120
133
|
t.include?(::Lutaml::Model::Serialize))
|
|
121
|
-
return
|
|
134
|
+
return opt_out!(:non_plain_partition) unless plain_partition
|
|
122
135
|
end
|
|
123
136
|
|
|
124
137
|
# Interpretive hydration materializes every mapped
|
|
@@ -132,20 +145,20 @@ module Lutaml
|
|
|
132
145
|
# ns-qualified models keep those rules interpretive.
|
|
133
146
|
fragment_needed = rule.has_custom_method_for_deserialization? ||
|
|
134
147
|
rule.polymorphic_mapping? || attr.polymorphic? || attr.union?
|
|
135
|
-
return
|
|
148
|
+
return opt_out!(:fragment_with_ns) if fragment_needed && model_ns
|
|
136
149
|
|
|
137
150
|
if rule.attribute?
|
|
138
|
-
return
|
|
151
|
+
return opt_out!(:non_scalar) unless scalar_type?(attr, register)
|
|
139
152
|
# Attribute plan rows are local-name keyed; a type-level
|
|
140
153
|
# namespace makes the attribute (URI, local)-identified
|
|
141
154
|
# (lutaml-model#744) — the interpretive matcher owns it
|
|
142
155
|
# until plan rows carry namespace identity.
|
|
143
|
-
return
|
|
156
|
+
return opt_out!(:attr_type_ns) if attr.type_namespace_class(register)
|
|
144
157
|
|
|
145
158
|
attr_rows << [rule, attr]
|
|
146
159
|
plan_attrs << { name: rule.name.to_s }
|
|
147
160
|
elsif rule.content_mapping?
|
|
148
|
-
return
|
|
161
|
+
return opt_out!(:multi_content) if content_rows(rows) >= 1
|
|
149
162
|
|
|
150
163
|
mixed_content = true
|
|
151
164
|
compiled << [rule, attr,
|
|
@@ -161,7 +174,7 @@ module Lutaml
|
|
|
161
174
|
rows << { name: rule.name.to_s, kind: :raw }
|
|
162
175
|
elsif rule.polymorphic_mapping? || attr.polymorphic? || attr.union?
|
|
163
176
|
type = attr.type(register)
|
|
164
|
-
return
|
|
177
|
+
return opt_out!(:non_serializable_poly) unless serializable_type?(type) || attr.union?
|
|
165
178
|
|
|
166
179
|
needs_nodes = true
|
|
167
180
|
compiled << [rule, attr, :polymorphic, nil, delegate_target]
|
|
@@ -170,7 +183,7 @@ module Lutaml
|
|
|
170
183
|
type = attr.type(register)
|
|
171
184
|
if serializable_type?(type)
|
|
172
185
|
child = compile(type, register)
|
|
173
|
-
return
|
|
186
|
+
return opt_out!(:child_uncompilable) unless child
|
|
174
187
|
|
|
175
188
|
if child[:ordered]
|
|
176
189
|
# Ordered/mixed children need element_order on their
|
|
@@ -178,7 +191,7 @@ module Lutaml
|
|
|
178
191
|
# source nodes, so the subtree defers interpretively
|
|
179
192
|
# (the fragment parse runs the full machinery,
|
|
180
193
|
# order included).
|
|
181
|
-
return
|
|
194
|
+
return opt_out!(:ordered_child_with_ns) if model_ns
|
|
182
195
|
|
|
183
196
|
needs_nodes = true
|
|
184
197
|
compiled << [rule, attr, :ordered_deferred, nil,
|
|
@@ -200,7 +213,7 @@ module Lutaml
|
|
|
200
213
|
type_tag: (tag += 1) }
|
|
201
214
|
end
|
|
202
215
|
else
|
|
203
|
-
return
|
|
216
|
+
return opt_out!(:non_scalar) unless scalar_type?(attr, register)
|
|
204
217
|
|
|
205
218
|
row = { name: rule.name.to_s }
|
|
206
219
|
row[:ns] = child_ns(rule, model_ns) if rule.namespace_set?
|