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

Too slow in recent Mathematica 11 #1

Open
slizovskiy opened this issue Jan 4, 2017 · 10 comments
Open

Too slow in recent Mathematica 11 #1

slizovskiy opened this issue Jan 4, 2017 · 10 comments

Comments

@slizovskiy
Copy link

This seems to work MUCH slower than the ordinary "Save" button in Mathematica 11. I do not know, why. Probably, some other saving command should be used in the script.
Thanks,
Sergey

@joshburkart
Copy link
Owner

Bummer! Sadly this was written in a much older version of Mathematica (7?) and hasn't been updated... If you can figure out an improvement please send a PR!

@slizovskiy
Copy link
Author

slizovskiy commented Jan 4, 2017 via email

@joshburkart
Copy link
Owner

Ah, actually, I remember noticing the speed difference too. Yep I'm not sure how to work around this either, other than by using smaller notebooks... Sorry!

@Masterxilo
Copy link

I have experienced this too. It is prominent in notebooks with lots of large images. This makes the FrontEnd hang for quite some time after evaluations when the timeout for the auto-save has been reached again.

Is there really no way to fix this? Why should we not use NotebookSave?

@Masterxilo
Copy link

Masterxilo commented Mar 3, 2017

I applied the following changes:

BackupName[file_String, num_Integer] :=
	file <> StringJoin @@ Table["~", {num}] <> ".nb";

Monitor[

NotebookSave[EvaluationNotebook[], Print@bakfile;bakfile];
(*Print@renameFile[bakfile<>".nb",bakfile];(*HACKFIX for NotebookSave adding .nb to .nb~*)*)

NotebookSave[EvaluationNotebook[], nbfile];(*HACKFIX for restoring the actual name instead of changing it*)
(*Export[bakfile, EvaluationNotebook[], "NB"]*)

,
				"Backing up " <> FileNameTake[nbfile] <> " to " <> FileNameTake[bakfile] <> "..."];

I had some trouble with RenameFile failing and NotebookSave adding .nb, but this works and seems much faster. This seems to do what I want.


Someone should report to WRI the NotebookSave <-> Export performance discrepancy.

@joshburkart
Copy link
Owner

@Masterxilo Thanks for looking into this! My recollection was that using NotebookSave actually changes the location that Mathematica thinks the notebook is located, so that the next time the user clicks File -> Save it updates the backup rather than the original save location. Maybe I'm wrong though?

I believe the issue is that Export doesn't support incremental updates, and always resaves the whole thing, whereas NotebookSave only saves the new stuff. Again could be wrong.

If your solution works with no deleterious side effects then please consider sending a PR!

@joshburkart
Copy link
Owner

Oh sorry, I see now that you got around this. Well in that case looks good to me! The slowness of using Export was always annoying to me too. PR?

@Masterxilo
Copy link

Masterxilo commented Mar 3, 2017

Sure!

I would prefer to get .nb~ and .nb~~ files though.

With my fix I get .nb~.nb and .nb~~.nb files which mix with the normal notebooks. I find that not too pretty.

@joshburkart
Copy link
Owner

Ahh, yeah. Also, does this mean every time there's a backup, the notebook also gets saved? To its normal save path?

@Masterxilo
Copy link

Yes. This might be problematic if the notebook becomes corrupted (making the original and the backup unusable on the next backup).

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

3 participants