comp.lang.ada
 help / color / mirror / Atom feed
* User Defined Storage Pool : did you ever experiment with it ?
@ 2011-01-22  0:04 Yannick Duchêne (Hibou57)
  2011-01-22  0:55 ` Adam Beneschan
                   ` (9 more replies)
  0 siblings, 10 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-22  0:04 UTC (permalink / raw)



Hi,

Ada has provision for user defined storage pool, that is, an application  
may have a (or multiple) custom implementation of a heap or like for any  
kind of object.
http://www.ida.liu.se/edu/ugrad/progkon/Ada/ada-doc/LRM95/rm95html/rm9x-13-11.html
(from an uknown site, AdaIC server seems down today)

I don't feel to remember I ever see a single Ada source with some use of  
this. Is this just an not enough known feature, or does it mean there is  
not so much benefit to use it ? Or else, may be this could be beneficial  
but no one never go up to there (no evaluation of this option, or anything  
else) ?

Straightforwardly, I may think about some examples where this may be  
beneficial (you may say if you agree or not):
* Avoid memory fragmentation due to objects of different size (one pool  
with all object of the same size may limit the overall memory  
fragmentation)
* Help the CPU cache to be more efficient (if a pool is created for the  
most accessed type of objects, there may be grouped together in a single,  
thus better use of CPU internal cache)
* Profit from noticeable behavior of some process, like one which most of  
time allocate/deallocate like a stack would while not being really a stack  
(so could not be allocated on the stack).

Or may be basic containers just make user storage pool unnecessary ? (for  
containers holding object values, not reference)
Or is the typical head implementation clever enough is all cases to avoid  
the need of user defined storage pools ?

Just wondered why, while memory resource is so much important, and user  
defined storage pool does not look like an obscure feature, I've never  
seen it at work in multiple sources I could read from the web.


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
@ 2011-01-22  0:55 ` Adam Beneschan
  2011-01-22  1:42   ` Yannick Duchêne (Hibou57)
  2011-01-22  5:19   ` Randy Brukardt
  2011-01-22  8:49 ` Dmitry A. Kazakov
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 39+ messages in thread
From: Adam Beneschan @ 2011-01-22  0:55 UTC (permalink / raw)


On Jan 21, 4:04 pm, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Hi,
>
> Ada has provision for user defined storage pool, that is, an application  
> may have a (or multiple) custom implementation of a heap or like for any  
> kind of object.http://www.ida.liu.se/edu/ugrad/progkon/Ada/ada-doc/LRM95/rm95html/rm...
> (from an uknown site, AdaIC server seems down today)
>
> I don't feel to remember I ever see a single Ada source with some use of  
> this. Is this just an not enough known feature, or does it mean there is  
> not so much benefit to use it ? Or else, may be this could be beneficial  
> but no one never go up to there (no evaluation of this option, or anything  
> else) ?

I've seen lots of publicly available Ada sources that make use of
storage pools.  I couldn't tell you right now where they all are, but
I'm sure others will be happy to provide the links to some examples.

                               -- Adam




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:55 ` Adam Beneschan
@ 2011-01-22  1:42   ` Yannick Duchêne (Hibou57)
  2011-01-22  5:19   ` Randy Brukardt
  1 sibling, 0 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-22  1:42 UTC (permalink / raw)


Le Sat, 22 Jan 2011 01:55:52 +0100, Adam Beneschan <adam@irvine.com> a  
écrit:
> I've seen lots of publicly available Ada sources that make use of
> storage pools.  I couldn't tell you right now where they all are, but
> I'm sure others will be happy to provide the links to some examples.
>
>                                -- Adam
Would be nice.

I've just looked at the Ada WikiBook to see if there was some talk there.
But
http://en.wikibooks.org/wiki/Ada_Programming/Types/access#Deleting_objects_from_a_storage_pool
only mention the existence of Storage Pool and does not introduce use case  
of user defined storage pools.


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:55 ` Adam Beneschan
  2011-01-22  1:42   ` Yannick Duchêne (Hibou57)
@ 2011-01-22  5:19   ` Randy Brukardt
  1 sibling, 0 replies; 39+ messages in thread
From: Randy Brukardt @ 2011-01-22  5:19 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> wrote in message 
news:abbc72ee-19f0-424d-b4d4-bad430b4f562@p7g2000prb.googlegroups.com...
>I've seen lots of publicly available Ada sources that make use of
>storage pools.  I couldn't tell you right now where they all are, but
>I'm sure others will be happy to provide the links to some examples.

I can't say that I've seen any such uses, but I can say that I've used 
specialized storage pools for quite a number of different jobs. One of the 
most important is debugging of storage leaks and the like.

I believe GNAT comes with some storage pools for this purpose; presumably 
the source is available somewhere to look at.

                                Randy.





^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
  2011-01-22  0:55 ` Adam Beneschan
@ 2011-01-22  8:49 ` Dmitry A. Kazakov
  2011-01-22  9:47 ` User Defined Storage Pool : Example anon
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: Dmitry A. Kazakov @ 2011-01-22  8:49 UTC (permalink / raw)


On Sat, 22 Jan 2011 01:04:41 +0100, Yannick Duch�ne (Hibou57) wrote:

> Ada has provision for user defined storage pool, that is, an application  
> may have a (or multiple) custom implementation of a heap or like for any  
> kind of object.
> http://www.ida.liu.se/edu/ugrad/progkon/Ada/ada-doc/LRM95/rm95html/rm9x-13-11.html
> (from an uknown site, AdaIC server seems down today)
> 
> I don't feel to remember I ever see a single Ada source with some use of  
> this. Is this just an not enough known feature, or does it mean there is  
> not so much benefit to use it ?

http://www.dmitry-kazakov.de/ada/components.htm#Pools_etc
http://www.dmitry-kazakov.de/ada/components.htm#Generic_Doubly_Linked_Web

> Or else, may be this could be beneficial  
> but no one never go up to there (no evaluation of this option, or anything  
> else) ?

Storage pools are extremely useful for purposes, which are not directly
related to memory allocation. If you take a look at the example I provided,
you will notice that the storage pools there do not maintain a heap of
their own. They rather take the memory from some backend pool.
 
Consider the doubly-link list implementation. It is storage pool based. The
links are not in the element body. They are maintained by the pool. So you
can have any type as the list element type, plain strings for example. 

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : Example
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
  2011-01-22  0:55 ` Adam Beneschan
  2011-01-22  8:49 ` Dmitry A. Kazakov
@ 2011-01-22  9:47 ` anon
  2011-01-22  9:54 ` User Defined Storage Pool : did you ever experiment with it ? AdaMagica
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 39+ messages in thread
From: anon @ 2011-01-22  9:47 UTC (permalink / raw)


-- referance delete for spacing


-- Found on www.adapower.com
--
-- http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=222
--
-- Files:
--        memory_management-test.adb
--        memory_management-support.ads
--        memory_management-support.adb
--        memory_management.ads
--        memory_management.adb
--
-- To compile and run:
-- 
--   >gnat make memory_management-test.adb
--   >memory_management-test

--
--  Memory Management with Storage Pools (Anh Vo)
--
--  Memory management can cause real headache due to memory leakage over 
--  time. That is, memory allocation is not properly deallocated after the 
--  call. When the memory runs out, the result could be catastrophic for 
--  some applications. This problem can be recued by garbage collector 
--  built-in the compiler such as Java. However, the cost of run-time 
--  overhead is high.
     
--  Here comes Ada 95 to the recue. How is it possible you may ask? Ah! 
--  Ada 95 provides a feature called Storage Pool. It allows the users 
--  have total control over the memory management. Best of all, it does 
--  not involve run-time overhead as garbage collector. When it is 
--  combined with controlled type, the memory leakage problem is history.
    
--  As shown in the test case, 100 storage elements were allocated 
--  initially. Then, these storage elements are reused again and again. It 
--  is pretty cool isn't it? Enjoy.
     

--------------------------------------------
-- File => memory_management-test.adb
--
with Ada.Finalization ;
with Ada.Text_Io ;
with Memory_Management.Support ;
     
procedure Memory_Management.Test is
    use Ada ;
    use Text_Io ;
     
begin
     
  Put_Line ("********* Memory Control Testing Starts **********") ;
   
  for Index in 1 .. 10 loop
    declare
      David_Botton : Support.General_Data ;
      Nick_Roberts : Support.General_Data ;
      Anh_Vo       : Support.General_Data ;
     
    begin
      David_Botton := ( Finalization.Controlled with
                         Id   => new Integer' ( 111 ), 
                         Name => new String' ( "David Botton" ) ) ;

      Nick_Roberts := ( Finalization.Controlled with
                          Id   => new Integer' ( 222 ), 
                          Name => new String' ( "Nick Roberts" ) ) ;

      Anh_Vo := ( Finalization.Controlled with
                    Id   => new Integer' ( 333 ),
                    Name => new String' ( "Anh Vo" ) ) ;
    end ;
  end loop ;
     
  Put_Line ( "Memory Management Test Passes" ) ;
     
exception
  when others =>
    Put_Line ( "Memory Management Test Fails" ) ;
     
end Memory_Management.Test ;


--------------------------------------------
-- File => memory_management-support.ads
--
with Ada.Finalization ;
     
package Memory_Management.Support is
     
  use Ada ;
     
  -- Adjust the storage size according to the application
  Big_Pool : User_Pool ( Size => 100 )  ;
     
  type Int_Acc is access Integer ;
    for Int_Acc'Storage_Pool use Big_Pool ;
     
  type Str_Acc is access all String ;
    for Str_Acc'Storage_Pool use Int_Acc'Storage_Pool ;
     
  type General_Data is new Finalization.Controlled 
         with record
                Id : Int_Acc ;
                Name : Str_Acc ;
              end record ;
     
  procedure Initialize ( Object : in out General_Data )  ;
     
  procedure Finalize ( Object : in out General_Data )  ;
     
end Memory_Management.Support ;
     

--------------------------------------------
-- File => memory_management-support.adb
--
with Ada.Unchecked_Deallocation ;
     
package body Memory_Management.Support is
     
  procedure Free is new Ada.Unchecked_Deallocation 
                                                 ( Integer, Int_Acc ) ;
  procedure Free is new Ada.Unchecked_Deallocation
                                                  ( String, Str_Acc ) ;
     
   procedure Initialize ( Object : in out General_Data ) is
     begin
       null ;
     end Initialize ;
     
  procedure Finalize ( Object : in out General_Data ) is
    begin
      Free ( Object.Id ) ;
      Free ( Object.Name ) ;
    end Finalize ;
     
end Memory_Management.Support ;
     
--------------------------------------------     
-- File => memory_management.ads
--
with System.Storage_Pools ;
with System.Storage_Elements ;
     
package Memory_Management is
     
    use System ;
    use Storage_Elements ;
    use Storage_Pools ;
     
  type User_Pool ( Size : Storage_Count ) is new
                                       Root_Storage_Pool with private ;
     
  procedure Allocate ( Pool                     : in out User_Pool ;
                       Storage_Address          :    out Address   ;
                       Size_In_Storage_Elements : in Storage_Count ;
                       Alignment                : in Storage_Count ) ;
     
  procedure Deallocate 
                      ( Pool                     : in out User_Pool ;
                        Storage_Address          : in     Address   ;
                        Size_In_Storage_Elements : in Storage_Count ;
                        Alignment                : in Storage_Count ) ;
     
  function Storage_Size ( Pool : in User_Pool ) 
               return Storage_Count ;
     
  -- Exeption declaration

  Memory_Exhausted : exception ;
     
  Item_Too_Big : exception ;
     
private
  type User_Pool ( Size : Storage_Count ) is new Root_Storage_Pool
           with record
                  Data       : Storage_Array ( 1 .. Size ) ;
                  Addr_Index : Storage_Count := 1 ;
                end record ;
     
end Memory_Management ;
     

--------------------------------------------     
-- File => memory_management.adb
--
with Ada.Exceptions ;
with Ada.Text_Io ;
with System ;
with System.Storage_Elements ;
with System.Address_To_Access_Conversions ;
     
package body Memory_Management is
     
    use Ada ;
    use Text_Io ;
    use System ;
    use Storage_Elements ;
    use type Storage_Count ;
     
  Package_Name : constant String := "Memory_Management." ;
     
    -- Used to turn on/off the debug information
  Debug_On : Boolean := True ; -- False ;
     
  type Holder is record
         Next_Address : Address := System.Null_Address ;
  end record ;
     
  package Addr_To_Acc is new Address_To_Access_Conversions ( Holder ) ;
     
  -- Keep track of the size of memory block for reuse
  Free_Storage_Keeper : array ( Storage_Count range 1 .. 100 )
          of Address := ( others => Null_Address ) ;
     
  procedure Display_Info ( Message       : string ; 
                           With_New_Line : Boolean := True ) is
    begin
      if Debug_On then
        if With_New_Line then
          Put_Line ( Message ) ;
        else
          Put ( Message ) ;
        end if ;
      end if ;
    end Display_Info ;
     

  procedure Allocate ( Pool                     : in out User_Pool ;
                       Storage_Address          :    out Address   ;
                       Size_In_Storage_Elements : in Storage_Count ;
                       Alignment                : in Storage_Count ) is
          
      Procedure_Name : constant String := "Allocate" ;
      Temp_Address   : Address  := Null_Address ;
      Marker         : Storage_Count ;
    begin
     
      Marker := ( Size_In_Storage_Elements + Alignment - 1 )
              / Alignment ;
     
      if Free_Storage_Keeper ( Marker ) /= Null_Address then
        Storage_Address := Free_Storage_Keeper ( Marker ) ;
        Free_Storage_Keeper (Marker) :=
        Addr_To_Acc.To_Pointer 
                ( Free_Storage_Keeper ( Marker ) ).Next_Address ;
      else
        Temp_Address := Pool.Data (Pool.Addr_Index)'Address ;
              
        Pool.Addr_Index := Pool.Addr_Index 
                         + Alignment 
                         * ( ( Size_In_Storage_Elements 
                               + Alignment - 1 ) 
                         / Alignment ) ;
     
        -- make sure memory is available as requested
        if Pool.Addr_Index > Pool.Size then
          Exceptions.Raise_Exception ( Storage_Error'Identity,
                                       "Storage exhausted in " 
                                       & Package_Name 
                                       & Procedure_Name ) ;
        else
          Storage_Address := Temp_Address ;
        end if ;
      end if ;
     
      Display_Info  ( "Address allocated from pool: "
                      & Integer_Address'Image 
                          ( To_Integer ( Storage_Address ) ) ) ;
   
      Display_Info ( "storage elements allocated from pool: "
                     & Storage_Count'Image 
                          ( Size_In_Storage_Elements ) ) ;
     
      Display_Info ( "Alignment in allocation operation: "
                     & Storage_Count'Image ( Alignment ) ) ;
   
    exception
      when Error : others => -- Object too big or memory exhausted
        Display_Info ( Exceptions.Exception_Information ( Error ) ) ;
        raise ;
     
    end Allocate ;


  procedure Deallocate 
                     ( Pool                     : in out User_Pool ;
                       Storage_Address          : in     Address   ;
                       Size_In_Storage_Elements : in Storage_Count ;
                       Alignment                : in Storage_Count ) is
          
      Marker : Storage_Count ;
     
    begin
     
      Marker := ( Size_In_Storage_Elements + Alignment - 1) 
              / Alignment ;
      Addr_To_Acc.To_Pointer ( Storage_Address ).Next_Address :=
                                     Free_Storage_Keeper ( Marker ) ;
      Free_Storage_Keeper ( Marker ) := Storage_Address ;
     
      Display_Info  ( "Address returned to pool: " 
                      & Integer_Address'Image 
                          ( To_Integer ( Storage_Address ) ) ) ;
     
      Display_Info ( "storage elements returned to pool: "
                     & Storage_Count'Image 
                         ( Size_In_Storage_Elements ) ) ;
     
      Display_Info ( "Alignment used in deallocation: "
                     & Storage_Count'Image ( Alignment ) ) ;
     
  end Deallocate ;
     
  function Storage_Size ( Pool : in User_Pool ) 
             return Storage_Count is
    begin
      return Pool.Size ;
    end Storage_Size ;
     
end Memory_Management ;




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (2 preceding siblings ...)
  2011-01-22  9:47 ` User Defined Storage Pool : Example anon
