[viff-devel] Two-threaded VIFF

Marcel Keller mkeller at cs.au.dk
Tue Apr 21 11:11:48 PDT 2009

Hi friends of VIFF,

I've finally completed the patch for a two-threaded VIFF where most of 
the VIFF code runs in a separate thread. The patch is against the tip of 
my repository: http://hg.viff.dk/mkeller

It turned out be not so straight-forward as I thought. I had to use a 
recursion, as in the hack, but I refined it to ensure that the recursion 
limit isn't exceeded.

Unfortunately, this solution is slower than the hack, e.g. one AES block 
encryption takes 4 seconds compared to 3 seconds with the hack. On the 
other hand, the preprocessing time in the actively secure multiplication 
is linear and not quadratic, whereas the online time is significantly 

	two-threaded		hack			original
(n,t)	online	preprocessing	online	preprocessing	online	preproc.
(4,1)	6	22		4	17		4	20
(7,2)	10	37		6	29		6	42
(10,3)	13	53		8	42		8	82
(13,4)	17	68		10	56		10	136
(16,5)	20	84		12	68		12	208
(19,6)	23	106		13	83		14	287
(22,7)	26	120		15	98		17	377

I did some profiling and didn't find an obvious reason why the 
two-thread is slower. Therefore, I guess that the reason is the 
multi-threading implementation of Python (which could be better, as 
mentioned in the discussion about the hack). The guess is also supported 
by the fact that having an own thread for every callback, which I also 
tried, turned out to be really slow.

Unit tests:
All unit test get passed, even the previosly skipped 
test_multiple_callbacks. This because I added the @increment_pc 
decorator to schedule_callback(). This of course changes the program 
counters heavily but I didn't experience any problems.

Best regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: two-threaded-viff.patch
Type: text/x-patch
Size: 20203 bytes
Desc: not available
URL: <http://lists.viff.dk/pipermail/viff-devel-viff.dk/attachments/20090421/99a073d8/attachment-0002.bin>

More information about the viff-devel mailing list