[INSTRM-2102] Reduce the overhead of geometry loading Created: 08/Nov/23  Updated: 24/Jan/24  Resolved: 08/Dec/23

Status: Won't Fix
Project: Instrument control development
Component/s: ics_mcsActor
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Normal
Reporter: chyan Assignee: karr
Resolution: Won't Fix Votes: 0
Labels: EngRun
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Figure 1-16.png    
Sprint: 2DDRP-2023 A

 Description   

After using the multi-processing, the centroid time is much faster than before. Now. the first iteration still require ~4 seconds to load the geometry. We need to think about how to reduce the overhead

    def getGeometry(self, cmd):

        db = self.connectToDB(cmd)

        cmd.inform(f'text="getting geometry"')

        if(self.geometrySet == True):
            cmd.inform('text="geometry is already set"')
            return

        # boresight centre in pixels
        self.rotCent = dbTools.loadBoresightFromDB(db, int(self.visitId))
        cmd.inform(f'text="boresight={self.rotCent[0]},{self.rotCent[1]}"')

        # read xmlFile
        instPath = os.path.join(os.environ['PFS_INSTDATA_DIR'])
        #if(self.geomFile == None):
        #    self.geomFile = os.path.join(instPath, 'data/pfi/modules/ALL/ALL_final_20210920_mm.xml')
        if(self.dotFile == None):
            self.dotFile = os.path.join(
                instPath, "data/pfi/dot/black_dots_mm.csv")

        pfi = self.butler.get("moduleXml", moduleName="ALL", version="")
        dots = self.butler.get("black_dots", moduleName="ALL", version="")

        cmd.inform(f'text="loading XML from butler"')
        cmd.inform(f'text="loading DOT location from butler"')
        self.centrePos, self.armLength, self.dotPos, self.goodIdx, self.calibModel = mcsTools.readCobraGeometry(
            pfi, dots)
        
        fids = self.butler.get('fiducials')
        self.outerRingIds, self.badFidIds = mcsTools.readFiducialMasks(fids)
        cmd.inform('text="cobra geometry read"')
        self.geometrySet = True
 


 Comments   
Comment by price [ 09/Nov/23 ]

Can I suggest storing your data files in a binary format (that can be loaded directly into memory) rather than text (that has to be parsed)?

Comment by karr [ 08/Dec/23 ]

I looked at the code, and the geometry should only be loading once.

The suggestion was made of reading the geometry from the database, rather than XML. The key in either case is being sure that the format we're reading from is automatically synched to new XML files; it's not clear the database will always be matched to the current XML in pfs_instdata.

 

Generated at Sat Feb 10 16:43:01 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.