Noticeable delay in prompt return #1503
-
I had noticed a delay in getting prompt back even if all i did was just repeatedly press enter in the shell. The effect was somewhat significant if my command used the So i looked up the flame graph to identify the bottleneck. Seems
When I commented this out locally, the delay disappeared and everything still worked fine. ChatGPT had suggested replacing the subprocess with termios like this(Not sure how that works as i couldn't see any differences with/without the subprocess code so i am unsure how to test this out):
Can you please check on your side & let me know; The issue is easily seen if you try doing everything quick on the shell. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 7 replies
-
@Sripadvallabh Can you please give us a little bit more info to help us reproduce. Key things of interest:
Code for a toy cmd2 application that demonstrates this would also be helpful. |
Beta Was this translation helpful? Give feedback.
-
I did some initial testing on a system with the following setup:
In this testing I modified cmd's built-in timing measurement to capture the full command lifecycle timing. With the code as-is, the full lifecycle for an empty command on this older computer was about 0.007 seconds (7 thousands of a second). This is not something I would even remotely call "slow" given typical human reaction times. I did experiment replacing the subprocess call with a more optimized version of the @Sripadvallabh I trust that your personal observations of slowness are valid. But I believe there is some important difference or differences in the way we are testing, so I think I need more info from you to try to reproduce. |
Beta Was this translation helpful? Give feedback.
-
I created draft PR #1504 to experiment with changes suggested in this Discussion. |
Beta Was this translation helpful? Give feedback.
-
@Sripadvallabh We merged in the PR that made similar changes to what you suggested. Changes will be in the 3.0.0 release. |
Beta Was this translation helpful? Give feedback.
-
@Sripadvallabh That sounds like a very interesting an atypical use case. I'm glad cmd2 is able to meet your needs. Since you are using Python 3.8, you should be able to painlessly upgrade to cmd2 2.5.11. We haven't released 3.0.0 yet, but hope to do so within about a month. But that will required Python 3.10 or newer. |
Beta Was this translation helpful? Give feedback.
-
@Sripadvallabh Python 3.8 hit EOL about a year ago and 3.9 is going to hit EOL in a couple weeks: https://devguide.python.org/versions/ As such, I would strongly encourage you to upgrade the version of Python you are using if at all possible to one receiving security updates. If you need support for Python 3.9 we could probably backport the fix to the 2.x branch which is currently at 2.7.0. However, we dropped support for Python 3.8 starting with 2.6.0, so it is no longer possible for us to backport a fix for Python 3.8. |
Beta Was this translation helpful? Give feedback.
@Sripadvallabh We merged in the PR that made similar changes to what you suggested. Changes will be in the 3.0.0 release.