[YANGTOOLS-1067] Use flyweight EffectiveStatement implementations Created: 11/Jan/20  Updated: 04/Dec/21  Resolved: 04/Dec/21

Status: Resolved
Project: yangtools
Component/s: parser
Affects Version/s: None
Fix Version/s: 8.0.0

Type: Improvement Priority: Medium
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: PNG File image-2020-12-03-19-16-01-224.png     PNG File image-2020-12-03-19-16-57-891.png     PNG File junos_yt800_dups.png    
Issue Links:
Blocks
is blocked by YANGTOOLS-694 Eliminate duplicate DescriptionEffect... Resolved
is blocked by YANGTOOLS-1066 SchemaPath identification of SchemaNo... Resolved
Relates
relates to YANGTOOLS-1209 Track substatement independence in St... Resolved
Sub-Tasks:
Key
Summary
Type
Status
Assignee
YANGTOOLS-1212 Reuse effective substatement lists wh... Sub-task Resolved Robert Varga  
YANGTOOLS-1213 Allow substatement-derived state to b... Sub-task Resolved Robert Varga  
YANGTOOLS-1214 Reuse effective substatements along e... Sub-task Resolved Robert Varga  
Epic Link: Parser Performance

 Description   

Most EffectiveStatement subtrees are inlined via grouping/uses mechanics, which we gain control of via YANGTOOLS-694.

Since most effective statements have a SchemaPath, their state depends on it and thus we cannot reasonably share state – this property cascades to parent substatement list – hence we can share very little.

Once we get rid of SchemaPath, though, each effective statement's state is (mostly?) dominated by its QName (which dictates substatements' QNames, etc.), hence we can deploy a very efficient flyweight pattern, where we maintain a QNameModule -> template cache and aggressively reuse effective statements.



 Comments   
Comment by Robert Varga [ 14/Jan/20 ]

Note that CopyHistory and parent's 'isConfiguration' are also contributing to that state (but we should get that at buildEffective() time from YANGTOOLS-694). The overall matrix of possible states is nevertheless quite small and amenable to caching.

Comment by Robert Varga [ 03/Dec/20 ]

The primary goal here is to eliminate duplicate lists (note Object[] is used by RegularImmutableList, too)

Comment by Robert Varga [ 03/Dec/20 ]

These typically consist of CopyPolicy.CONTEXT_INDEPENDENT:

hence the list should be readily shared

Comment by Robert Varga [ 12/Feb/21 ]

Unfortunately the current mode of operation causes a significant CPU regression without any real benefit. This will need to be revisited.

Comment by Robert Varga [ 02/Sep/21 ]

with SchemaPath out of the picture, the situation is much better, but there is obviously still room for improvement.

Generated at Wed Feb 07 20:55:05 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.