Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
8d7f0d31
Unverified
Commit
8d7f0d31
authored
1 year ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
add extrinsic base weight overhead
parent
c8d99448
No related branches found
No related tags found
No related merge requests found
Pipeline
#35108
passed
1 year ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/weight_analyzer/src/lib.rs
+17
-5
17 additions, 5 deletions
resources/weight_analyzer/src/lib.rs
with
17 additions
and
5 deletions
resources/weight_analyzer/src/lib.rs
+
17
−
5
View file @
8d7f0d31
...
@@ -55,13 +55,13 @@ pub fn analyze_weight(
...
@@ -55,13 +55,13 @@ pub fn analyze_weight(
)
->
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
{
)
->
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
{
let
pallet_weights
=
read_pallet_weight
(
folder_path
);
let
pallet_weights
=
read_pallet_weight
(
folder_path
);
let
db_weight
=
read_db_weight
(
folder_path
);
let
db_weight
=
read_db_weight
(
folder_path
);
let
_
overhead_weights
=
read_overhead_weight
(
folder_path
);
let
overhead_weights
=
read_overhead_weight
(
folder_path
);
// Initialize scope with db weights
// Initialize scope with db weights
let
mut
scope
=
Scope
::
from_substrate
();
let
mut
scope
=
Scope
::
from_substrate
();
scope
=
scope
.with_storage_weights
(
db_weight
.weights.read
,
db_weight
.weights.write
);
scope
=
scope
.with_storage_weights
(
db_weight
.weights.read
,
db_weight
.weights.write
);
process
(
pallet_weights
,
scope
,
max_block_weight
)
process
(
pallet_weights
,
scope
,
max_block_weight
,
&
overhead_weights
)
}
}
fn
read_pallet_weight
(
folder_path
:
&
Path
)
->
Vec
<
Vec
<
ChromaticExtrinsic
>>
{
fn
read_pallet_weight
(
folder_path
:
&
Path
)
->
Vec
<
Vec
<
ChromaticExtrinsic
>>
{
...
@@ -87,7 +87,7 @@ fn read_db_weight(folder_path: &Path) -> Weights {
...
@@ -87,7 +87,7 @@ fn read_db_weight(folder_path: &Path) -> Weights {
}
}
fn
read_overhead_weight
(
folder_path
:
&
Path
)
->
Weight
{
fn
read_overhead_weight
(
folder_path
:
&
Path
)
->
Weight
{
subweight_core
::
parse
::
overhead
::
parse_file
(
folder_path
.join
(
"
block
_weights.rs"
)
.as_path
())
subweight_core
::
parse
::
overhead
::
parse_file
(
folder_path
.join
(
"
extrinsic
_weights.rs"
)
.as_path
())
.expect
(
"No overhead weight"
)
.expect
(
"No overhead weight"
)
}
}
...
@@ -95,6 +95,7 @@ fn evaluate_weight(
...
@@ -95,6 +95,7 @@ fn evaluate_weight(
extrinsic
:
ChromaticExtrinsic
,
extrinsic
:
ChromaticExtrinsic
,
scope
:
&
mut
Scope
<
Term
<
u128
>>
,
scope
:
&
mut
Scope
<
Term
<
u128
>>
,
max_block_weight
:
&
MaxBlockWeight
,
max_block_weight
:
&
MaxBlockWeight
,
overhead
:
&
Weight
,
)
->
Result
<
(
String
,
String
,
WeightInfo
),
String
>
{
)
->
Result
<
(
String
,
String
,
WeightInfo
),
String
>
{
// Extend the scope with the maximum value of the complexity parameter.
// Extend the scope with the maximum value of the complexity parameter.
if
let
Some
(
params
)
=
extrinsic
.comp_ranges
{
if
let
Some
(
params
)
=
extrinsic
.comp_ranges
{
...
@@ -106,12 +107,22 @@ fn evaluate_weight(
...
@@ -106,12 +107,22 @@ fn evaluate_weight(
}
}
// Evaluate the weight
// Evaluate the weight
let
weight
=
extrinsic
let
mut
weight
=
extrinsic
.term
.term
.simplify
(
subweight_core
::
Dimension
::
Time
)
.simplify
(
subweight_core
::
Dimension
::
Time
)
.expect
(
"Can't evaluate"
)
.expect
(
"Can't evaluate"
)
.eval
(
scope
)
.eval
(
scope
)
.unwrap
();
.unwrap
();
// Add base extrinsic overhead
if
let
Weight
::
ExtrinsicBase
(
i
)
=
overhead
{
weight
+=
i
.simplify
(
subweight_core
::
Dimension
::
Time
)
.expect
(
"Can't evaluate"
)
.eval
(
scope
)
.unwrap
();
}
let
relative_weight
=
(
weight
as
f64
)
/
max_block_weight
*
100.
;
let
relative_weight
=
(
weight
as
f64
)
/
max_block_weight
*
100.
;
Ok
((
Ok
((
extrinsic
extrinsic
...
@@ -134,12 +145,13 @@ fn process(
...
@@ -134,12 +145,13 @@ fn process(
pallet_weights
:
Vec
<
Vec
<
ChromaticExtrinsic
>>
,
pallet_weights
:
Vec
<
Vec
<
ChromaticExtrinsic
>>
,
mut
scope
:
Scope
<
Term
<
u128
>>
,
mut
scope
:
Scope
<
Term
<
u128
>>
,
max_block_weight
:
&
MaxBlockWeight
,
max_block_weight
:
&
MaxBlockWeight
,
overhead
:
&
Weight
,
)
->
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
{
)
->
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
{
let
mut
weight_by_pallet
:
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
=
HashMap
::
new
();
let
mut
weight_by_pallet
:
HashMap
<
String
,
HashMap
<
String
,
WeightInfo
>>
=
HashMap
::
new
();
for
i
in
pallet_weights
{
for
i
in
pallet_weights
{
for
j
in
i
{
for
j
in
i
{
let
(
pallet
,
extrinsic
,
weight
)
=
let
(
pallet
,
extrinsic
,
weight
)
=
evaluate_weight
(
j
,
&
mut
scope
,
max_block_weight
)
.unwrap
();
evaluate_weight
(
j
,
&
mut
scope
,
max_block_weight
,
overhead
)
.unwrap
();
if
let
Some
(
i
)
=
weight_by_pallet
.get_mut
(
&
pallet
)
{
if
let
Some
(
i
)
=
weight_by_pallet
.get_mut
(
&
pallet
)
{
i
.insert
(
extrinsic
,
weight
);
i
.insert
(
extrinsic
,
weight
);
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment