Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #59777

Re: allot which initialize the alloted space ?

From Alex <alex@rivadpm.com>
Newsgroups comp.lang.forth
Subject Re: allot which initialize the alloted space ?
Date 2017-05-24 16:58 +0100
Organization A noiseless patient Spider
Message-ID <og4abs$cu0$1@dont-email.me> (permalink)
References (1 earlier) <9dc8fce7-889a-40ca-b57c-382d3569620f@googlegroups.com> <ofsapd$le7$1@dont-email.me> <be9ff482-b5c2-41e7-a06b-dc9d1f8571eb@googlegroups.com> <ofsecg$1mu$1@dont-email.me> <ff9b9e91-4de1-4f78-810e-c53bef78ad82@googlegroups.com>

Show all headers | View raw


On 5/24/2017 16:03, hughaguilar96@gmail.com wrote:
> On Sunday, May 21, 2017 at 9:17:33 AM UTC-7, Ron Aaron wrote:
>> On 21/05/2017 19:02, hughaguilar96@gmail.com wrote:
>>> As for the time that it takes to initialize data to zero, I don't
>>> worry about that. Modern processors are pretty fast!
>> 
>> Memory speed is not insignificant, and is considerably slower than 
>> processor speed.  If the data being initialized is (for example) a
>> 10000 byte long buffer, then the memory initialization time is
>> significant, and if it's happening in a time-critical loop, you
>> won't want to do the extra work.  That is, if efficiency is
>> important.
> 
> ALLOT is almost always done at compile-time, not run-time. A 10000
> ALLOT in a time-critical loop is nonsense.
> 
> I also zero out ALLOCATE and speed is an issue there. ALLOCATE is
> already horribly slow though, but that is the OS --- that has nothing
> to do with my zeroing out the memory, which takes a few microseconds,
> even with a 10000 byte block --- I typically use ALLOCATE for
> structs, and they are typically less than 100 bytes in size. A 10000
> ALLOCATE in a time-critical loop is nonsense.
> 
> A lot of these comp.lang.forth threads seem to quickly devolve into
> nonsense, and this is one of them --- just zero out the memory as
> typical defensive-programming to help with debugging --- don't worry,
> be happy!
> 

I agree that there are few times you will be ALLOTing, and ALLOCATE is 
overhead laden in many systems; so zeroing is a marginal loss.

However buffer management is one area where large allocations, 
frequently performed, are an issue. Zeroing storage at every allocation 
out of a pool may have significant overheads. A few microseconds is more 
than hugely significant when you're shifting data across a network at 
the rate of Tb/sec. Don't do it unless you have hardware assistance 
would be my advice.

I also disagree that zeroing is good for defensive-programming to help 
with debugging. In the 40+ years or so that I've been do this, I've 
found oddball bit patterns more useful. There's nothing quite like 
seeing DEADBEEF (obvious) FA17FA17 (FAILFAIL) 71077345 (Shell Oil upside 
down) or your chosen fill a few digits or bits off, in a register or key 
memory location, to know that there's something quite wrong. Zero is too 
ubiquitous to be of much use.

-- 
Alex

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

allot which initialize the alloted space ? Andreas Klimas <klimas@w3group.de> - 2017-05-21 13:50 +0200
  Re: allot which initialize the alloted space ? Coos Haak <htrofhc@gmail.com> - 2017-05-21 14:13 +0200
  Re: allot which initialize the alloted space ? hughaguilar96@gmail.com - 2017-05-21 08:01 -0700
    Re: allot which initialize the alloted space ? Ron Aaron <rambamist@gmail.com> - 2017-05-21 18:16 +0300
      Re: allot which initialize the alloted space ? hughaguilar96@gmail.com - 2017-05-21 09:02 -0700
        Re: allot which initialize the alloted space ? Ron Aaron <rambamist@gmail.com> - 2017-05-21 19:17 +0300
          Re: allot which initialize the alloted space ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-22 11:22 +0000
          Re: allot which initialize the alloted space ? hughaguilar96@gmail.com - 2017-05-24 08:03 -0700
            Re: allot which initialize the alloted space ? Alex <alex@rivadpm.com> - 2017-05-24 16:58 +0100
        Re: allot which initialize the alloted space ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-22 07:40 +0000
          Re: allot which initialize the alloted space ? Mark Wills <markwills1970@gmail.com> - 2017-05-22 08:02 -0700
            Re: allot which initialize the alloted space ? "HAA" <someone@microsoft.com> - 2017-05-24 16:40 +1000
          Re: allot which initialize the alloted space ? hughaguilar96@gmail.com - 2017-05-22 13:27 -0700
      Re: allot which initialize the alloted space ? Alex <alex@rivadpm.com> - 2017-05-21 17:16 +0100
        Re: allot which initialize the alloted space ? Ron Aaron <rambamist@gmail.com> - 2017-05-21 19:22 +0300
          Re: allot which initialize the alloted space ? Alex <alex@rivadpm.com> - 2017-05-21 18:03 +0100
          Re: allot which initialize the alloted space ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-21 20:46 +0200
            Re: allot which initialize the alloted space ? Alex <alex@rivadpm.com> - 2017-05-21 20:34 +0100
      Re: allot which initialize the alloted space ? "HAA" <someone@microsoft.com> - 2017-05-24 16:41 +1000
  Re: allot which initialize the alloted space ? Julian Fondren <julian.fondren@gmail.com> - 2017-05-21 08:36 -0700

csiph-web