From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: ka@socrates.hr.att.com (Kenneth Almquist) Subject: Re: Java vs Ada 95 (Was Re: Once again, Ada absent from DoD SBIR solicitation) Date: 1996/10/31 Message-ID: <55aoo1$die@nntpa.cb.lucent.com>#1/1 X-Deja-AN: 193455442 references: <325BC3B3.41C6@hso.link.com> <325D7F9B.2A8B@gte.net> <325FF8D0.6660@io.com> <554c5d$4ag@nntpa.cb.lucent.com> organization: Lucent Technologies, Columbus, Ohio newsgroups: comp.lang.ada Date: 1996-10-31T00:00:00+00:00 List-Id: > Kenneth says > > "I suspect that automatic garbage collection is required to implement > unbounded strings efficiently. In Icon, the assignment "b := a" can > be performed by simply copying a pointer." > > This is an unjustified generalization from one benchmark. There are two > ways of handling unbounded strings, copy on modify and copy on assignment. > It is trivial to write a benchmark that will kill the ICON copy on > assignment model, you just chose something which was the other way round. The benchmark I presented did concatenation, assignment, and substring operations. What operations do you think a string benchmark should contain, if not these? In any case, the GNAT code ran so slowly that issues like copying don't really change the picture. We can cause the Icon interpreter to copy a string before assignment by concatenating an empty string. The resulting timings are: 1.39 seconds for Icon 1.59 seconds for Icon with copy before assignment 10.03 seconds for GNAT The first number is a little lower than the value I gave in my previous post because I deleted a null statement. (The Icon interpreter takes about a microsecond to execute a null statement.) The point of my comment about doing string assignment by copying a single pointer is that garbage collection allows you to eliminate essentially all the code that GNAT currently generates for unbounded string assignments. Currently, copying the contents of the string is only a small part of that. If you can find a way to speed up the code that GNAT generates for controlled types to the point that the majority of the cost of assigning an unbounded string is the cost of copying the contents of the string, then I'll post an article here complaining that the GNAT implementation of unbounded string is unacceptably slow because it copies the contents of strings on every assignment. :-) But my guess is that no amount of work on the way GNAT handles controlled types will get you to that point. That's why I stated in my earlier article that efficient implementation of Unbounded_String probably requires automatic garbage collection. Kenneth Almquist -------------------------------------------------------------------- # Version of benchmark where we prevent sharing of string memory by # concatenating the null string before assignment when necessary. procedure main() local a, b, c, i, first a := "abcdefghijklmnopqrstuvwxyz" b := "ABCDEFGHIJKLMNOPQRSTUVWXYZ" every i := 1 to 40000 do { c := b || a || b b := a || "" a := c[1 : 27] || "" } write(c) end