caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Severe loss of performance due to new signal handling
@ 2006-03-17 18:39 Markus Mottl
  2006-03-17 19:10 ` [Caml-list] " Christophe TROESTLER
  2006-03-20  9:29 ` Xavier Leroy
  0 siblings, 2 replies; 13+ messages in thread
From: Markus Mottl @ 2006-03-17 18:39 UTC (permalink / raw)
  To: ocaml


[-- Attachment #1.1: Type: text/plain, Size: 1591 bytes --]

Hi,

this report has also been posted to the OCaml bug tracker, but since it is a
surprising observation, it may be good if people on the list know that it
exists without having to search the bug tracker archive.  Maybe some
assembler guru can repeat this result and explain to us what's going on...

----------

It seems that changes to signal handling between OCaml 3.08.4 and 3.09.1 can
lead to a very significant loss of performance (up to several orders of
magnitude!) in code that uses threads and performs I/O (tested on Linux).

The attached file (slow.ml) demonstrates this: it prints a character to
stdout in a for-loop. The uploaded version will take approximately 600ms in
native code to complete this test when redirecting output to /dev/null.  If
you comment out the line containing "module X = Thread" and compile without
thread support, then the test suddenly only takes around 1.5ms, i.e. it runs
400 times faster.

Profiling using oprofile revealed that the function
"caml_process_pending_signals" seems to be responsible for that.  Annotated
assembler output showed that the code was sampled an astonishing number of
times in the instruction "test %eax,%eax" as obviously generated for "if
(async_action != NULL)" in this function. This is really weird, because
everything else seems to be sampled a sensible number of times, but it would
surely explain the timings.

OCaml-3.08.4 does not exhibit any problems of that kind.

----------

Best regards,
Markus

--
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com

[-- Attachment #1.2: Type: text/html, Size: 1937 bytes --]

[-- Attachment #2: slow.ml --]
[-- Type: application/octet-stream, Size: 195 bytes --]

open Unix
open Printf

module X = Thread

let () =
  let t1 = gettimeofday () in
  for i = 1 to 100000 do
    print_char '.';
  done;
  let t2 = gettimeofday () in
  eprintf "%f\n" (t2 -. t1);



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

end of thread, other threads:[~2006-03-21 12:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-17 18:39 Severe loss of performance due to new signal handling Markus Mottl
2006-03-17 19:10 ` [Caml-list] " Christophe TROESTLER
2006-03-20  9:29 ` Xavier Leroy
2006-03-20 10:39   ` Oliver Bandel
2006-03-20 12:37     ` Gerd Stolpmann
2006-03-20 13:13       ` Oliver Bandel
2006-03-20 15:54       ` Xavier Leroy
2006-03-20 16:15   ` Markus Mottl
2006-03-20 16:24     ` Will Farr
2006-03-21  1:33   ` Robert Roessler
2006-03-21  3:11     ` Markus Mottl
2006-03-21  4:04       ` Brian Hurt
2006-03-21 12:54       ` Robert Roessler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).