Browse thread
enter_blocking_section() and string modifications
-
Reed Wilson
-
Jacques Garrigue
-
Reed Wilson
- Romain Beauxis
-
Reed Wilson
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Romain Beauxis <toots@r...> |
| Subject: | Re: [Caml-list] enter_blocking_section() and string modifications |
Le Wednesday 02 April 2008 05:26:27 Reed Wilson, vous avez écrit :
> > Here is a snippet from ml_gpointer.c, in lablgtk, which copies an
> > abstract block to the old heap when it is young. Such a block is then
> > stable as long as there is no compaction.
> >
> > CAMLprim value ml_stable_copy (value v)
> > {
> > Â Â if (Is_block(v) && (char*)(v) < young_end && (char*)(v) >
> > young_start) {
> > Â Â Â Â CAMLparam1(v);
> > Â Â Â Â mlsize_t i, wosize = Wosize_val(v);
> > Â Â Â Â int tag = Tag_val(v);
> > Â Â Â Â value ret;
> > Â Â Â Â if (tag < No_scan_tag) invalid_argument("ml_stable_copy");
> > Â Â Â Â ret = alloc_shr (wosize, tag);
> > Â Â Â Â for (i=0; i < wosize; i++) Field(ret,i) = Field(v,i);
> > Â Â Â Â CAMLreturn(ret);
> > Â Â }
> > Â Â return v;
> > }
> >
> > Jacques Garrigue
>
> Thanks! That's exactly what I needed to know. All of my strings are
> around 8MB, so they'll all be allocated directly on the old heap. I'll
> test to see how much memory is used up by disabling compaction.
>
> And in this case, the concurrency is definitely worth it. With 2 threads
> and 2 processors, using enter_blocking_section() raises CPU usage from
> ~50% (i.e. 100% of 1 processor) to ~75%, with a corresponding increase
> in throughput.
Isn't it possible to register a global variable for that purpose ?
Romain
--
He say 'im that he's the first one
Who discover Jamaica, I an' I say that:
What about the Awarak indians ?