Skip to content

odb: speedup dbITerm::getMTerm()#9538

Open
openroad-ci wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:odb-getmterm-speedup
Open

odb: speedup dbITerm::getMTerm()#9538
openroad-ci wants to merge 1 commit intoThe-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:odb-getmterm-speedup

Conversation

@openroad-ci
Copy link
Collaborator

Cache the mterms on the dbInstHeader. Intended to help sta performance.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a performance optimization for dbITerm::getMTerm() by caching master terminal pointers (_dbMTerm*) in the _dbInstHdr. This avoids repeated lookups through the database hierarchy, which should improve performance as intended. The changes are well-contained and correctly handle cache population during dbInstHdr creation, dynamic updates in hierarchical blocks, and deserialization. The use of the cache in getMTerm is straightforward and achieves the intended speedup. The implementation appears solid and I have no further comments.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

dbId<_dbLib> lib_;
dbId<_dbMaster> master_;
dbVector<dbId<_dbMTerm>> mterms_;
std::vector<_dbMTerm*> mterm_ptrs_; // non-persistent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::vector" is directly included [misc-include-cleaner]

src/odb/src/db/dbInstHdr.h:6:

+ #include <vector>

Cache the mterms on the dbInstHeader.  Intended to help sta performance.

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@QuantamHD
Copy link
Collaborator

@maliberty Why not just store a dbMTerm* on the Iterm itself. I found it way faster to do that than go through the indirection of the vector.

@maliberty
Copy link
Member

That is a lot more memory as iterms are numerous. @dsengupta0628 will be profiling this so we'll get a sense if this is enough.

@QuantamHD
Copy link
Collaborator

QuantamHD commented Feb 25, 2026

Even on our 3 million standard cell block it only increases memory by 434MB. Against a 78GB total ram usage it's not much.

The problem with the vector is that you're taking two indirections and thrashing the cache. On most of my benchmarks i've seen MTerm take anywhere from 5-6% of the profile, I'd really make sure you're not just moving that cost around with this solution.

@QuantamHD
Copy link
Collaborator

I'd really urge you to do the comparison yourself. Just add the pointer to Iterm and load an existing ODB subtract the memory difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants