perf(execution): build component association indexes only when needed
This commit is contained in:
1 parent
2ad36ba45d
commit
8fe82c3124
3 files changed
+93
-15
No files matched your search
@@ -458,6 +458,54 @@ Require Not QP_NativeMutationPossible,"no native mutation"
|
||||
''')
|
||||
|
||||
|
||||
def test_zero_match_does_not_read_unused_component_geometry(tmp_path, monkeypatch):
|
||||
counted = EXTRA.replace('Public UID, Refdes, Orientation, Scale, Attributes, AddCount',
|
||||
'Public UID, Refdes, Orientation, Scale, Attributes, AddCount, LocationReads')
|
||||
counted = counted.replace('Set GetLocation=Point',
|
||||
'LocationReads=LocationReads+1\n Set GetLocation=Point', 1)
|
||||
monkeypatch.setattr(f'{__name__}.EXTRA', counted)
|
||||
run_vbs(tmp_path, 'preserve', '''
|
||||
QP_Fso.DeleteFile SnapshotPath
|
||||
Comp.LocationReads=0
|
||||
QPCaptureAndSelect Command,SnapshotPath
|
||||
Require QPReadState(QP_Fso.BuildPath(QP_Root,"status.tsv"),"value-job")="no_match","no-match state"
|
||||
Require Comp.LocationReads=0,"no-match read geometry for an index that is never consumed"
|
||||
Require Not QP_Fso.FileExists(SnapshotPath),"no-match generated a snapshot"
|
||||
''')
|
||||
|
||||
|
||||
def test_component_lookup_reads_fallback_geometry_only_when_needed(tmp_path, monkeypatch):
|
||||
counted = EXTRA.replace('Public UID, Refdes, Orientation, Scale, Attributes, AddCount',
|
||||
'Public UID, Refdes, Orientation, Scale, Attributes, AddCount, LocationReads')
|
||||
counted = counted.replace('Set GetLocation=Point',
|
||||
'LocationReads=LocationReads+1\n Set GetLocation=Point', 1)
|
||||
monkeypatch.setattr(f'{__name__}.EXTRA', counted)
|
||||
run_vbs(tmp_path, 'preserve', '''
|
||||
Dim Records, Record, Candidate
|
||||
Set Records=QPReadSnapshot(SnapshotPath)
|
||||
Set Record=Records.Item("components").Item("0")
|
||||
QPInvalidateComponentIndex
|
||||
Comp.LocationReads=0
|
||||
Set Candidate=QPFindUniqueByOldLocation(Record)
|
||||
Require Candidate Is Comp,"UID lookup returned wrong component"
|
||||
Require Comp.LocationReads=0,"UID lookup eagerly read fallback geometry"
|
||||
Record("uid")="missing"
|
||||
Set Candidate=QPFindUniqueByOldLocation(Record)
|
||||
Require Candidate Is Comp,"refdes fallback returned wrong component"
|
||||
Require Comp.LocationReads=0,"refdes lookup eagerly read location fallback"
|
||||
Record("refdes")="missing"
|
||||
Set Candidate=QPFindUniqueByOldLocation(Record)
|
||||
Require Candidate Is Comp,"location fallback returned wrong component"
|
||||
Require Comp.LocationReads=1,"location fallback did not read geometry exactly once"
|
||||
Set Candidate=QPFindUniqueByOldLocation(Record)
|
||||
Require Comp.LocationReads=1,"same read context rebuilt its fallback index"
|
||||
QPInvalidateComponentIndex
|
||||
Set Candidate=QPFindUniqueByOldLocation(Record)
|
||||
Require Candidate Is Comp,"fresh location fallback returned wrong component"
|
||||
Require Comp.LocationReads=2,"invalidated index reused stale geometry"
|
||||
''')
|
||||
|
||||
|
||||
def test_pin_index_avoids_repeated_full_sheet_queries(tmp_path):
|
||||
run_vbs(tmp_path, 'part_number', '''
|
||||
QPInvalidatePinIndex
|
||||
|
||||
Reference in new issue
Block a user