X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cHE6qi5l9Lh5kvF9WKbD+iQ50UP8h7eZnrl4fiuzjLE=; b=UmdmHniIqJCL+aE2vMA6cAwXtJyG1QbJzxbUsmYFKUdhL+J8ABralZ34CZJNVO4nfR q3J6oyb1CP0WGA3gKScAb6zWcke5Pbrod4EPW5309SH/degDBOJ5Ks34XAGDAov1Blso Rkx+hg0qDTBEE1+wIMk7wQ1KMMnKEGgmw3TX8= MIME-Version: 1.0 In-Reply-To: <20111205214441.3691881D543C@turkos.aspodata.se> References: <20111130211002 DOT 32B5081F6275 AT turkos DOT aspodata DOT se> <20111203133340 DOT E09A181D541B AT turkos DOT aspodata DOT se> <20111203215549 DOT 238A581D5424 AT turkos DOT aspodata DOT se> <20111205214441 DOT 3691881D543C AT turkos DOT aspodata DOT se> Date: Tue, 6 Dec 2011 13:28:14 +0100 Message-ID: Subject: Re: [geda-user] Dynamic loading personal components (with subfolder) into the search component tree of gschem From: Luigi Salvatore Palese To: geda-user AT delorie DOT com Content-Type: multipart/mixed; boundary=20cf3074b5feb8609204b36b9148 Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --20cf3074b5feb8609204b36b9148 Content-Type: multipart/alternative; boundary=20cf3074b5feb8608f04b36b9146 --20cf3074b5feb8608f04b36b9146 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Dec 5, 2011 at 10:44 PM, Karl Hammar wrote: > Luigi: > ... > > In attachment an improved version of the script. > ... > > That version works fine. > > It seems a little strange, though, to use both ftw and opendir. > Let me to explain why this decision. In my point of view we have two targets: a) build a list with the sub-folders, and b) skip sub-folder with no files or files other than .sym So the ftw system is very fast to build the tree of sub-folders, but it scans all the tree in depth. I haven't found any option to stop it at the first level of the tree. This is the real reason on the why i use readdir in the (is-there-any-symbols-in?) procedure. readdir,instead, stops at the first level of the tree and the procedure exit immediately when found a sym file. So the code in (build-symbols-list) does a searching for only the subfolders containing sym files and exiting as fast as possible. I thought the overhead of this mechanism is lower than an hash calculation for each sym file. But I was wrong ! So to verify this i make a test as follow: i have downloaded all gedasymbols site in the folder gedasymbol and copy it 4 times so i have: gedasymbol gedasymbol2 gedasymbol3 gedasymbol4 gedasymbol5 main folders. Each folder has (at now): 716 folder (x5 3580) 4997 files of this 1754 are symbols (x5 24985 8770) in gafrc i put the following lines: (load (build-path geda-rchome-path "local-symbols-library.scm")) <-- opendir version ;;;(load (build-path geda-rchome-path "peter.scm")) <-- Peter version ;;;(load (build-path geda-rchome-path "karl.scm")) <-- Karl version ;;;(load (build-path geda-rchome-path "local-symbols-library-hash-version.scm")) <-- we'll see later (component-library-add-tree "Own" "/home/ultrabit/ProgrammingWorkspace/gitrepos/sviluppo-100/gitosis-admin/Fo= otprints/gEda-sym/personal/") (component-library-add-tree "gEDA" "/home/ultrabit/ProgrammingWorkspace/electronics/geda-suite/gedasymbols/www= /user") (component-library-add-tree "gEDA1" "/home/ultrabit/ProgrammingWorkspace/electronics/geda-suite/gedasymbols2/ww= w/user") (component-library-add-tree "gEDA2" "/home/ultrabit/ProgrammingWorkspace/electronics/geda-suite/gedasymbols3/ww= w/user") (component-library-add-tree "gEDA3" "/home/ultrabit/ProgrammingWorkspace/electronics/geda-suite/gedasymbols4/ww= w/user") (component-library-add-tree "gEDA4" "/home/ultrabit/ProgrammingWorkspace/electronics/geda-suite/gedasymbols5/ww= w/user") at the prompt shell i run: ultrabit AT hurricane:~/.gEDA$ time gschem -c "(gschem-exit)" <--- loading gschem and exit at startup Invalid path [./sym] passed to component-library Invalid path [./footprint] passed to component-library Invalid path [./footprint] passed to component-library-search real 0m1.427s user 0m1.100s sys 0m0.248s (total gschem loading time (intel core 2 @ 3Ghz and 8 Gb of ram (not all free)) Step 2 second test some conditions but Peter version: ;;;(load (build-path geda-rchome-path "local-symbols-library.scm")) <-- opendir version (load (build-path geda-rchome-path "peter.scm")) <-- Peter version ;;;(load (build-path geda-rchome-path "karl.scm")) <-- Karl version ;;;(load (build-path geda-rchome-path "local-symbols-library-hash-version.scm")) <-- we'll see later ultrabit AT hurricane:~/.gEDA$ time gschem -c "(gschem-exit)" Invalid path [./sym] passed to component-library Invalid path [./footprint] passed to component-library Invalid path [./footprint] passed to component-library-search real 0m5.538s user 0m3.600s sys 0m1.840s Step 3 same conditions but with Karl version: ultrabit AT hurricane:~/.gEDA$ time gschem -c "(gschem-exit)" Invalid path [./sym] passed to component-library Invalid path [./footprint] passed to component-library Invalid path [./footprint] passed to component-library-search real 0m1.436s user 0m1.172s sys 0m0.160s So, i am surprised about results because i thought the Karl version was like the Peter version, but this is not true. I found the problem (many thanks to the "two column" emacs mode) was the use of (hasx-set!) vs (hashq-set!) and storing symbols instead of strings . In conclusion i made a very condensed guile code (one procedure) to do all using only ftw: Step 4: ;;;(load (build-path geda-rchome-path "local-symbols-library.scm")) <-- opendir version ;;;(load (build-path geda-rchome-path "peter.scm")) <-- Peter version ;;;(load (build-path geda-rchome-path "karl.scm")) <-- Karl version (load (build-path geda-rchome-path "local-symbols-library.scm")) <-- Optimized hash version ultrabit AT hurricane:~/.gEDA$ time gschem -c "(gschem-exit)" Invalid path [./sym] passed to component-library Invalid path [./footprint] passed to component-library Invalid path [./footprint] passed to component-library-search real 0m1.229s user 0m0.980s sys 0m0.152s The better i can do :-D If we are going to use opendir, we could just as well do the > traversal ourself and dump ftw. > > I see two alternatives: > > a) I'm satisfied with my version, and stop here > > b) we > dump ftw > do the traversal ourself > clean up your script > and proposes it for inclusion in geda > > What do you think? > Karl, please look at code in attachment and say me if can be accepted as is. I think this can be proposed for inclusion in geda. > > Regards, > /Karl Hammar > > ----------------------------------------------------------------------- > Asp=F6 Data > Lilla Asp=F6 148 > S-742 94 =D6sthammar > Sweden > +46 173 140 57 > > > Regards, Luigi PS: Peter in bcc as FYI --20cf3074b5feb8608f04b36b9146 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Mon, Dec 5, 2011 at 10:44 PM, Karl Ha= mmar <karl AT aspodata DOT se> wrote:
Luigi:
...
> In attachment an improved version of the script.
...

That version works fine.

It seems a little strange, though, to use both ftw and opendir.
Let me to explain why this decision. In my point of view we have = two targets:

a) build a list with the sub-folders, and
b) skip su= b-folder with no files or files other than .sym

So the ftw system is very fast to build the tree of sub-folders, but it= scans all the tree in depth. I haven't found any option to stop it at = the first level of the tree. This is the real reason on the why i use readd= ir in the (is-there-any-symbols-in?) procedure. readdir,instead, stops at t= he first level of the tree and the procedure exit immediately when found a = sym file.
So the code in (build-symbols-list) does a searching for only the subfolder= s containing sym files and exiting as fast as possible.
I thought the overhead of this mechanism is lower than an hash calculation= for each sym file. But I was wrong !
So to verify this i make a test as follow:

i have downloaded all ged= asymbols site in the folder gedasymbol and copy it 4 times so i have:
ge= dasymbol
gedasymbol2
gedasymbol3
gedasymbol4
gedasymbol5

main folders. Each folder has (at now):
716 folder (x5 3580)
4997 files of this 1754 are symbols (x5 24985 8770)=
=A0
in gafrc i put the following lines:
(load (build-path geda-rc= home-path "local-symbols-library.scm")) <-- opendir version ;;;(load (build-path geda-rchome-path "peter.scm")) <-- Peter= =A0 version
;;;(load (build-path geda-rchome-path "karl.scm"))= =A0 <-- Karl=A0 version
;;;(load (build-path geda-rchome-path "l= ocal-symbols-library-hash-version.scm")) <-- we'll see later
(component-library-add-tree "Own" "/home/ultrabit/Progra= mmingWorkspace/gitrepos/sviluppo-100/gitosis-admin/Footprints/gEda-sym/pers= onal/")
(component-library-add-tree "gEDA" "/home/ultrabit/Programmi= ngWorkspace/electronics/geda-suite/gedasymbols/www/user")
(componen= t-library-add-tree "gEDA1" "/home/ultrabit/ProgrammingWorksp= ace/electronics/geda-suite/gedasymbols2/www/user")
(component-library-add-tree "gEDA2" "/home/ultrabit/Programm= ingWorkspace/electronics/geda-suite/gedasymbols3/www/user")
(compon= ent-library-add-tree "gEDA3" "/home/ultrabit/ProgrammingWork= space/electronics/geda-suite/gedasymbols4/www/user")
(component-library-add-tree "gEDA4" "/home/ultrabit/Programm= ingWorkspace/electronics/geda-suite/gedasymbols5/www/user")

