Re: Cracking DES with C++ is faster than Java?

From: Jerry Coffin (jcoffin_at_taeus.com)
Date: 04/30/04


Date: 29 Apr 2004 21:13:46 -0700


"Andrew Swallow" <am.swallow@eatspam.btinternet.com> wrote in message news:<c6o7e4$pmn$1@sparta.btinternet.com>...

[ ... ]

> Computers can access fixed locations in memory
> faster that relative locations.

That's not necessarily true. In theory, it takes more work to
generate the absolute address from a relative address, but in fact
nearly all reasonably current computers have hardware dedicated to the
task.

With most modern computers, a cache miss causes a MUCH larger delay
than figuring an effective address.

> Recursion requires
> local variables to be stored on the stack, i.e. to
> be accessed using relative locations. Data structures
> on the heap are even more complicated to access.

Not so -- allocating and freeing data can be expensive, but at least
in C and C++, when you allocate memory on the heap/free store you get
the (absolute) address of the memory allocated. Once you have that,
the access is relatively direct. By contrast, access to the stack is
essentially always done relative to some register.

As noted above, however, this rarely means much. Accessing data on
the stack IS usually quite fast, but that's primarily because the page
at the top of the stack will nearly always be in the cache.

> Dynamic storage is very bad, you can see the computer
> stop for several thousand million clock cycles whilst the
> garbage collector tries to find some more memory.

Only, for starters, when you actually use a garbage collector. Even
then, techniques to reduce waits during a collection cycle have been
well known for quite some time. I realize that many JVMs (for one
example) use GC that dates back to roughly the Lisp 1.5 era, but that
doesn't mean nothing better is known. Generataional scavenging,
incremental GC, etc., have been around for some time and can't be
summarily dismissed even for hard real-time systems.

--
    Later,
    Jerry.
The universe is a figment of its own imagination.


Relevant Pages

  • Re: Cracking DES with C++ is faster than Java?
    ... > be accessed using relative locations. ... the (absolute) address of the memory allocated. ... access to the stack is ... Only, for starters, when you actually use a garbage collector. ...
    (sci.crypt)
  • Re: Cracking DES with C++ is faster than Java?
    ... > be accessed using relative locations. ... the (absolute) address of the memory allocated. ... access to the stack is ... Only, for starters, when you actually use a garbage collector. ...
    (comp.lang.cpp)
  • Re: Register Allocators and Garbage Collectors
    ... A typical garbage collector would "scan" the stack of all ... active processes looking for values that "might be" pointers. ...
    (comp.compilers)
  • Re: Advanced C
    ... C++, and since there is no portable way to scan the stack, the code talking about scanning the stack for pointers must be non-portable (i.e. not standard C), and this is evidenced by the existence of hacks in the code for systems which are sloppy with their stack frames. ... a garbage collector cannot be written in standard C except as part of writing a complete virtual machine where you obviously have complete control over the memory handling of the virtual machine (e.g. if you are writing a JVM). ...
    (comp.lang.c)
  • Re: Store any object in port 0,1,2 directly from stack
    ... misunderstanding you? ... The absolute difficulty is limited by your knowledge of the HP49G+, ... But to be able to use it from the stack, ... C and have a good few hours of HPGCC use behind you. ...
    (comp.sys.hp48)