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

Excessive call stack depth on saving #512

Closed
samdmarshall opened this issue Dec 28, 2016 · 8 comments
Closed

Excessive call stack depth on saving #512

samdmarshall opened this issue Dec 28, 2016 · 8 comments

Comments

@samdmarshall
Copy link
Contributor

Description of the problem or steps to reproduce

I noticed some seemingly excessive CPU usage from micro when doing some basic operations, so I captured a sample of the process. I have attached said sample, and it seems that micro enters an enormous call-stack when saving a file. I think this might be a problem with how the file is being serialized (using encoding/gob), not with micro's code. If you think I should be opening this issue on that library instead I can do that.

sample.txt

Specifications

Version: 1.1.3
Commit hash: 67ac3f1
Compiled on December 06, 2016
ProductName:	Mac OS X
ProductVersion:	10.12.2
BuildVersion:	16C67
@zyedidia
Copy link
Owner

I think this is happening because micro serializes the undo stack and this means serializing every TextEvent struct. I'm not sure if there is a more efficient way to do this. You can turn it off by turning off saveundo (I'm guessing savecursor doesn't cause too many problems).

@samdmarshall
Copy link
Contributor Author

The only thing this would stop is having access to the undo stack across sessions?

@zyedidia
Copy link
Owner

Yes, although I've looked at the code a bit more closely now and you would need to turn off both savecursor and saveundo because they both save their data to the same file, so if one of them is on then they are both on.

Perhaps this could be improved by separating cursor and undo files.

@zyedidia
Copy link
Owner

I'm guessing the file you were editing in this case has a large undo stack because it's one you edit a lot so it has a lot of history built up. It's probably a good idea to have a limit to how far back the undo stack goes, i.e. 1000 changes or something like that.

@samdmarshall
Copy link
Contributor Author

Does the undo stack get held in memory while micro is active? If so, then I'd suggest adding an option to the settings that takes an non-negative integer that sets the number of changes held (and if set to zero, doesn't limit the undo stack).

@samdmarshall
Copy link
Contributor Author

I've since turned off these features and also removed the buffers directory from ~/.config/micro/ and still seeing high CPU usage from open sessions that are idle. Do you want me to capture additional samples and attach them here?

@zyedidia
Copy link
Owner

I think the high CPU usage is more related to gdamore/tcell#129 than the buffer serialization.

@samdmarshall
Copy link
Contributor Author

:(

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