SlickEdit Community

Archived Read Only Forums => SlickEdit 2017 v22 Beta Discussion => Topic started by: jporkkahtc on September 20, 2017, 06:19:19 pm

Title: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 06:19:19 pm
I created a plain text file,
size=218,264,095 bytes.
#lines=7,385,617

Saving in Beta3 takes 40 seconds!
Saving the same file in V21: Less than 1 second.

Happens even if I turn off backup history.
Happens with UTF-8 and DBCS encoding. (The data is plain ascii text).
Happens every time I save the file, or SaveAs to a different name.

From an external program I can see the size of the file being saved slowly growing from 0 to 218mb.

I don't see any significant difference in options between v21 and v22 - same FileOtions and  ApplicationOptions.


Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 06:30:40 pm
Looking with PROCMON, saving the file (with dbcs encoding).
Slick writes about 32kb at a time ... but not 32,768 bytes -- seemingly random lengths just under 32,768 bytes each time.

It oughta write 32,768 bytes each time, and keep it aligned.

Also, at the start of the save it appears to truncate the file to 0 bytes - OK, but before writing that much it would help to set the file length to the desired size for best disk space allocation.

V21 writes the same file 8,192 bytes at a time - aligned with DBCS, but offset with utf8 by 3 bytes - but either way it is fast.

This is writing to an SSD.
Title: Re: Saving a large file is *really* slow
Post by: Dan on September 20, 2017, 06:52:45 pm
Just to be REALLY sure, while the file is open run "save +o" on the SlickEdit command line.
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 07:01:12 pm
Same result.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 20, 2017, 07:29:43 pm
I've read through this quickly. Have you tried a default config?

I just tried saving foo3 and on my machine with a clean config, the save is a fraction of a second.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 20, 2017, 07:47:15 pm
Note: SlickEdit was on plain text mode for foo3
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 07:59:51 pm
OK, clean configuration doesn't repro --- in this case Slick is doing 8KB IOs.

I tried importing all options except appearance, keyboard, debugging, languages.
It still did not repro.

I then imported all options, and now it does repro.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 20, 2017, 08:04:06 pm
My best guess is a save option
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 08:08:11 pm
Which?
Short of importing all settings, it doesn't repro.

I tried:
Repro: Importing all
Not repro: Importing all except appearance, keyboard, debugging, languages
Not repro: Importing only appearance, keyboard, debugging, languages


Title: Re: Saving a large file is *really* slow
Post by: Clark on September 20, 2017, 08:09:54 pm
Are you changing the line endings on save?  If so, it will have to write a spill file which takes a long time. You can increase the buffer cache size (default is 2 megabytes) to speed this up.
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 08:13:37 pm
Nope.

PROCMON shows the only IO is Slick writing just slightly less than 32KB at a time.

From a clean config it actually alternates reading the original file and writing at 8kb at a time -- much faster somehow.

In my config
Buffer cache size (MB)"=8000 (default=2)
Load partially when files are larger than=10,001 (default is 8,000)
Wrap line length=8,000 (default is 4,000)
Maximum size to backup=75,000(default 20,000)

THese are the only difference from default config which looked relevant to me, yet setting these isn't enough to make it repro.
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 08:17:36 pm
I uploaded my options export to support/porkka_slow_save.
Title: Re: Saving a large file is *really* slow
Post by: Dan on September 20, 2017, 08:22:13 pm
I haven't looked at the options you exported, but strip trailing spaces would be a killer on a large file too.
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 08:40:49 pm
nope, i don't have that set.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 20, 2017, 09:01:20 pm
You are translating the line endings to Unix EOL on save (see language specific save options). The save code could be optimized but hasn't been yet (i.e only change the data when the eol characters actually change). I don't know if this is easy, hard, or too hard to be worth doing.
Title: Re: Saving a large file is *really* slow
Post by: jporkkahtc on September 20, 2017, 09:18:18 pm
Ah.... So this changed when I was trying to figure out encoding and line endings (see other posts about this).
Confirmed: Changed to "automatic" and the problem goes away.
SaveAs->LF (even though the file is already LF) is also slow - presumably this is the same code path.


I wanted to get so all newly created files are utf-8 and LF endings.

So, what does "AUTOMATIC" do here?
The Help text in Options shows:
    Specifies how end of line characters are translated when a file is saved. Automatically attempts to determine the context.

I have no idea what that means ... what context?
Windows vs Linux?

Title: Re: Saving a large file is *really* slow
Post by: Clark on September 21, 2017, 02:26:50 am
For existing files,EOL characters are determined from first line of file. Otherwise, use OS default line endings. Also, save won't translate lines with mixed line endings unless a specific line ending format is specified. When all save translations are off. Save is fastest. When there are save translations what modify the original file, a lot of data that must be spilled may be generated in addition to the file contents being written to disk.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 21, 2017, 02:29:23 am
Looks like there is a bug in the optimization code. The save code was trying to optimize this particular case but it was goofed so it thinks every line is being modified when saving an LF file where the original file already just has LF line endings. The CR LF case is optimized correctly.
Title: Re: Saving a large file is *really* slow
Post by: Clark on September 21, 2017, 02:42:50 am
This optimization has been fixed in the next build