Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyvsc performance dominated by stack frame operations in inspect module #183

Open
grahamcx opened this issue Jul 13, 2023 · 1 comment
Open

Comments

@grahamcx
Copy link

Hi,

I've been profiling my cocotb testbenches where I use pyvsc extensively, to see where I can gain simulation performance. I noticed that a large proportion of the python time is spent in rand_obj.init and most of this is spent in the call to inspect.stack().

Looking through the code it looks like these calls are used to provide the excellent debug features which make debugging constraint failures possible. However for testbenches where the constraints are stable and there are no constraint failures to debug, it looks like this feature is costing sim performance.

I may well be missing some important other use case of the srcinfo_inst attributes that init adds to randobjs but if the purpose is just for debug it may be worth implementing a switch to allow this feature to be disabled where debug is not needed but simulation speed is.

Thanks,
Graham

@mballance
Copy link
Member

Hi @grahamcx,
Indeed, for some reason, call-stack inspection is quite slow in Python! Out of the box, PyVSC should omit the work needed to capture source information about classes (something it currently needs to do every time a class is instanced). PyVSC still captures source information about covergroups, but the hope is that these are created much less frequently so the overhead is significantly lower.
Here's a link to instructions on how source-info capture is enabled: Capturing Source Information. Can you confirm that you are not setting the global environment variable, and that your class decorators don't use 'srcinfo=True'?
If things are still slow after confirming that source-capture should be turned off, it might be worth checking the version of PyVSC that you're using. 'Capture off' has been the default policy for quite some time, but I know it's also easy for older packages to hang around systems as long as they're mostly working.

Please let me know either way if you're able to resolve the issue!

Thanks,
Matthew

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

No branches or pull requests

2 participants