Excessive processing time

Previous topic - Next topic

Alcantara

Hello.

I am writing a Python script for Scribus. The script prepares an annual astronomical calendar, and the document is normally 107 pages long. Apart from the first page, which serves as the cover, all the other pages are identical, except that the left-hand page has three days while the right-hand page has four days.

The problem is the document processing time.

Since the processing time is excessive, in order to find the bottleneck, I wrote a small logger that reports the time taken to process each page in a file.

This is the content of the report for the first 20 pages.

--- Log Session Start: 2026-02-08 17:02:25 ---

[2026-02-08 17:02:25] (+0:00:00.000240)
start

[2026-02-08 17:02:25] (+0:00:00.232512)
starting page 1

[2026-02-08 17:02:28] (+0:00:03.000688)
starting page 2

[2026-02-08 17:02:38] (+0:00:09.916929)
starting page 3

[2026-02-08 17:02:50] (+0:00:11.915591)
starting page 4

[2026-02-08 17:03:10] (+0:00:19.837202)
starting page 5

[2026-02-08 17:03:32] (+0:00:22.023284)
starting page 6

[2026-02-08 17:04:04] (+0:00:31.714290)
starting page 7

[2026-02-08 17:04:38] (+0:00:34.625371)
starting page 8

[2026-02-08 17:05:27] (+0:00:48.587275)
starting page 9

[2026-02-08 17:06:12] (+0:00:45.257146)
starting page 10

[2026-02-08 17:07:13] (+0:01:00.909167)
starting page 11

[2026-02-08 17:08:09] (+0:00:55.905012)
starting page 12

[2026-02-08 17:09:23] (+0:01:13.615812)
starting page 13

[2026-02-08 17:10:25] (+0:01:02.406089)
starting page 14

[2026-02-08 17:11:40] (+0:01:14.887103)
starting page 15

[2026-02-08 17:12:56] (+0:01:16.068229)
starting page 16

[2026-02-08 17:14:32] (+0:01:35.853824)
starting page 17

[2026-02-08 17:15:50] (+0:01:17.926507)
starting page 18

[2026-02-08 17:17:29] (+0:01:38.905634)
starting page 19

[2026-02-08 17:18:56] (+0:01:27.307346)
starting page 20

[2026-02-08 17:20:43] (+0:01:47.524493)
END


The time of the event is shown in square brackets, and the time elapsed since the previous event is shown in round brackets.

As you can see, it takes Scribus a few seconds to prepare the first pages (which, I repeat, are all the same), but the time increases for each page until it reaches the twentieth, which takes 1 minute and 47 seconds.

The snakeviz report does not reveal anything remarkable; all functions take up processing time in a more or less uniform manner.

In your experience, is this behavior normal? Could it be a problem with Scribus or Python? Do you have any ideas for solving the problem?

a.l.e

Are you linking / chaining the text frames?

Scribus gets very slow when creating long chains...

If you're not doing that, would you mind publishing a minimal script that reproduces the issue?

Alcantara

#2
Hello.

I have done a thorough rewrite of the code and managed to reduce the number of text frames on each page by almost 50%. In addition, each line and each text frame is styled as recommended in the wiki.

The script is now significantly faster, but still not fast enough.

Each page is composed of about 40 lines and about 40 text frames. From the logger, I see that not only does the time taken to process each page continue to increase steadily (albeit at a much slower rate than before), but the processing of each new page takes up about 2 megabytes of additional memory.

--- Log Session Start: 2026-02-09 16:11:47 ---

[2026-02-09 16:11:47] (+0:00:00.000419)
start

[2026-02-09 16:11:48] (+0:00:00.241822)
starting page 1

Memory used by the script: 251.78 MB

[2026-02-09 16:11:49] (+0:00:01.273202)
starting page 2

Memory used by the script: 253.73 MB

[2026-02-09 16:11:52] (+0:00:03.150408)
starting page 3

Memory used by the script: 255.84 MB

[2026-02-09 16:11:56] (+0:00:04.509947)
starting page 4

Memory used by the script: 257.58 MB

[2026-02-09 16:12:03] (+0:00:06.815275)
starting page 5

Memory used by the script: 259.71 MB

[2026-02-09 16:12:11] (+0:00:07.666422)
starting page 6

Memory used by the script: 261.43 MB

[2026-02-09 16:12:22] (+0:00:10.874998)
starting page 7

Memory used by the script: 263.51 MB

[2026-02-09 16:12:33] (+0:00:11.249659)
starting page 8

Memory used by the script: 265.19 MB

[2026-02-09 16:12:47] (+0:00:13.747667)
starting page 9

Memory used by the script: 267.40 MB

[2026-02-09 16:13:01] (+0:00:14.593259)
starting page 10

Memory used by the script: 269.10 MB

[2026-02-09 16:13:22] (+0:00:20.415355)
starting page 11

Memory used by the script: 271.16 MB

[2026-02-09 16:13:42] (+0:00:19.983406)
starting page 12

Memory used by the script: 272.87 MB

[2026-02-09 16:14:04] (+0:00:22.390132)
starting page 13

Memory used by the script: 274.93 MB

[2026-02-09 16:14:25] (+0:00:20.755356)
starting page 14

Memory used by the script: 276.66 MB

[2026-02-09 16:14:50] (+0:00:24.819259)
starting page 15

Memory used by the script: 278.74 MB

[2026-02-09 16:15:14] (+0:00:24.413419)
END

Memory used by the script: 280.68 MB

Is there a technique for freeing up the memory used after processing each page, so that Scribus processes each new page as if it were the first?





Quote from: a.l.e on February 08, 2026, 06:20:43 PMAre you linking / chaining the text frames?

No. Just simple text frames not linked.

Quote from: a.l.e on February 08, 2026, 06:20:43 PMIf you're not doing that, would you mind publishing a minimal script that reproduces the issue?

I'm working on a rather complex script that spans several Python files. I don't think it's appropriate to publish everything here.

As soon as I've put everything on a GitHub repository, I'll post the address here.

For now, I'll put the logger report here.

The details are as I've already said: forty lines per page, forty text frames per page; 107 pages in A5 format. Practically nothing else.