9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bakul Shah <bakul+plan9@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
Date: Mon, 17 Jan 2011 12:30:31 -0800	[thread overview]
Message-ID: <20110117203032.9C8455B04@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Mon, 17 Jan 2011 21:59:58 +0200." <AANLkTi=cW9gpquskLvYszs6Od-WnS9iJEiJ1_wMo2ufR@mail.gmail.com>

On Mon, 17 Jan 2011 21:59:58 +0200 Ciprian Dorin Craciun <ciprian.craciun@gmail.com>  wrote:
>     Actually I'm using the `mk` from
> `http://swtch.com/plan9port/unix/mk-with-libs.tgz` which I'm assuming
> is an extract of the `plan9port` sources. As such in order to build it
> I had to resort to updating the Makefile, but I didit.

Look at the top 4 items:

  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 28.11      2.24     2.24        1     2.24     2.24  clrmade
 22.96      4.07     1.83        1     1.83     1.83  attribute
 22.33      5.85     1.78        1     1.78     1.78  ambiguous.clone.2
 20.45      7.48     1.63        1     1.63     1.63  cyclechk

Next look at the call graphs to see that these functions are
called 59+ million times! Significantly more times than
anything else.  These are all in src/cmd/mk/graph.c -- mk is
using simple algorithm with much worse time complexity than
is theoretically possible.

I haven't studied make algorithms much to know if one can
just compute transitive closure of the dependency matrix
upfront as that would definitely be much faster than walking
so many linked lists so many times. cycle check is then just
walking down the diagonal of TC(dependency-matrix) to find
self-dependencies. A dependency matrix is usually very sparse
so one can do better than Warshall's Algorithm with its
O(N^3) time complexity.

Not sure how any of this helps you though.... You are better
off using gnumake for maximum portability, however detestable
it might be. You have to learn just enough of it to get by.



  reply	other threads:[~2011-01-17 20:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 14:47 Ciprian Dorin Craciun
2011-01-17 14:59 ` erik quanstrom
2011-01-17 15:05   ` Ciprian Dorin Craciun
2011-01-17 16:50     ` Bakul Shah
2011-01-17 16:56       ` erik quanstrom
2011-01-17 18:36         ` Bakul Shah
2011-01-17 19:33           ` Ciprian Dorin Craciun
2011-01-17 19:59           ` Ciprian Dorin Craciun
2011-01-17 20:30             ` Bakul Shah [this message]
2011-01-17 15:00 ` Robert Raschke
2011-01-17 15:02   ` Robert Raschke
2011-01-17 15:18     ` erik quanstrom
2011-01-17 15:33   ` Ciprian Dorin Craciun
2011-01-17 15:51     ` Federico G. Benavento
2011-01-17 15:53     ` Robert Raschke
2011-01-17 16:02       ` andrey mirtchovski
2011-01-17 16:45         ` Ciprian Dorin Craciun
2011-01-17 17:31       ` Ciprian Dorin Craciun
2011-01-17 17:46         ` Federico G. Benavento
2011-01-17 17:51           ` Federico G. Benavento
2011-01-18  6:09         ` Andy Spencer
2011-01-18 13:26           ` erik quanstrom
2011-01-17 15:21 ` Ciprian Dorin Craciun

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=20110117203032.9C8455B04@mail.bitblocks.com \
    --to=bakul+plan9@bitblocks.com \
    --cc=9fans@9fans.net \
    /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).