comp.lang.ada
 help / color / mirror / Atom feed
* Problems with dynamic allocation in tasks
@ 2007-07-25 16:11 ldb
  2007-07-25 16:45 ` Robert A Duff
  2007-07-26 20:56 ` Simon Wright
  0 siblings, 2 replies; 6+ messages in thread
From: ldb @ 2007-07-25 16:11 UTC (permalink / raw)


I have a piece of code that runs great under linux using GNAT and
terrible under Windows also using GNAT. The code makes ample use of
dynamic allocation and threads.

I've tracked the problem down to simple memory allocation. Under
windows, it appears to me that the 'new' operator and the unchecked-
decallocate operations are using a task lock that is totally jamming
the system. A single threaded version of the windows code runs faster
than the dual-threaded version (on linux, I get a speed-up of a factor
close to 2). The sad fact is 99+% of the these allocations are local
and do not need to be shared across tasks. Ideally, i'd be able to
create a task-local memory pool that doesn't require a mutex for these
allocations.. not sure how feasible this is in Ada, though.

The obvious solution is to remove or minimize dynamic allocations but
I fear this isn't really practical. If it comes to this, so be it, but
I'd rather exhaust the other options first.

The other option is to replace the allocator with one of my own (or
someone elses), which brings me to my question: how! What I'd really
like to do is make a library that lets me replace the global allocator
a la libgmem. I struggled through the source code and makefiles of
GNAT and failed miserably in replicated it's function.

In a nut shell, what I want to be able to do is take System.Memory,
copy it, change a line of code (Put_Line("hello world")), and then be
able to replace the global allocator with this one. I was able to get
a replacement body for System.Memory to build with the gnatg flag, and
was able to get an o file, but whenever i make a simple test program
it automatically wants to put the original System.Memory in and I get
duplicate units if I try to bind them.

If anyone knows a more elegant solution to the actual problem, or has
any other advice, I'd love to hear it.




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

end of thread, other threads:[~2007-07-26 20:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25 16:11 Problems with dynamic allocation in tasks ldb
2007-07-25 16:45 ` Robert A Duff
2007-07-25 17:04   ` ldb
2007-07-25 17:25     ` Robert A Duff
2007-07-25 18:35     ` Dmitry A. Kazakov
2007-07-26 20:56 ` Simon Wright

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