Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
`mk` (from Plan9 ports) efficiency related issue
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  21 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
erik quanstrom  
View profile  
 More options Jan 17 2011, 10:00 am
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 17 Jan 2011 15:00:50 GMT
Local: Mon, Jan 17 2011 10:00 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

>     Any ideas what could cause this?

have you tried profiling mk?

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Raschke  
View profile  
 More options Jan 17 2011, 10:01 am
Newsgroups: comp.os.plan9
From: rtrli...@googlemail.com (Robert Raschke)
Date: Mon, 17 Jan 2011 15:01:57 GMT
Local: Mon, Jan 17 2011 10:01 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

Terribly sorry, my email won't help you much, apart from going "Wow, a 4000
link mk file!" and "Hmm, I wouldn't start from here if you want to go
there." Your email also doesn't explain why you cannot generate a "normal"
mk file.

If you want to stick with your approach, it almost looks like you may be
better off to generate a shell script that explicitly checks and runs
everything you need. (And yes, essentially make your "generator" be a make
in it's own right. Another one won't hurt.)

But it's cool to see someone else who uses Erlang and RabbitMQ hanging out
on this list. :-)

Robby

On Mon, Jan 17, 2011 at 2:47 PM, Ciprian Dorin Craciun <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Raschke  
View profile  
 More options Jan 17 2011, 10:04 am
Newsgroups: comp.os.plan9
From: rtrli...@googlemail.com (Robert Raschke)
Date: Mon, 17 Jan 2011 15:04:19 GMT
Local: Mon, Jan 17 2011 10:04 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

Err, "Wow, a 4000 line mk file!"

On Mon, Jan 17, 2011 at 3:00 PM, Robert Raschke <rtrli...@googlemail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 10:06 am
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 15:06:58 GMT
Local: Mon, Jan 17 2011 10:06 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

On Mon, Jan 17, 2011 at 16:59, erik quanstrom <quans...@quanstro.net> wrote:
>>     Any ideas what could cause this?

> have you tried profiling mk?

> - erik

    In fact I tried to `strace -f -T` it and it seems that in the
first second or so it `stats` all the files that exist, and then it
just waits 14 seconds computing something (100% processor), and
concludes that all is already built. (This is after I've already
successfully built it once).

    But any further profiling I didn't do as I've stumbled upon this
issue just about an hour ago...

    Ciprian.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Jan 17 2011, 10:21 am
Newsgroups: comp.os.plan9
From: quans...@labs.coraid.com (erik quanstrom)
Date: Mon, 17 Jan 2011 15:21:16 GMT
Local: Mon, Jan 17 2011 10:21 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

> Err, "Wow, a 4000 line mk file!"

machine making machnes—oh, my
        - c3po

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 10:23 am
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 15:23:10 GMT
Local: Mon, Jan 17 2011 10:23 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
On Mon, Jan 17, 2011 at 16:47, Ciprian Dorin Craciun

    P.S.: A complete build from nothing takes about 16 minutes...

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 10:35 am
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 15:35:43 GMT
Local: Mon, Jan 17 2011 10:35 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

On Mon, Jan 17, 2011 at 17:00, Robert Raschke <rtrli...@googlemail.com> wrote:
> Terribly sorry, my email won't help you much, apart from going "Wow, a 4000
> link mk file!" and "Hmm, I wouldn't start from here if you want to go
> there."

    No problem. Any feedback is welcomed, as I try to understand what
I'm not doing properly.

> Your email also doesn't explain why you cannot generate a "normal"
> mk file.

    I'm afraid I don't understand the question. What do you mean by
"generating a normal mk file"?
    A) Do you mean why am I using a generator that writes the `mk`
script instead of writing the `mk` script myself by hand? The answer
to this is complexity: writing `mk` is Ok when you have a simple
application to build, but as the application grows larger so does the
make script. (And using meta rules is not always possible.)
    B) Why isn't the output script a "normal" `mk` script? Actually is
a very simple script (no meta-rules, no shell expansion, etc.). It's
just big. :)

> If you want to stick with your approach, it almost looks like you may be
> better off to generate a shell script that explicitly checks and runs
> everything you need. (And yes, essentially make your "generator" be a make
> in it's own right. Another one won't hurt.)

    I favored the idea of using another make tool because of
portability and simplicity. The target is that I only need to generate
the make script once and distribute it with the source code, thus it
could be built with an already existing make tool (currently only `mk`
from Plan9 is supported, but I plan to also add GNU/BSD make support.)

    The idea of generating shell scripts doesn't seem so tempting, as
I know that scripting -- at least in Bash -- is not very reliable or
easy...

    (BTW I've chosen `mk` over `make` because it's rules (syntax and
semantic) seems much simpler and saner than the ones with GNU make...
(A lot of automagic happens in that realm...) But if I'm not able to
fix this I'll have to resort back to make...) :(

> But it's cool to see someone else who uses Erlang and RabbitMQ hanging out
> on this list. :-)

> Robby

    Glad to see another erlanger. :)

    Ciprian.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Federico G. Benavento  
View profile  
 More options Jan 17 2011, 10:53 am
Newsgroups: comp.os.plan9
From: benave...@gmail.com (Federico G. Benavento)
Date: Mon, 17 Jan 2011 15:53:47 GMT
Local: Mon, Jan 17 2011 10:53 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

>> Your email also doesn't explain why you cannot generate a "normal"
>> mk file.

>    I'm afraid I don't understand the question. What do you mean by
> "generating a normal mk file"?
>    A) Do you mean why am I using a generator that writes the `mk`
> script instead of writing the `mk` script myself by hand? The answer
> to this is complexity: writing `mk` is Ok when you have a simple
> application to build, but as the application grows larger so does the
> make script. (And using meta rules is not always possible.)
>    B) Why isn't the output script a "normal" `mk` script? Actually is
> a very simple script (no meta-rules, no shell expansion, etc.). It's
> just big. :)

a normal mkfile does have meta-rules and if you have so many targets
wouldn't it make sense to have more mkfiles?

--
Federico G. Benavento


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Raschke  
View profile  
 More options Jan 17 2011, 10:55 am
Newsgroups: comp.os.plan9
From: rtrli...@googlemail.com (Robert Raschke)
Date: Mon, 17 Jan 2011 15:55:40 GMT
Local: Mon, Jan 17 2011 10:55 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

On Mon, Jan 17, 2011 at 3:33 PM, Ciprian Dorin Craciun <

Sorry, I meant an idiomatic mk file, in the sense as they are used within
the Plan 9 distribution. Have a look at "Plan 9 Mkfiles" (
http://www.cs.bell-labs.com/sys/doc/mkfiles.html) and "Maintaining Files on
Plan 9 with Mk" (http://www.cs.bell-labs.com/sys/doc/mk.html), if you
haven't already done so.

I think by listing all your dependencies one by one, step by step, you are
bypassing a lot of the strengths of a make system. I would expect your
generator to produce a mk include file with the meta rules plus the mk file
itself which lists file dependencies in a concise manner.

Robby


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andrey mirtchovski  
View profile  
 More options Jan 17 2011, 11:04 am
Newsgroups: comp.os.plan9
From: mirtchov...@gmail.com (andrey mirtchovski)
Date: Mon, 17 Jan 2011 16:04:17 GMT
Local: Mon, Jan 17 2011 11:04 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
something else to try if you're on a multiprocessor system: set $NPROC
to a value > 1 and see how this affects the runtime in the 14-second
case. your dependency tree may be very deep, but parallelizable.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 11:47 am
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 16:47:16 GMT
Local: Mon, Jan 17 2011 11:47 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

On Mon, Jan 17, 2011 at 18:02, andrey mirtchovski <mirtchov...@gmail.com> wrote:
> something else to try if you're on a multiprocessor system: set $NPROC
> to a value > 1 and see how this affects the runtime in the 14-second
> case. your dependency tree may be very deep, but parallelizable.

    I've tried that, either NPROC=1 or NPROC=8 doesn't affect the
behaviour. (I'm on a Core2 Duo processor.)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Jan 17 2011, 11:51 am
Newsgroups: comp.os.plan9
From: bakul+pl...@bitblocks.com (Bakul Shah)
Date: Mon, 17 Jan 2011 16:51:58 GMT
Local: Mon, Jan 17 2011 11:51 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
On Mon, 17 Jan 2011 17:05:27 +0200 Ciprian Dorin Craciun <ciprian.crac...@gmail.com>  wrote:

> On Mon, Jan 17, 2011 at 16:59, erik quanstrom <quans...@quanstro.net> wrote=
> :
> >> Any ideas what could cause this?

> > have you tried profiling mk?

> > - erik

>     In fact I tried to `strace -f -T` it and it seems that in the
> first second or so it `stats` all the files that exist, and then it
> just waits 14 seconds computing something (100% processor), and
> concludes that all is already built. (This is after I've already
> successfully built it once).

strace tells you what system calls were made and when.  To
find out which functions use most time, compile with -pg and
look at the gprof output once done.  That 14 seconds were
probably spent computing dependencies.  You can convert your
test.mk to a Makefile with a trivial sed script. See what
bsdmake or gmake does with it time wise. {bsd,g}make have
been been abused with huge Makefiles for far longer and are
likely to be friendlier to them :-)

But the real issue is that mk has to check all the long
dependency chains your generator creates and it is probably
not tuned for such large mkfiles as typically one factors out
build logic in a set of mkfiles and uses meta rules where
appropriate.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Jan 17 2011, 11:58 am
Newsgroups: comp.os.plan9
From: quans...@labs.coraid.com (erik quanstrom)
Date: Mon, 17 Jan 2011 16:58:11 GMT
Local: Mon, Jan 17 2011 11:58 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

> strace tells you what system calls were made and when.  To
> find out which functions use most time, compile with -pg and
> look at the gprof output once done.  That 14 seconds were
> probably spent computing dependencies.  You can convert your
> test.mk to a Makefile with a trivial sed script. See what
> bsdmake or gmake does with it time wise. {bsd,g}make have
> been been abused with huge Makefiles for far longer and are
> likely to be friendlier to them :-)

why not just use prof, which is exactly the tool for the job?

i don't see how comparing with *make would get one closer
to solving the mystery.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 12:33 pm
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 17:33:22 GMT
Local: Mon, Jan 17 2011 12:33 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

On Mon, Jan 17, 2011 at 17:51, Federico G. Benavento

<benave...@gmail.com> wrote:

> a normal mkfile does have meta-rules and if you have so many targets
> wouldn't it make sense to have more mkfiles?

> --
> Federico G. Benavento

    I'll respond to both Robert and Federico in the same email, as
their observations an suggestions are on the same topic.

    So for starters I've read both mentioned papers "Plan9 Mkfiles"
and "Maintaining Files on Plan9 with Mk", and I have the following
observations:
    * the second paper "Maintaining Files on ..." is more a general
guide that describes the semantic and syntax of `mk` files;
    * the first paper "Plan9 Mkfiles" focuses entirely and exclusively
on writing `mk` files for building Plan9 native applications; that is
it describes the general rules on how to write short and simple `mk`
files that take advantage on the existing Plan9 build infrastructure;
    * as a consequence both of them seem to suggest writing small `mk`
scripts that individually build each application or library;
    * unfortunately what they don't deal with is inter-dependencies
between multiple projects or libraries each with it's own `mk` script;
    * thus if looking into the `plan9port` source code, inside the
`src/mkfile` I see the following snippet (and I count about 50 other
similar instances):
~~~~
libs-%:V:
        for i in $LIBDIRS
        do
                (cd $i; echo cd `pwd`';' mk $MKFLAGS $stem; mk $MKFLAGS $stem)
        done
~~~~

    But after reading the paper "Recursive Make Considered Harmful", I
see that this approach poses at least the following problems:
    * when developing and updating a single library, there is no way
in which I can instruct `mk` to rebuild all dependent applications --
unless I know about them and enumerate them one by one; as a
consequence -- unless I know very well the real dependency graph --
`mk` doesn't help me at all and I have to `mk clean all`;
    * second, there is a performance bottleneck as now libraries can't
be built in parallel; (this is fine if a library is quite big, but if
I have libraries with a number of files on par with the number of
processors I have wasted time;)
    * third, it's almost impossible to make a dependency between one
library to another; the dependency is encoded in their order in the
variables like `LIBDIRS`;

    I hope that these observations answer the first question of why
don't I just create a number of separate files one for each project or
library.

    (The cited paper is at http://aegis.sourceforge.net/auug97.pdf .)

    For the second question about why no "meta-rules", the answer is
somehow trickier, thus I'll give a few problems which arise when using
meta-rules:
    * not all files of the same type are built by using the same rule;
(for example for some files I want to enable debugging, for others
not); thus I don't see how a meta-rule would solve this problem;
(unless I create separate `mk` files or I resort to filename tags --
for example I would call `*.debug.c` all C files that I want to be
debugged, and `*.release.c` for those I don't);
    * second, each file has a unique dependency graph -- for example
one `*.c` file might include other headers than another `*.c` file in
the same project; thus when updating a single header I want to be able
to build only those `*.c` files that actually depend on it; (this
observation is less important for C applications, but for other type
of programs -- like Java -- this fine grained dependency tracking
means a lot of saved computing power);
    * third, in my brief experience with make files, meta-rules are
quite hard to get right... furthermore it is impossible to have two
patterns like: `%.%.x`; just imagine I have two types of images:
background and foreground and I want to superimpose them, then I would
like to be able to write `%{foreground}.%{background}.jpg :
%{foreground}.jpg %{background}.jpg ..."; (I know that I can resort
here to "<| generating command" but it seems just plain wrong...)

    Now I hope nobody was offended by my observations regarding the
way `mk` scripts are currently written. I am sure that for the purpose
of building Plan9 applications this way is the best trade-off. But
applying the same techniques to more complex programming languages or
other systems is quite hard... Thus I just wanted to use the good `mk`
tool as a backend for a build script generator that is more intimately
acquainted with what it tries to build. (I want to extend my generator
to Python -- as a replacement for `setup.py` -- and Java -- as a
replacement for all the awful tools that exist in that ecosystem,
especially Ant.)

    Ciprian.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Federico G. Benavento  
View profile  
 More options Jan 17 2011, 12:50 pm
Newsgroups: comp.os.plan9
From: benave...@gmail.com (Federico G. Benavento)
Date: Mon, 17 Jan 2011 17:50:50 GMT
Local: Mon, Jan 17 2011 12:50 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
when you have a clean mkfile, doing mk clean; mk install is faster than all the
dependency checking you'd want to do, specially is the project is a big bloat

take X11 for instance.... how long does it take to build it?

On Mon, Jan 17, 2011 at 2:31 PM, Ciprian Dorin Craciun

--
Federico G. Benavento

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Federico G. Benavento  
View profile  
 More options Jan 17 2011, 1:30 pm
Newsgroups: comp.os.plan9
From: benave...@gmail.com (Federico G. Benavento)
Date: Mon, 17 Jan 2011 18:30:53 GMT
Local: Mon, Jan 17 2011 1:30 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
about debug, release

CONF=debug
DEBUG=`{if(~ $CONF release) echo -DNDEBUG}

CFLAGS=$CFLAGS $DEBUG

if you want debug you run
mk 'CONF=debug'

wouldn't something like that help?

or have 2 files mkdebug and mkrelease
so you include them from the other mkfiles as you see fit

On Mon, Jan 17, 2011 at 2:46 PM, Federico G. Benavento

--
Federico G. Benavento

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Jan 17 2011, 1:37 pm
Newsgroups: comp.os.plan9
From: bakul+pl...@bitblocks.com (Bakul Shah)
Date: Mon, 17 Jan 2011 18:37:20 GMT
Local: Mon, Jan 17 2011 1:37 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
On Mon, 17 Jan 2011 11:56:22 EST erik quanstrom <quans...@labs.coraid.com>  wrote:

> > strace tells you what system calls were made and when.  To
> > find out which functions use most time, compile with -pg and
> > look at the gprof output once done.  That 14 seconds were
> > probably spent computing dependencies.  You can convert your
> > test.mk to a Makefile with a trivial sed script. See what
> > bsdmake or gmake does with it time wise. {bsd,g}make have
> > been been abused with huge Makefiles for far longer and are
> > likely to be friendlier to them :-)

> why not just use prof, which is exactly the tool for the job?

Ciprian specified plan9ports. Recipe for building a profiling
mk on unix:

    cd $PLAN9/src/cmd/mk
    9 mk clean
    CC9="gcc -pg" 9 mk all

Then:

    mk=$PLAN9/src/cmd/mk/o.mk
    cd <source dir>
    9 mk clean
    9 $mk
    gproff $mk > mk.gprof

This will show where time is being spent.

> i don't see how comparing with *make would get one closer
> to solving the mystery.

The comparison would reveal if other makes do better. I
suspect they do and that would solve Ciprian's problem.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciprian Dorin Craciun  
View profile  
 More options Jan 17 2011, 2:35 pm
Newsgroups: comp.os.plan9
From: ciprian.crac...@gmail.com (Ciprian Dorin Craciun)
Date: Mon, 17 Jan 2011 19:35:41 GMT
Local: Mon, Jan 17 2011 2:35 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

    Ok. So I've transformed (with a `sed` script as suggested) the
script from `mk` to GNU `make. The results is as follows:
    * building the entire thing with no parallelism took as in my
experiment -- when I've just obtained the raw commands and runned them
with plain sh -- about 1 minute and 27 seconds seconds;
    * after the build issuing `make` a second time take under one
second (0.2 seconds);

    I'll try now to profile the `mk` tool as suggested.

    Ciprian.

    P.S.: I'm not suggesting that GNU `make` is a better tool, just
that for this particular task it behaves better. (Actually I find it
overly complex and almost incomprehensible in its full
implications...)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Jan 17 2011, 3:31 pm
Newsgroups: comp.os.plan9
From: bakul+pl...@bitblocks.com (Bakul Shah)
Date: Mon, 17 Jan 2011 20:31:57 GMT
Local: Mon, Jan 17 2011 3:31 pm
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
On Mon, 17 Jan 2011 21:59:58 +0200 Ciprian Dorin Craciun <ciprian.crac...@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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy Spencer  
View profile  
 More options Jan 18 2011, 1:11 am
Newsgroups: comp.os.plan9
From: andy753...@gmail.com (Andy Spencer)
Date: Tue, 18 Jan 2011 06:11:13 GMT
Local: Tues, Jan 18 2011 1:11 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
On 2011-01-17 19:31, Ciprian Dorin Craciun wrote:

>     * not all files of the same type are built by using the same rule;
> (for example for some files I want to enable debugging, for others
> not); thus I don't see how a meta-rule would solve this problem;
> (unless I create separate `mk` files or I resort to filename tags --
> for example I would call `*.debug.c` all C files that I want to be

Use a variable:

a_cflags=-g -Da
b_cflags=-g -Db
test: test.o a.o b.o
        gcc -o $target $prereq
%.o: %.c
        gcc $($stem^_cflags) -c -o $target $stem.c

Or only filename-tag the object files:

test: test.o a-debug.o b-opt.o c-prof.o
%.o: %.c
        gcc -c -o $target $prereq
%-opt.o: %.c
        gcc -O -c -o $target $prereq
%-debug.o: %.c
        gcc -g -c -o $target $prereq
%-prof.o: %.c
        gcc -p -c -o $target $prereq

>     * second, each file has a unique dependency graph -- for example
> one `*.c` file might include other headers than another `*.c` file in
> the same project; thus when updating a single header I want to be able
> to build only those `*.c` files that actually depend on it; (this
> observation is less important for C applications, but for other type
> of programs -- like Java -- this fine grained dependency tracking
> means a lot of saved computing power);

Have you looked at cpp -M? Many cpps will generate make style
dependencies for you, I think they'll work with mk as well. You can
include them and the use meta rules for all the real work.

It's still a large list of dependencies though, so it might not help you
in this case. I'm no sure if erlang has somethings similar or not.

>     * third, in my brief experience with make files, meta-rules are
> quite hard to get right... furthermore it is impossible to have two
> patterns like: `%.%.x`; just imagine I have two types of images:
> background and foreground and I want to superimpose them, then I would
> like to be able to write `%{foreground}.%{background}.jpg :
> %{foreground}.jpg %{background}.jpg ..."; (I know that I can resort
> here to "<| generating command" but it seems just plain wrong...)

Mk's meta rules are much easier to get right because they don't get
messed up by all of GNU Make's automatically added meta rules. Also:

default:V: circle-square.png

(.*)-(.*).png:R: \1.png \2.png
        composite $prereq $target

P.S. anyone know a better way to composite images using the
plan9/plan9port image tools?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Jan 18 2011, 8:31 am
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Tue, 18 Jan 2011 13:31:23 GMT
Local: Tues, Jan 18 2011 8:31 am
Subject: Re: [9fans] `mk` (from Plan9 ports) efficiency related issue

> P.S. anyone know a better way to composite images using the
> plan9/plan9port image tools?

what do you mean by better?  there's a compose program in
contrib quanstro/radar which may compile on p9p just fine.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »