[pmwiki-users] Revisiting CondAuth slow page loading with attr set
Petko Yotov
5ko at 5ko.fr
Sun Apr 27 06:17:04 PDT 2025
This was a thread from last year (see below), I just got the peace and
chance to do a careful code review and update.
The problem was that every "if auth" conditional would read the page
file from disk in order to calculate and return the correct permissions.
A partial fix last year was to cache internally the permissions per page
and per level; this didn't reopen the disk file for a page if the same
level say "edit" was checked again. But it did reopen the disk file if
another level like "upload" was checked subsequently for the same page.
The prerelease should now only open the disk file once and return all
permissions for a page, and the conditional should cache these for
subsequent queries.
So all these now require opening only one disk file :
(:if auth read:)read
(:if auth edit:)edit
(:if auth publish:)publish
(:if auth upload:)upload
(:if auth attr:)attr
(:if auth admin:)admin
(:ifend:)
I have committed this to Subversion: it would be great if you could test
it in existing configurations of Site, Group and Page passwords - not
for the speed, but for the correctness, to make sure I didn't
inadvertently break something.
You can get the prerelease either from Subversion or from ChangeLog:
https://www.pmwiki.org/wiki/PmWiki/ChangeLog
https://www.pmwiki.org/wiki/PmWiki/Subversion
I plan to release 2.4.5 in 3 weeks.
Petko
On 14/04/2024 14:42, Petko Yotov wrote:
> On 14/04/2024 13:41, Hans Bracker wrote:
>> see this
>> post this
>> edit this
>> admin this
>> upload this
> ...
>> You can see the five extra calls to ReadPage in case 2 and 3,
>
> Do you have 5 different levels (read, post, edit, admin, upload)? If
> so, it is normal that the page file is opened 5 times.
>
> Permissions are cached per page and per level, or per "page+level". So
> you had "page+read", "page+post", etc. each calling RetrieveAuthPage,
> then cached.
>
> If you had 5 times (:if auth edit:), it would cache the "edit" level
> perms for the current page the first time, and for the next ifs it
> would return the cached perms and not reopen the page.
>
> Before the latest revision, 5 times (:if auth edit:) would open the
> page file 5 times, one for each "if" and verifies the password, if
> any. Now it opens and verifies the first time only.
>
>> and case 2 is a lot faster, as fast as without conditionals!
>
> It seems your operating system is caching recently opened files, like
> mine. Which suggests, as I suspected, that most of the time is spent
> verifying a password.
>
> RetrieveAuthPage is complex to change, as it may return a page with
> full history or partial history, or only the latest text and metadata.
> The conditional markup, and many recipes, don't need this, they only
> need to check the permissions.
>
> Maybe we can add a new function optimized for checking permissions
> only, that will return neither the page text nor the history, but will
> cache the page attributes so that they could be re-checked for
> different levels without reopening the page. But if the password
> verification takes most of the time, the improvements may not be
> noticeable.
>
> Petko
More information about the pmwiki-users
mailing list