<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.28.1">
</HEAD>
<BODY>
Good morning,<BR>
<BR>
Yesterday I did a few tests to measure the performance of FFI calls and found that the calls themselves are very quick (1-2 nanosecond).<BR>
However, there is a kind of FFI calls when one have to allocate a temporary memory block (for a struct, or a temporary buffer). One of examples is a call to &quot;gettimeofday&quot; or &quot;clock_gettime&quot;. Unfortunately, the usual way of doing it (using the &quot;alloca&quot; function) is quite slow (~40 nanoseconds).<BR>
<BR>
I was wondering, is there any way to allocate a small chunk of data on a thread's stack?<BR>
That should be cheap, as by large it is just a shift of a pointer and, perhaps, a few other trivial operations.<BR>
I understand that it is not safe to allocate large blocks on the stack. But we could possibly have a function similar to &quot;alloca&quot; which would allocate small blocks on stack and would use the &quot;alloca&quot; for big ones.<BR>
<BR>
With kind regards,<BR>
Denys Rtveliashvili
</BODY>
</HTML>