at = the prompt shell i run:

ultrabit AT hurricane:~/.gEDA$ time gschem -c &= quot;(gschem-exit)"=A0=A0=A0=A0 <--- loading gschem and exit at sta= rtup
Invalid path [./sym] passed to component-library
Invalid path [./footpri= nt] passed to component-library
Invalid path [./footprint] passed to com= ponent-library-search

real=A0=A0=A0 0m1.427s=A0=A0
user=A0=A0=A0 0m1.100s
sys=A0=A0=A0 0m0.248s

(total gschem loadin= g time (intel core 2 @ 3Ghz and 8 Gb of ram (not all free))

Step 2 = second test some conditions but Peter version:
;;;(load (build-path geda= -rchome-path "local-symbols-library.scm")) <-- opendir version=
(load (build-path geda-rchome-path "peter.scm")) <-- Peter=A0 = version
;;;(load (build-path geda-rchome-path "karl.scm"))=A0 <-- Karl= =A0 version
;;;(load (build-path geda-rchome-path "local-symbols-library-hash-vers= ion.scm")) <-- we'll see later
=A0
ultrabit AT hurricane:~/.= gEDA$ time gschem -c "(gschem-exit)"
Invalid path [./sym] pass= ed to component-library
Invalid path [./footprint] passed to component-library
Invalid path [./f= ootprint] passed to component-library-search

real=A0=A0=A0 0m5.538s<= br>user=A0=A0=A0 0m3.600s
sys=A0=A0=A0 0m1.840s

Step 3 same condi= tions but with Karl version:
ultrabit AT hurricane:~/.gEDA$ time gschem -c "(gschem-exit)"
Inv= alid path [./sym] passed to component-library
Invalid path [./footprint]= passed to component-library
Invalid path [./footprint] passed to compon= ent-library-search

real=A0=A0=A0 0m1.436s
user=A0=A0=A0 0m1.172s
sys=A0=A0=A0 0m0.16= 0s

So, i am surprised about results because i thought the Karl versi= on was like the Peter version, but this is not true.
I found the proble= m (many thanks to the "two column" emacs mode) was the use of (ha= sx-set!) vs (hashq-set!) and storing symbols instead of strings .
In conclusion i made a very condensed guile code (one procedure) to do all = using only ftw:

Step 4:
;;;(load (build-path geda-rchome-path &qu= ot;local-symbols-library.scm")) <-- opendir version
;;;(load (build-path geda-rchome-path "peter.scm")) <-- Peter= =A0 version
;;;(load (build-path geda-rchome-path "karl.scm"))=A0 <-- Karl= =A0 version
(load (build-path geda-rchome-path "local-symbols-library.scm"))= =A0 <-- Optimized hash version

ultrabit AT hurricane:~/.gEDA$ time g= schem -c "(gschem-exit)"
Invalid path [./sym] passed to compon= ent-library
Invalid path [./footprint] passed to component-library
Invalid path [./f= ootprint] passed to component-library-search

real=A0=A0=A0 0m1.229s<= br>user=A0=A0=A0 0m0.980s
sys=A0=A0=A0 0m0.152s

The better i can = do :-D


If we are going to use opendir, we could just as well do the
traversal ourself and dump ftw.

I see two alternatives:

a) I'm satisfied with my version, and stop here

b) we
=A0 =A0dump ftw
=A0 =A0do the traversal ourself
=A0 =A0clean up your script
=A0and proposes it for inclusion in geda

What do you think?

Karl, please look at code in at= tachment and say me if can be accepted as is. I think this can be proposed = for inclusion in geda.

=A0

Regards,
/Karl Hammar

-----------------------------------------------------------------------
Asp=F6 Data
Lilla Asp=F6 148
S-742 94 =D6sthammar
Sweden
+46 173 140 57


Regards,
Luigi

PS:
Peter in bcc= as FYI
--20cf3074b5feb8608f04b36b9146-- --20cf3074b5feb8609204b36b9148 Content-Type: text/x-scheme; charset=US-ASCII; name="local-symbols-library.scm" Content-Disposition: attachment; filename="local-symbols-library.scm" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gvuvncck0 OyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IC0qLVNjaGVtZS0qLQo7ICAgIFRoaXMgcHJvZ3JhbSBpcyBmcmVlIHNvZnR3YXJlOiB5b3UgY2Fu IHJlZGlzdHJpYnV0ZSBpdCBhbmQvb3IgbW9kaWZ5CjsgICAga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mFtZSkKCQkgIChoYXNocS1zZXQh IGh0IChzdHJpbmctPnN5bWJvbCAoZGlybmFtZSBmaWxlbmFtZSkpICN0KSkgI3QpKSkKICAgIChm b3ItZWFjaAogICAgIChsYW1iZGEgKGRpcikKICAgICAgIChjb21wb25lbnQtbGlicmFyeSBkaXIg KHN0cmluZy1hcHBlbmQgcHJlZml4IChzdHJpbmctY29weSBkaXIgKHN0cmluZy1sZW5ndGggbWFp bmZvbGRlcikpKSkKICAgICAgICkKICAgICAoc29ydC1saXN0ISAoaGFzaC1tYXAtPmxpc3QgKGxh bWJkYSAoa2V5IHZhbCkgKHN5bWJvbC0+c3RyaW5nIGtleSkpIGh0KSBzdHJpbmc+PykpCiAgICAp CiAgKQo= --20cf3074b5feb8609204b36b9148--