@ 2011-01-22  9:54 ` AdaMagica
  2011-01-24  9:57   ` Yannick Duchêne (Hibou57)
  2011-01-24 10:48   ` Mark Lorenzen
  2011-01-22 15:13 ` Simon Wright
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 39+ messages in thread
From: AdaMagica @ 2011-01-22  9:54 UTC (permalink / raw)


We use storage pools on a helicopter flight simulator. All global
objects are elements of one storage pool. Thus we can take snapshots
of a current state by simply storing away the pool contents. Later, by
restoring the pool contents, a previous situation, e.g. where a pilot
did not perform correctly, can be restored and the pilot can try to do
better.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (3 preceding siblings ...)
  2011-01-22  9:54 ` User Defined Storage Pool : did you ever experiment with it ? AdaMagica
@ 2011-01-22 15:13 ` Simon Wright
  2011-01-24  9:56   ` Yannick Duchêne (Hibou57)
  2011-01-24 23:58   ` Yannick Duchêne (Hibou57)
  2011-01-22 22:17 ` Fritz Wuehler
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 39+ messages in thread
From: Simon Wright @ 2011-01-22 15:13 UTC (permalink / raw)


"Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr> writes:

> I don't feel to remember I ever see a single Ada source with some use
> of this. Is this just an not enough known feature, or does it mean
> there is not so much benefit to use it ? Or else, may be this could be
> beneficial but no one never go up to there (no evaluation of this
> option, or anything else) ?

The Booch Components (https://sourceforge.net/projects/booch95/) have
always required users to provide storage pools (except for Bounded
forms). I expect that most people who use(d) the BCs use(d) the one
provided, which is a wrapper for the system storage pool.

However, while developing code on Windows for use in VxWorks, we found
that the Windows allocator would zero-fill, while the VxWorks allocator
did no initialization (which is perfectly legal, of course). The result
was that uninitialized record components would appear to work on Windows
and crash mysteriously on the target.

What we did to work round this (which was before GNAT offered pragma
Initialize_Scalars and -gnatV) was to provide a specialised storage pool
which fills requested memory with 16#deadbeef#; so any uninitialized
fields are (a) reasonably unlikely to correspond to reasonable values,
(b) reasonably easy to spot in a store dump, (c) wrong on either OS.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (4 preceding siblings ...)
  2011-01-22 15:13 ` Simon Wright
@ 2011-01-22 22:17 ` Fritz Wuehler
  2011-01-24  9:52   ` Yannick Duchêne (Hibou57)
  2011-01-24  9:25 ` Ludovic Brenta
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 39+ messages in thread
From: Fritz Wuehler @ 2011-01-22 22:17 UTC (permalink / raw)


> Ada has provision for user defined storage pool, that is, an application
> may have a (or multiple) custom implementation of a heap or like for any
> kind of object. 
>

snip

> I don't feel to remember I ever see a single Ada source with some use of
> this. Is this just an not enough known feature, or does it mean there is
> not so much benefit to use it ? Or else, may be this could be beneficial
> but no one never go up to there (no evaluation of this option, or anything
> else) ? 

I wonder if this is related to the MVS concept of storage pools and was
exposed in Ada? I don't have an Ada compiler for MVS (although I would
gladly accept a free one!) so I can't confirm this.

If anybody knows for sure, I can give a little background on the MVS feature, if
it would be interesting to anybody. Otherwise what I know is probably not
relevant.




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (5 preceding siblings ...)
  2011-01-22 22:17 ` Fritz Wuehler
@ 2011-01-24  9:25 ` Ludovic Brenta
  2011-01-24  9:43   ` Yannick Duchêne (Hibou57)
  2011-01-24 11:46 ` Jacob Sparre Andersen
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 39+ messages in thread
From: Ludovic Brenta @ 2011-01-24  9:25 UTC (permalink / raw)


Yannick Duchêne wrote on comp.lang.ada:
> I don't feel to remember I ever see a single Ada source with some use of  
> [storage pools]. Is this just an not enough known feature, or does it mean there is  
> not so much benefit to use it ?

At Eurocontrol, we use two custom storage pools besides the default
one.

We have a "No-Dealloc" storage pool that raises an exception if the
software attempts to deallocate from it. More importantly, this pool
works in two modes: initially it accepts allocation and writing of new
objects in the pool (but, of course, no deallocation), then it
switches to read-only mode by calling mprotect(2) on all memory pages.
Any subsequent attempt to alter data in this pool will crash the
program.  We use this pool to parse a large database of immutable
objects into memory; objects have lots of access values referencing
one another, so we have to be able to alter references while parsing.
We switch to read-only mode when the parsing is complete.

The other custom storage pool we use is to detect memory leaks. We do
that by preprocessing our sources when building in a special leak-
detection mode.

--
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24  9:25 ` Ludovic Brenta
@ 2011-01-24  9:43   ` Yannick Duchêne (Hibou57)
  2011-01-24 13:43     ` Emmanuel Briot
  0 siblings, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24  9:43 UTC (permalink / raw)


Le Mon, 24 Jan 2011 10:25:29 +0100, Ludovic Brenta  
<ludovic@ludovic-brenta.org> a écrit:
> We have a "No-Dealloc" storage pool that raises an exception if the
> software attempts to deallocate from it.
I like this one, though about the same (there are many case where  
deallocation does not occur until end of program).

> More importantly, this pool
> works in two modes: initially it accepts allocation and writing of new
> objects in the pool (but, of course, no deallocation), then it
> switches to read-only mode by calling mprotect(2) on all memory pages.
Clever, will keep this idea in mind.

> The other custom storage pool we use is to detect memory leaks. We do
> that by preprocessing our sources when building in a special leak-
> detection mode.
You did not said enough :)

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22 22:17 ` Fritz Wuehler
@ 2011-01-24  9:52   ` Yannick Duchêne (Hibou57)
  2011-01-24 14:20     ` Bill Findlay
  0 siblings, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24  9:52 UTC (permalink / raw)


Le Sat, 22 Jan 2011 23:17:49 +0100, Fritz Wuehler  
<fritz@spamexpire-201101.rodent.frell.theremailer.net> a écrit:
> I wonder if this is related to the MVS concept of storage pools and was
> exposed in Ada?
Even old DOS had a kind of storage pool (with EMM386) ;)

To be serious, I do not know if Ada get it from MVS.

> I don't have an Ada compiler for MVS (although I would
> gladly accept a free one!) so I can't confirm this.
>
> If anybody knows for sure, I can give a little background on the MVS  
> feature, if
> it would be interesting to anybody. Otherwise what I know is probably not
> relevant.
Until you do not say more, cannot know if it's relevant or not.

How was this used ?


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22 15:13 ` Simon Wright
@ 2011-01-24  9:56   ` Yannick Duchêne (Hibou57)
  2011-01-24 16:09     ` Simon Wright
  2011-01-24 23:58   ` Yannick Duchêne (Hibou57)
  1 sibling, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24  9:56 UTC (permalink / raw)


Le Sat, 22 Jan 2011 16:13:40 +0100, Simon Wright <simon@pushface.org> a  
écrit:

> "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr> writes:
>
>> I don't feel to remember I ever see a single Ada source with some use
>> of this. Is this just an not enough known feature, or does it mean
>> there is not so much benefit to use it ? Or else, may be this could be
>> beneficial but no one never go up to there (no evaluation of this
>> option, or anything else) ?
>
> The Booch Components (https://sourceforge.net/projects/booch95/) have
> always required users to provide storage pools
*Required* That's interesting (currently downloading from the link you  
gave).

> However, while developing code on Windows for use in VxWorks, we found
> that the Windows allocator would zero-fill, while the VxWorks allocator
> did no initialization (which is perfectly legal, of course). The result
> was that uninitialized record components would appear to work on Windows
> and crash mysteriously on the target.
>
> What we did to work round this (which was before GNAT offered pragma
> Initialize_Scalars and -gnatV) was to provide a specialised storage pool
> which fills requested memory with 16#deadbeef#; so any uninitialized
> fields are (a) reasonably unlikely to correspond to reasonable values,
> (b) reasonably easy to spot in a store dump, (c) wrong on either OS.
This looks like a bit what Ludovic exposed. This is some use of storage  
pool for security purpose. So these are at least two examples of storage  
pool used for something else than just for allocation strategy.

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  9:54 ` User Defined Storage Pool : did you ever experiment with it ? AdaMagica
@ 2011-01-24  9:57   ` Yannick Duchêne (Hibou57)
  2011-01-24 10:48   ` Mark Lorenzen
  1 sibling, 0 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24  9:57 UTC (permalink / raw)


Le Sat, 22 Jan 2011 10:54:01 +0100, AdaMagica  
<christoph.grein@eurocopter.com> a écrit:

> We use storage pools on a helicopter flight simulator. All global
> objects are elements of one storage pool. Thus we can take snapshots
> of a current state by simply storing away the pool contents. Later, by
> restoring the pool contents, a previous situation, e.g. where a pilot
> did not perform correctly, can be restored and the pilot can try to do
> better.
This snap-shot could not be made another way ? Ex. deep copy or object  
network ? Is this way used for efficiency or ease of implementation ?

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  9:54 ` User Defined Storage Pool : did you ever experiment with it ? AdaMagica
  2011-01-24  9:57   ` Yannick Duchêne (Hibou57)
@ 2011-01-24 10:48   ` Mark Lorenzen
  1 sibling, 0 replies; 39+ messages in thread
From: Mark Lorenzen @ 2011-01-24 10:48 UTC (permalink / raw)


On 22 Jan., 10:54, AdaMagica <christoph.gr...@eurocopter.com> wrote:
> We use storage pools on a helicopter flight simulator. All global
> objects are elements of one storage pool. Thus we can take snapshots
> of a current state by simply storing away the pool contents. Later, by
> restoring the pool contents, a previous situation, e.g. where a pilot
> did not perform correctly, can be restored and the pilot can try to do
> better.

This is a very interesting use of storage pools!



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (6 preceding siblings ...)
  2011-01-24  9:25 ` Ludovic Brenta
@ 2011-01-24 11:46 ` Jacob Sparre Andersen
  2011-01-24 23:51   ` Yannick Duchêne (Hibou57)
  2011-01-24 14:04 ` Timo Warns
  2011-01-26 20:13 ` Warren
  9 siblings, 1 reply; 39+ messages in thread
From: Jacob Sparre Andersen @ 2011-01-24 11:46 UTC (permalink / raw)


Yannick Duch�ne wrote:

> I don't feel to remember I ever see a single Ada source with some use
> of this. Is this just an not enough known feature, or does it mean
> there is not so much benefit to use it ? Or else, may be this could be
> beneficial but no one never go up to there (no evaluation of this
> option, or anything else) ?

I use storage pools to implement persistent objects.  I presented a
paper on the subject at Ada Europe 2010.  There is some demonstration
source code at <http://www.jacob-sparre.dk/persistence/>.

My technique is depends on a well-behaved memory mapping implementation
from your operating system.  Especially memory layout randomization
makes things more tricky than I like.

Jacob
--
Jacob Sparre Andersen Research & Innovation
Vesterbrogade 148K, 1. th.
1620 K�benhavn V
Danmark

Phone:    +45 21 49 08 04
E-mail:   jacob@jacob-sparre.dk
Web-site: http://www.jacob-sparre.dk/



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24  9:43   ` Yannick Duchêne (Hibou57)
@ 2011-01-24 13:43     ` Emmanuel Briot
  2011-01-24 16:48       ` Dirk Craeynest
  0 siblings, 1 reply; 39+ messages in thread
From: Emmanuel Briot @ 2011-01-24 13:43 UTC (permalink / raw)


On Jan 24, 10:43 am, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> > The other custom storage pool we use is to detect memory leaks. We do
> > that by preprocessing our sources when building in a special leak-
> > detection mode.
>
> You did not said enough :)


See the package GNAT.Debug_Pools and its documentation for more
information.

Emmanuel



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (7 preceding siblings ...)
  2011-01-24 11:46 ` Jacob Sparre Andersen
@ 2011-01-24 14:04 ` Timo Warns
  2011-01-24 23:34   ` Yannick Duchêne (Hibou57)
  2011-01-26 20:13 ` Warren
  9 siblings, 1 reply; 39+ messages in thread
From: Timo Warns @ 2011-01-24 14:04 UTC (permalink / raw)


As an example, Ada Gem #77 (http://www.adacore.com/2010/01/11/gem-77/) shows
how to use the GNAT debug storage pool for analyzing the memory usage of a
program.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24  9:52   ` Yannick Duchêne (Hibou57)
@ 2011-01-24 14:20     ` Bill Findlay
  0 siblings, 0 replies; 39+ messages in thread
From: Bill Findlay @ 2011-01-24 14:20 UTC (permalink / raw)


On 24/01/2011 09:52, in article op.vps4c0jsule2fv@garhos, "Yannick Duch�ne
(Hibou57)" <yannick_duchene@yahoo.fr> wrote:

> Le Sat, 22 Jan 2011 23:17:49 +0100, Fritz Wuehler
> <fritz@spamexpire-201101.rodent.frell.theremailer.net> a �crit:
>> I wonder if this is related to the MVS concept of storage pools and was
>> exposed in Ada?
> Even old DOS had a kind of storage pool (with EMM386) ;)
> 
> To be serious, I do not know if Ada get it from MVS.

The original (Acta Informatica, 1971) Pascal had simple storage pools,
called "classes" by Wirth, so the concept should have been well-known to
proto-Adafolk.

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;





^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24  9:56   ` Yannick Duchêne (Hibou57)
@ 2011-01-24 16:09     ` Simon Wright
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Wright @ 2011-01-24 16:09 UTC (permalink / raw)


"Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr> writes:

> Le Sat, 22 Jan 2011 16:13:40 +0100, Simon Wright <simon@pushface.org>
> a écrit:
>
>> The Booch Components (https://sourceforge.net/projects/booch95/) have
>> always required users to provide storage pools

> *Required* That's interesting (currently downloading from the link you
> gave).

The rationale, such as it is, is pretty much lifted from the C++ BCs;
http://booch95.sourceforge.net/documentation.html#storage

I got a lot of complaints about the need for multiple levels of
instantiation, lack of support for indefinite types, need for storage
pools which I resisted on the grounds that the BCs were a
translation. In 2005 Martin Krischik added support for indefinite types
for some containers, and I have been toying with removing the need for
storage pools (by providing BC.Indefinite_Unmanaged_Containers, see
http://booch95.svn.sourceforge.net/viewvc/booch95/trunk/src/ about 2/3
of the way down).

Of course nowadays you'd use Ada.Containers, but there are still people
using Ada95 out there...



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 13:43     ` Emmanuel Briot
@ 2011-01-24 16:48       ` Dirk Craeynest
  2011-01-25  1:16         ` Yannick Duchêne (Hibou57)
  0 siblings, 1 reply; 39+ messages in thread
From: Dirk Craeynest @ 2011-01-24 16:48 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

In article <8e3c0ff0-a96d-41e9-9549-6600786e2af4@v17g2000vbo.googlegroups.com>,
Emmanuel Briot  <briot.emmanuel@gmail.com> wrote:
>On Jan 24, 10:43�am, Yannick Duch�ne (Hibou57)
><yannick_duch...@yahoo.fr> wrote:
>> You did not said enough :)
>
>See the package GNAT.Debug_Pools and its documentation for more
>information.
>
>Emmanuel

For a paper co-authored by AdaCore and Eurocontrol
about the introduction of that package, see:
<http://www.cs.kuleuven.be/~dirk/papers/ae03cfmu-paper.pdf>

It is titled "Exposing Memory Corruption and Finding Leaks: Advanced
Mechanisms in Ada" and was presented at the Ada-Europe 2003 conference.

HTH

Dirk
Dirk.Craeynest@cs.kuleuven.be (for Ada-Belgium/-Europe/SIGAda/WG9 mail)

*** 16th Intl.Conf.on Reliable Software Technologies - Ada-Europe'2011
*** June 20-24, 2011 **** Edinburgh, UK **** http://www.ada-europe.org



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 14:04 ` Timo Warns
@ 2011-01-24 23:34   ` Yannick Duchêne (Hibou57)
  2011-01-25  0:14     ` Yannick Duchêne (Hibou57)
  0 siblings, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24 23:34 UTC (permalink / raw)


Le Mon, 24 Jan 2011 15:04:30 +0100, Timo Warns  
<Timo.Warns@informatik.uni-oldenburg.de> a écrit:

> As an example, Ada Gem #77 (http://www.adacore.com/2010/01/11/gem-77/)  
> shows
> how to use the GNAT debug storage pool for analyzing the memory usage of  
> a
> program.

 From the above link:
> with My_Package;
> with Ada.Unchecked_Deallocation;
> procedure Main is
>    procedure Unchecked_Free is
>       new Ada.Unchecked_Deallocation (Integer, Integer_Access);
>    Ptr : Integer_Access;
Seems either a use My_Package or a “My_Package.” prefix is missing in the  
declaration of Ptr.

 From the same link:
> GNAT.Debug_Pools can also give false warnings when
> dereferencing a pointer to aliased data on the stack
> (which was never allocated via a “new” operator, but was
> accessed via an ‘Access attribute).
How can a storage pool catch dereferencing ?

I skipped part II and III which are GNAT or vendor specifics by essence.

Thanks for that pointer.

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 11:46 ` Jacob Sparre Andersen
@ 2011-01-24 23:51   ` Yannick Duchêne (Hibou57)
  2011-02-10  7:59     ` Jacob Sparre Andersen
  0 siblings, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24 23:51 UTC (permalink / raw)


Le Mon, 24 Jan 2011 12:46:53 +0100, Jacob Sparre Andersen  
<jacob@jacob-sparre.dk> a écrit:
> I use storage pools to implement persistent objects.  I presented a
> paper on the subject at Ada Europe 2010.  There is some demonstration
> source code at <http://www.jacob-sparre.dk/persistence/>.
>
> My technique is depends on a well-behaved memory mapping implementation
> from your operating system.  Especially memory layout randomization
> makes things more tricky than I like.
Jacob, do you know a link to that paper ? I just had a look at the source,  
but unfortunately it lacks any comments (may still come back to this one  
later). It makes use of POSIX package which I do not know, but this should  
not a problem.

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22 15:13 ` Simon Wright
  2011-01-24  9:56   ` Yannick Duchêne (Hibou57)
@ 2011-01-24 23:58   ` Yannick Duchêne (Hibou57)
  1 sibling, 0 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-24 23:58 UTC (permalink / raw)


Le Sat, 22 Jan 2011 16:13:40 +0100, Simon Wright <simon@pushface.org> a  
écrit:
> The Booch Components (https://sourceforge.net/projects/booch95/) have
> always required users to provide storage pools (except for Bounded
> forms). I expect that most people who use(d) the BCs use(d) the one
> provided, which is a wrapper for the system storage pool.
I had a look at that one too, rather big and will requires some time to  
study (I feel Booch Components are a kind of standard, although I do not  
know these, so they may be some abstract papers to help understand).  
Anyway, I enjoyed the style: well commented, and interestingly far more  
commented in specifications than in bodies ;) And the overall style is  
mostly well readable. Will keep this one at least for that purpose.

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 23:34   ` Yannick Duchêne (Hibou57)
@ 2011-01-25  0:14     ` Yannick Duchêne (Hibou57)
  2011-01-25  1:36       ` Randy Brukardt
  0 siblings, 1 reply; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-25  0:14 UTC (permalink / raw)


Le Tue, 25 Jan 2011 00:34:34 +0100, Yannick Duchêne (Hibou57)  
<yannick_duchene@yahoo.fr> a écrit:
>> GNAT.Debug_Pools can also give false warnings when
>> dereferencing a pointer to aliased data on the stack
>> (which was never allocated via a “new” operator, but was
>> accessed via an ‘Access attribute).
> How can a storage pool catch dereferencing ?
OK, I found. This is GNAT specific. I am currently reading a paper whose  
link to was posted by Dick Creanest (in this same thread), and it says:

> Because storage pools provide no means to check dereferences,
> GNAT offers a special type of storage pool, called a
> “checked pool”, with an additional abstract primitive
> operation called Dereference.
That's an interesting feature indeed, but not standard. How many Ada  
compiler vendors provides a similar feature ?

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 16:48       ` Dirk Craeynest
@ 2011-01-25  1:16         ` Yannick Duchêne (Hibou57)
  0 siblings, 0 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-01-25  1:16 UTC (permalink / raw)


Le Mon, 24 Jan 2011 17:48:24 +0100, Dirk Craeynest  
<dirk@vana.cs.kuleuven.be.> a écrit:
> For a paper co-authored by AdaCore and Eurocontrol
> about the introduction of that package, see:
> <http://www.cs.kuleuven.be/~dirk/papers/ae03cfmu-paper.pdf>

Here is an interesting tip from that paper (about checking dereferencing):

> 4.2 Data Structures
> The debug pool will respect all alignments specified in the user
> code by aligning all objects using the maximum machine alignment.
> This limits the performance impact of using the debug pool and,
> as we will show below, allows to quickly compute the validity of
> a memory reference.
(on page 135)

-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-25  0:14     ` Yannick Duchêne (Hibou57)
@ 2011-01-25  1:36       ` Randy Brukardt
  2011-02-06 20:05         ` Yannick Duchêne (Hibou57)
  0 siblings, 1 reply; 39+ messages in thread
From: Randy Brukardt @ 2011-01-25  1:36 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

"Yannick Duch�ne (Hibou57)" <yannick_duchene@yahoo.fr> wrote in message 
news:op.vpt8agtdule2fv@garhos...
Le Tue, 25 Jan 2011 00:34:34 +0100, Yannick Duch�ne (Hibou57)
<yannick_duchene@yahoo.fr> a �crit:
>> Because storage pools provide no means to check dereferences,
>> GNAT offers a special type of storage pool, called a
>> "checked pool", with an additional abstract primitive
>> operation called Dereference.
>That's an interesting feature indeed, but not standard. How many Ada 
>compiler vendors provides a similar feature ?

Can't answer that, but we did consider adding such a feature to Ada 2012. 
Eventually we decided on a more general purpose user-defined dereferencing 
capability instead.

                          Randy.





^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
                   ` (8 preceding siblings ...)
  2011-01-24 14:04 ` Timo Warns
@ 2011-01-26 20:13 ` Warren
  9 siblings, 0 replies; 39+ messages in thread
From: Warren @ 2011-01-26 20:13 UTC (permalink / raw)


=?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?=
expounded in news:op.vpont3pqule2fv@garhos: 

> Ada has provision for user defined storage pool, that is,
> an application  may have a (or multiple) custom
> implementation of a heap or like for any  kind of object.
> http://www.ida.liu.se/edu/ugrad/progkon/Ada/ada-doc/LRM95/rm
> 95html/rm9x-13-11.html (from an uknown site, AdaIC server
> seems down today) 
..

It can be useful when you want to preallocate a maximum amount 
of allocatable memory to a class of (by usage) objects. 
Emulator or simulators use this for safety. This avoids an 
errant emulation from allocating all of user memory and 
trashing the emulator's own environment by thrashing/swapping 
all available user memory.

Another useful application is permitting objects of a 
particular class (of use) to be allocated from a pool. Then at 
a clearly defined point in the code, _all_ of those objects 
can be efficiently released by freeing the entire pool. No 
list traversal (or list maintenance) is required.

Warren




^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-25  1:36       ` Randy Brukardt
@ 2011-02-06 20:05         ` Yannick Duchêne (Hibou57)
  2011-02-07 22:09           ` Randy Brukardt
  2011-02-07 22:18           ` Randy Brukardt
  0 siblings, 2 replies; 39+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2011-02-06 20:05 UTC (permalink / raw)


Le Tue, 25 Jan 2011 02:36:27 +0100, Randy Brukardt <randy@rrsoftware.com>  
a écrit:
> Can't answer that, but we did consider adding such a feature to Ada 2012.
> Eventually we decided on a more general purpose user-defined  
> dereferencing
> capability instead.
You mean this is already part of the actual or next to come Ada 2012 ?


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.

