4

Sometimes I do not use some programs with high memory usage (e.g. virtual machine with 2 GB of memory) for several days. When I return to it, its memory is mostly swapped onto HDD. When I try to work with this program later it is loaded back very slowly. For example its physical memory usage raises from 600 MB to 1100 MB with the speed of 250 KB/s and only after that it becomes rather responsive. So the slowdown is because data are read non-sequentially.

Is it possible to load program's memory in one sequential HDD read pass? Because this has to take only half a minute.

This is a working machine, OS Windows 7 x64, RAM size is 8 GB.

4
  • I know it doesn't directly answer the question, but wouldn't using an SSD fix the slow transfer rate?
    – user201262
    Sep 27, 2013 at 13:35
  • Theoretically yes, but I doubt I can push a additional SSD into my notebook. There is also a variant with SD card, but I think it will be slow
    – Mikhail M
    Sep 27, 2013 at 14:17
  • Oh, you didn't say it was a notebook. You could clone & replace your HDD, though.
    – user201262
    Sep 27, 2013 at 14:22
  • I don't want to overpay for 400-GB SSD, 128 GB is nothing for me
    – Mikhail M
    Sep 27, 2013 at 14:36

2 Answers 2

1

You should make your pagefile have a static size, so it does not fragment and eases hard drive reading.

An example of static size pagefile is shown below.

enter image description here

0

You can't directly change the way memory is swapped to the disk because it swaps out pages not programs. You can make things go faster by:

  1. Doing it UNIX way. Create small partition to hold your swap at the beginning of the disk.
  2. Restrict size changes to swap file.
  3. Install a decent defragmenting app.

Noone can also interfere with swapping. To mess with the swap you need to have maximum privileges because swap can possibly contain any vital data like keys or passwords. And even if you have access to the swap you can read it by yourself but this wouldn't give you any boost because swap is exempt from caching thus reading any pages just loads your drive without speeding up anything.

There are other solutions like avoiding using swap by Process/Application Checkpointing. Linux and BSD can do this. Some systems can do this naturally like DragonflyBSD due to their memory management and runtime object linking possibilities. However I doubt about possibility to do so on Windows, you can look for a threads like this (skip the junk about signals, they doesn't do anything about checkpoints).

6
  • IMHO, your and @Lorenzo Von Matterhorn's answers can only help a bit - to reduce pagefile fragmentation but to remain with random pages request order. What I'm thinking about is maybe a program that access all pages owned by the swapped process sequentially
    – Mikhail M
    Sep 27, 2013 at 11:16
  • Update: hybrid SSHD (HDD + 8 GB flash) helped a lot, but not principially. Typical rates of getting data back from swap I see now - 500-1000 KB/s instead of 250 KB/s
    – Mikhail M
    Mar 15, 2017 at 23:44
  • The bad things about swap is still fragmentation and small block size. Both increase number of i/o ops to read 1MB of data. You can try formatting your drive with 64k NTFS block size, this way each transfer would be at least 64k so you will partially remove fragmentation/small block access problem.
    – kworr
    Mar 16, 2017 at 19:56
  • interesting idea, although I don't believe in it... Do you think Windows looks much at file system when it works with virtual memory? Imagine you opened a file in C, you can read any fragment of it... I suppose it was the common solution, "we will implement 4-K pages in CPUs and OS" made based on effectiveness. But sometimes it's not best or it would be very desirable to have say 1-MB pages area. And HDD most likely also buffers touched areas, e.g. 64-KB blocks...
    – Mikhail M
    Mar 17, 2017 at 7:15
  • Well, Windows doesn't look at FS when working with swap but when writing 1MB chunk to swap there's no guarantee that they will not end up split up to blocks on FS level. And HDD cache exists only for storing extra encountered blocks when reading each cylinder. HDD rotates backwards so when you order it to read sector 13 it will first switch heads to that sector then start reading all sectors down until requested sector would appear. This way HDD cache will hold some subsequent sectors from that cylinder depending on when heads entered the cylinder. So HDD cache works like a prefetch buffer.
    – kworr
    Mar 23, 2017 at 21:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .