Performance of send_message()
Pascal Brisset
pascal.brisset@REDACTED
Sun Aug 6 20:50:58 CEST 2000
OK, I found an explanation for both problems. The quadratic
behaviour will definitely not happen in real applications.
When beam 4.9.1 sends a constant object (atom, small int, etc), it
allocates a useless off-heap message_buffer. This causes a GC every
heap_sz/5 messages. Unfortunately, heap_sz remains constant,
therefore GCs continue with the same frequency. I guess each GC
needs to run through the message queue, hence the O(N^2) total time.
Here's a possible patch.
- Pascal Brisset <pascal.brisset@REDACTED> +33 2 96051928 -
- France Telecom R&D DTL/MSV | 2, av Pierre Marzin | F-22307 Lannion -
--- otp_src_R6B-0/erts/emulator/beam/erl_message.c.dist Sun Aug 6 20:10:25 2000
+++ otp_src_R6B-0/erts/emulator/beam/erl_message.c Sun Aug 6 20:10:44 2000
@@ -190,8 +190,14 @@
token = copy_struct(SEQ_TRACE_TOKEN(sender), 6 /* TUPLE5 */,
&hp, &receiver->off_heap);
} else {
+ if ( msize ) {
bp = new_message_buffer(msize);
hp = bp->mem;
+ }
+ else {
+ bp = NULL;
+ hp = NULL;
+ }
}
message = copy_struct(message, msize, &hp, &receiver->off_heap);
queue_message_tt(receiver, bp, message, token);
More information about the erlang-questions
mailing list