“I am fluent in ASCII” [Warren 2010]



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-06 20:05         ` Yannick Duchêne (Hibou57)
@ 2011-02-07 22:09           ` Randy Brukardt
  2011-02-07 22:18           ` Randy Brukardt
  1 sibling, 0 replies; 39+ messages in thread
From: Randy Brukardt @ 2011-02-07 22:09 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 579 bytes --]


"Yannick Duch�ne (Hibou57)" <yannick_duchene@yahoo.fr> wrote in message 
news:op.vqhzfuuyule2fv@garhos...
Le Tue, 25 Jan 2011 02:36:27 +0100, Randy Brukardt <randy@rrsoftware.com>
a �crit:
> Can't answer that, but we did consider adding such a feature to Ada 2012.
> Eventually we decided on a more general purpose user-defined 
> dereferencing
> capability instead.
You mean this is already part of the actual or next to come Ada 2012 ?


-- 
Si les chats miaulent et font autant de vocalises bizarres, c'est pas pour
les chiens.

"I am fluent in ASCII" [Warren 2010] 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-06 20:05         ` Yannick Duchêne (Hibou57)
  2011-02-07 22:09           ` Randy Brukardt
@ 2011-02-07 22:18           ` Randy Brukardt
  2011-02-07 22:59             ` Maciej Sobczak
  2011-02-08  9:08             ` Alex R. Mosteo
  1 sibling, 2 replies; 39+ messages in thread
From: Randy Brukardt @ 2011-02-07 22:18 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2230 bytes --]

"Yannick Duch�ne (Hibou57)" <yannick_duchene@yahoo.fr> wrote in message 
news:op.vqhzfuuyule2fv@garhos...
>Le Tue, 25 Jan 2011 02:36:27 +0100, Randy Brukardt <randy@rrsoftware.com> 
>a �crit:
>> Can't answer that, but we did consider adding such a feature to Ada 2012.
>> Eventually we decided on a more general purpose user-defined 
>> dereferencing
>> capability instead.

>You mean this is already part of the actual or next to come Ada 2012 ?

We expect it to be, although it isn't finished and it will have to be 
finished by the end of this month (as with all work on Ada 2012) in order to 
be included.

See AI05-0139-2. The "Reference" aspect combines with access discriminants 
and controlled types to give effectively a user-defined dereferencing 
mechanism.

The primary problem with user-defined dereferencing is controlling the 
lifetime of the returned access value -- we don't want it copied outside of 
the control of the underlying container abstraction. In addition, it is 
important that the container be able to get control twice: once when the 
dereference is created, and once when it is destroyed. The latter is needed 
in cases of persistence or other kinds of locking. (In the case of 
persistence, the object must be available in memory so long as a reference 
to it is valid, but it can be pushed back to the backing store once the 
references are all gone. Another example is a the tampering check of the Ada 
containers, which prevent the object of the reference from disappearing 
while the reference exists.)

It turns out that the mechanism needed already exists in the language, in 
the form of access discriminants. In addition, the object containing the 
access discriminant can be controlled, thus giving control upon destruction 
of the object (and the reference). So the only problem is the terrible 
syntax of such a dereference. The Reference aspect allows us to eliminate 
that.

Combined with the indexing aspect, you'll be able to write something like:

     Foo(1).Bar := 10;

For a vector container Foo whose elements are a record type with a component 
Bar. And even:

    Text_Map ("Ada").Count := 1;

For an indefinite map.

                                       Randy.








^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-07 22:18           ` Randy Brukardt
@ 2011-02-07 22:59             ` Maciej Sobczak
  2011-02-07 23:57               ` Shark8
  2011-02-10  2:08               ` Randy Brukardt
  2011-02-08  9:08             ` Alex R. Mosteo
  1 sibling, 2 replies; 39+ messages in thread
From: Maciej Sobczak @ 2011-02-07 22:59 UTC (permalink / raw)


On Feb 7, 11:18 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:

> Combined with the indexing aspect, you'll be able to write something like:
>
>      Foo(1).Bar := 10;
>
> For a vector container Foo whose elements are a record type with a component
> Bar. And even:
>
>     Text_Map ("Ada").Count := 1;
>
> For an indefinite map.

Great!

But then - will this be implementable in a way that is simple enough
to allow reasonable inlining [*]? Remember that this feature will be
inevitably compared to C++. If Ada gets the performance part right,
this feature will sell very well.

[*] For the sake of comparison, the passive iterator idiom that is
currently used with containers is not inline-friendly.

--
Maciej Sobczak * http://www.inspirel.com



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-07 22:59             ` Maciej Sobczak
@ 2011-02-07 23:57               ` Shark8
  2011-02-08 13:40                 ` Maciej Sobczak
  2011-02-10  2:08               ` Randy Brukardt
  1 sibling, 1 reply; 39+ messages in thread
From: Shark8 @ 2011-02-07 23:57 UTC (permalink / raw)


On Feb 7, 3:59 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
>
> [*] For the sake of comparison, the passive iterator idiom that is
> currently used with containers is not inline-friendly.


Why do you say that?
I personally don't mind doing something like:
Declare
  Procedure Iterate ( Position : In Cursor ) is
   begin
     --- Implementation.
   end iterate;
Begin
  Container.Iterate( Iterate'Access );
End;

as the scope for Iterate is perfectly contained to where I want to
apply the procedure; and even if that scope is too limited [say it's a
commonly used iteration] I could move it into the library's scope.



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-07 22:18           ` Randy Brukardt
  2011-02-07 22:59             ` Maciej Sobczak
@ 2011-02-08  9:08             ` Alex R. Mosteo
  1 sibling, 0 replies; 39+ messages in thread
From: Alex R. Mosteo @ 2011-02-08  9:08 UTC (permalink / raw)


Randy Brukardt wrote:

> Combined with the indexing aspect, you'll be able to write something like:
> 
>      Foo(1).Bar := 10;
> 
> For a vector container Foo whose elements are a record type with a
> component Bar. And even:
> 
>     Text_Map ("Ada").Count := 1;
> 
> For an indefinite map.

Mewants to cry in happiness...



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-07 23:57               ` Shark8
@ 2011-02-08 13:40                 ` Maciej Sobczak
  0 siblings, 0 replies; 39+ messages in thread
From: Maciej Sobczak @ 2011-02-08 13:40 UTC (permalink / raw)


On Feb 8, 12:57 am, Shark8 <onewingedsh...@gmail.com> wrote:

> > [*] For the sake of comparison, the passive iterator idiom that is
> > currently used with containers is not inline-friendly.
>
> Why do you say that?
> I personally don't mind doing something like:
> Declare
>   Procedure Iterate ( Position : In Cursor ) is
>    begin
>      --- Implementation.
>    end iterate;
> Begin
>   Container.Iterate( Iterate'Access );
> End;

I don't mind to do that, either.

> as the scope for Iterate is perfectly contained to where I want to
> apply the procedure;

Yes, but my point was not about how do I, as a programmer, perceive
this additional procedure, but how the compiler copes with indirect
calls via access value. It looks like this is too much for the
compiler to do full inlining of the above, which can hit the
performance considerably, especially when your local procedure itself
is lightweight, which is frequently the case.

--
Maciej Sobczak * http://www.inspirel.com



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-07 22:59             ` Maciej Sobczak
  2011-02-07 23:57               ` Shark8
@ 2011-02-10  2:08               ` Randy Brukardt
  1 sibling, 0 replies; 39+ messages in thread
From: Randy Brukardt @ 2011-02-10  2:08 UTC (permalink / raw)


"Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:b1904d91-bdb3-4ab6-ac17-7a43d0a0de58@8g2000prt.googlegroups.com...
On Feb 7, 11:18 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
...
>But then - will this be implementable in a way that is simple enough
>to allow reasonable inlining [*]? Remember that this feature will be
>inevitably compared to C++. If Ada gets the performance part right,
>this feature will sell very well.

That depends on the implementation, I think. I doubt that early ones will be 
that great, but I expect it to get better over time.

>[*] For the sake of comparison, the passive iterator idiom that is
>currently used with containers is not inline-friendly.

Maybe, but you'd never write one of those in Ada 2012 anyway. You'd instead 
write:

    for E of My_Container loop
        <do whatever with E>
    end loop;

Here again, I expect early implementations to be an exact translation to the 
"canonical" code (probably not that wonderful), but later versions most 
likely will be better.

                            Randy.


--
Maciej Sobczak * http://www.inspirel.com 





^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-01-24 23:51   ` Yannick Duchêne (Hibou57)
@ 2011-02-10  7:59     ` Jacob Sparre Andersen
  2011-02-13 15:56       ` AdaMagica
  0 siblings, 1 reply; 39+ messages in thread
From: Jacob Sparre Andersen @ 2011-02-10  7:59 UTC (permalink / raw)


Yannick Duch�ne wrote:
> Le Mon, 24 Jan 2011 12:46:53 +0100, Jacob Sparre Andersen
> <jacob@jacob-sparre.dk> a �crit:

>> I use storage pools to implement persistent objects.  I presented a
>> paper on the subject at Ada Europe 2010.  There is some demonstration
>> source code at <http://www.jacob-sparre.dk/persistence/>.

> Jacob, do you know a link to that paper ?

I've updated the web-page with a link to the paper.

> I just had a look at the source, but unfortunately it lacks any
> comments

IMHO source code shouldn't contain/need comments.  Comments are not
checkable by the compiler, and thus (potentially) misleading.

> It makes use of POSIX package which I do not know, but this should not
> a problem.

On Debian and Ubuntu systems it is hidden in a libflorist* package.

Jacob
-- 
Adlai Stevenson said it all when, at an event during the
1956 Presidential campaign, a woman shouted, "You have the
vote of every thinking person!" Stevenson shouted back,
"That's not enough, madam, we need a majority!"



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-10  7:59     ` Jacob Sparre Andersen
@ 2011-02-13 15:56       ` AdaMagica
  2011-02-13 19:10         ` Simon Clubley
  0 siblings, 1 reply; 39+ messages in thread
From: AdaMagica @ 2011-02-13 15:56 UTC (permalink / raw)


On 10 Feb., 08:59, Jacob Sparre Andersen <spa...@nbi.dk> wrote:
> Yannick Duch ne wrote:
> > I just had a look at the source, but unfortunately it lacks any
> > comments
>
> IMHO source code shouldn't contain/need comments.  Comments are not
> checkable by the compiler, and thus (potentially) misleading.

Ouch, that hurts :-(



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: User Defined Storage Pool : did you ever experiment with it ?
  2011-02-13 15:56       ` AdaMagica
@ 2011-02-13 19:10         ` Simon Clubley
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Clubley @ 2011-02-13 19:10 UTC (permalink / raw)


On 2011-02-13, AdaMagica <christoph.grein@eurocopter.com> wrote:
> On 10 Feb., 08:59, Jacob Sparre Andersen <spa...@nbi.dk> wrote:
>> Yannick Duch ne wrote:
>> > I just had a look at the source, but unfortunately it lacks any
>> > comments
>>
>> IMHO source code shouldn't contain/need comments. �Comments are not
>> checkable by the compiler, and thus (potentially) misleading.
>
> Ouch, that hurts :-(

I agree that code should be commented - provided that developers remember
that the code tells you _what_ the program does and the comments should
tell you _why_ it does it.

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world



^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2011-02-13 19:10 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-22  0:04 User Defined Storage Pool : did you ever experiment with it ? Yannick Duchêne (Hibou57)
2011-01-22  0:55 ` Adam Beneschan
2011-01-22  1:42   ` Yannick Duchêne (Hibou57)
2011-01-22  5:19   ` Randy Brukardt
2011-01-22  8:49 ` Dmitry A. Kazakov
2011-01-22  9:47 ` User Defined Storage Pool : Example anon
2011-01-22  9:54 ` User Defined Storage Pool : did you ever experiment with it ? AdaMagica
2011-01-24  9:57   ` Yannick Duchêne (Hibou57)
2011-01-24 10:48   ` Mark Lorenzen
2011-01-22 15:13 ` Simon Wright
2011-01-24  9:56   ` Yannick Duchêne (Hibou57)
2011-01-24 16:09     ` Simon Wright
2011-01-24 23:58   ` Yannick Duchêne (Hibou57)
2011-01-22 22:17 ` Fritz Wuehler
2011-01-24  9:52   ` Yannick Duchêne (Hibou57)
2011-01-24 14:20     ` Bill Findlay
2011-01-24  9:25 ` Ludovic Brenta
2011-01-24  9:43   ` Yannick Duchêne (Hibou57)
2011-01-24 13:43     ` Emmanuel Briot
2011-01-24 16:48       ` Dirk Craeynest
2011-01-25  1:16         ` Yannick Duchêne (Hibou57)
2011-01-24 11:46 ` Jacob Sparre Andersen
2011-01-24 23:51   ` Yannick Duchêne (Hibou57)
2011-02-10  7:59     ` Jacob Sparre Andersen
2011-02-13 15:56       ` AdaMagica
2011-02-13 19:10         ` Simon Clubley
2011-01-24 14:04 ` Timo Warns
2011-01-24 23:34   ` Yannick Duchêne (Hibou57)
2011-01-25  0:14     ` Yannick Duchêne (Hibou57)
2011-01-25  1:36       ` Randy Brukardt
2011-02-06 20:05         ` Yannick Duchêne (Hibou57)
2011-02-07 22:09           ` Randy Brukardt
2011-02-07 22:18           ` Randy Brukardt
2011-02-07 22:59             ` Maciej Sobczak
2011-02-07 23:57               ` Shark8
2011-02-08 13:40                 ` Maciej Sobczak
2011-02-10  2:08               ` Randy Brukardt
2011-02-08  9:08             ` Alex R. Mosteo
2011-01-26 20:13 ` Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox