From: qwx@sciops.net
To: 9front@9front.org
Subject: [9front] page(1) performance fixes
Date: Thu, 13 Jan 2022 02:54:35 +0100 [thread overview]
Message-ID: <A218DB0D8F09073C4200BE52D1BC28A4@wopr.sciops.net> (raw)
Hello,
The following patch attempts to improve page(1) performance, a huge
annoyance of mine, especially when files are themselves slow to load.
My benchmark is a t61p where these issues are extremely noticeable.
- fix showpage1 only decrementing proc counter once limit is reached;
this blocked having more than one loadpages process after NPROC calls,
since the next one has to wait until the last has exited, which is why
page(1) always hangs around after every few pages (if memory limit is
large enough anyway, but even with the default)
- allow procs to skip pages currently being loaded by others; this
forced processes to wait for each other when reaching the same page,
which happens all of the time
- (hack) immediately fork NPROC times after adding all pages at
startup to force loading a batch of pages in parallel
Thoughts? If it's all good, I'd like to commit this.
Thanks,
qwx
diff 6e64d30454f71ecda88dba1bd792e97509115d73 uncommitted
--- a//sys/src/cmd/page.c
+++ b//sys/src/cmd/page.c
@@ -951,7 +951,8 @@
loadpages(Page *p, int oviewgen)
{
while(p != nil && viewgen == oviewgen){
- qlock(p);
+ if(!canqlock(p))
+ goto next;
loadpage(p);
if(viewgen != oviewgen){
unloadpage(p);
@@ -974,6 +975,7 @@
qunlock(p);
if(p != current && imemsize >= imemlimit)
break; /* only one page ahead once we reach the limit */
+ next:
if(forward < 0){
if(p->up == nil || p->up->down == p)
break;
@@ -1309,16 +1311,17 @@
writeaddr(p, "/dev/label");
current = p;
oviewgen = viewgen;
+ if(nproc >= NPROC)
+ waitpid();
switch(rfork(RFPROC|RFMEM)){
case -1:
sysfatal("rfork: %r");
case 0:
loadpages(p, oviewgen);
+ nproc--;
exits(nil);
}
- if(++nproc >= NPROC)
- if(waitpid() > 0)
- nproc--;
+ nproc++;
}
/* recursive display lock, called from main proc only */
@@ -1691,6 +1694,8 @@
addpage(root, "stdin", popenfile, strdup("/fd/0"), -1);
for(; *argv; argv++)
addpage(root, *argv, popenfile, strdup(*argv), -1);
+ for(i=0; i<NPROC; i++) /* rice */
+ showpage(current);
drawlock(1);
for(;;){
next reply other threads:[~2022-01-13 2:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 1:54 qwx [this message]
2022-01-14 11:30 ` cinap_lenrek
2022-01-14 17:48 ` qwx
2022-01-14 17:54 ` qwx
2022-01-18 1:18 ` qwx
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A218DB0D8F09073C4200BE52D1BC28A4@wopr.sciops.net \
--to=qwx@sciops.net \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).