Archive script doesn't complete

I have a new Piwik installation and I’m trying to import log files for the last year.
I’m able to import the log files (using import_logs.py), but when I run the archive script it always gets stuck at the same place.

See:

Here’s the archive command:
“C:\Program Files\PHP\v7.1\php.exe” “C:\websites\piwik\web\console” core:archive --force-all-websites --force-all-periods=315576000 --force-date-last-n=1000 --url=https://mypiwiksite

I’m running Piwik 3.1.1 on Windows Server 2012 R2.

Any ideas what might be causing this?

UPDATE:

I tried importing the logs in smaller batches of about 3 to 5 days at a time and then archiving after each import. That seemed to work, although the first archive took about 10 minutes, which seems like a long time for files that are pretty small (about 600K for each day with a couple thousand log lines in each). The subsequent archives went a bit faster (2 minutes or so).

I then tried importing and archiving a file containing one entire month (about 87,000 log lines) and now the archive script seems to be stuck again. I’ve let it run now for about 4 hours and it still says “pre-processing all visits” like the screenshot above.