Re: HLA Lib



On 19 Mar 2007 20:31:33 -0700
"randyhyde@xxxxxxxxxxxxx" <randyhyde@xxxxxxxxxxxxx> wrote:

It's a real shame to watch a programmer do things like use a 1-
byte SCASD instruction to add 4 to EDI (to save a byte or two) and
then have ten times that amount wasted by a memory allocation call.

Quite so, which is why initial allocations should be (under the
programmer's control) large enough for the string buffer to expand and
contract multiple times without triggering a reallocation.

Personally, I'm a bit concerned about the nine bytes of overhead that
HLA strings already consume.

Rather than being concerned, I would say that your code is a model of
conciseness. Even in 32-bit code, it is difficult to pack all the
string management information into only nine bytes. I have always
considered a 16-bit maximum length field, and a 16-bit current length
field to be an absolute minimum, with a 32-bit chain pointer as a
useful addition. And in my multitasking code, another 32-bit field is
required for the tcb address of the owning task.

Then again, memory size really doesn't matter any more. So maybe all
my debating is pointless. :-)

Even on 32-bit systems, virtual memory size doesn't matter much, and as
the x86_64 systems become standard, it will matter even less. What does
matter is working set, and -- to a much lesser extent -- cache line
management. HLL programmers, of course, leave all that to the compiler,
but assembly language programmers should learn to pay attention to
these issues.

-- Chuck
.



Relevant Pages

  • Re: The Strinx Library
    ... The Strinx philosophy is that a library should not enforce a ... >> technique. ... >> string. ... >> an extra memory allocation and copy. ...
    (comp.lang.cpp)
  • Re: Efficient use of results of [binary scan]
    ... And memory allocation is *definitely* comparatively slow ... The same trick is ... naif solution, for my 100K string. ... DOULOS - Developing Design Know-how ...
    (comp.lang.tcl)
  • Re: Problem using copy.copy with my own class
    ... have a string associated with the int. ... By subclassing int to add a string, ... How do I know when the memory allocation ... between pickling and copying here. ...
    (comp.lang.python)
  • Re: Difference between String variable and String Class definition
    ... Duane Evenson wrote: ... as each other about memory allocation or not? ... It copies the string from the first place to the new place ... I would have thought its was syntactic sugar, ...
    (comp.lang.java.programmer)