[Mono-list] Status of unsafe code in Mono

Sebastien Pouliot Sebastien Pouliot <spouliot@videotron.ca>
Mon, 10 Mar 2003 22:59:07 -0500


This is a multi-part message in MIME format.

--Boundary_(ID_YkHKAyPkcvJ2scg7M59xuA)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 7BIT

Hello Ben,

First I don't known anything specific to the status of unsafe in mono (never tried it with mono). But if (or when) it's supported I don't anticipate any problem using it within corlib (which is where the BigInteger will be most used) because corlib will only be used with the mono runtime (so it's simple).

However using unsafe code will make the class less (must do some reading to quantify "less") useful for other uses [*] because the application using the assembly/class will be required to "acknowledge" to use  of unsafe code - and this, IMHO, is bad for reusing (my main focus ;-).

[*] Example: including BigInteger in Mono.Security to implement DH for SSL.

The speed gain seems important for the specific methods but I'm unsure how it's translate in a real application. Is it still worth it ?
If yes maybe the unsafe code could be #if/#endif depending on where it will be used (like corlib or other assemblies). 

Sebastien Pouliot
Security Architect, Motus Technologies, http://www.motus.com/
work: spouliot@motus.com
home: spouliot@videotron.ca

  ----- Original Message ----- 
  From: Ben Maurer 
  To: mono-list@lists.ximian.com 
  Sent: Sunday, February 09, 2003 10:57 AM
  Subject: [Mono-list] Status of unsafe code in Mono


  Hi,



  I am working on improving/rewriting Mono.Math.BigInteger, a class that is essential for asymmetrical crypto. My main focus is speed. I have found that using unsafe code can give a 20% - 50% speed boost in a couple of functions.



  I was wondering how well unsafe code is implemented in mono. Is it to the point where production code can use it?



  Sincerely,
  Ben Maurer 

--Boundary_(ID_YkHKAyPkcvJ2scg7M59xuA)
Content-type: text/html; charset=iso-8859-1
Content-transfer-encoding: 7BIT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR>
<STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
	COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
	COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
	COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
	COLOR: purple; TEXT-DECORATION: underline
}
P {
	FONT-SIZE: 10pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; FONT-FAMILY: Arial
}
SPAN.EmailStyle17 {
	COLOR: windowtext; FONT-FAMILY: Arial
}
DIV.Section1 {
	page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello Ben,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>First I don't known anything specific to the status 
of unsafe in mono (never tried it with mono). </FONT><FONT face=Arial size=2>But 
if (or when) it's supported </FONT><FONT face=Arial size=2>I don't anticipate 
any problem using&nbsp;it within corlib (which is where the BigInteger will be 
most used) because corlib will only be used with the mono runtime (so it's 
simple).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>However using unsafe code will make the class less 
(must do some reading to quantify "less") useful for other uses [*]&nbsp;because 
the application using the assembly/class will be required to "acknowledge" to 
use&nbsp; of unsafe code - and this, IMHO, is bad for reusing (my main focus 
;-).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>[*] Example:&nbsp;including BigInteger&nbsp;in 
Mono.Security to implement DH for SSL.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The speed gain seems important for the specific 
methods but I'm unsure how it's translate in a real application. Is it still 
worth it ?</FONT></DIV>
<DIV><FONT face=Arial size=2>If yes maybe the unsafe code could be #if/#endif 
depending on where it will be used (like corlib or other assemblies). 
</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Sebastien Pouliot<BR>Security Architect, Motus 
Technologies, <A href="http://www.motus.com/">http://www.motus.com/</A><BR>work: 
<A href="mailto:spouliot@motus.com">spouliot@motus.com</A><BR>home: <A 
href="mailto:spouliot@videotron.ca">spouliot@videotron.ca</A><BR></FONT></DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=webmaster@theratnerschool.org 
  href="mailto:webmaster@theratnerschool.org">Ben Maurer</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=mono-list@lists.ximian.com 
  href="mailto:mono-list@lists.ximian.com">mono-list@lists.ximian.com</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, February 09, 2003 10:57 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [Mono-list] Status of unsafe 
  code in Mono</DIV>
  <DIV><BR></DIV>
  <DIV class=Section1>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hi,</SPAN></FONT></P>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I am working on 
  improving/rewriting Mono.Math.BigInteger, a class that is essential for 
  asymmetrical crypto. My main focus is speed. I have found that using unsafe 
  code can give a 20% - 50% speed boost in a couple of 
  functions.</SPAN></FONT></P>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I was wondering how well unsafe 
  code is implemented in mono. Is it to the point where production code can use 
  it?</SPAN></FONT></P>
  <P class=MsoNormal><FONT face=Arial size=2><SPAN 
  style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <DIV>
  <P><FONT face=Arial size=2><SPAN style="FONT-SIZE: 10pt">Sincerely,<BR>Ben 
  Maurer </SPAN></FONT></P></DIV></DIV></BLOCKQUOTE></BODY></HTML>

--Boundary_(ID_YkHKAyPkcvJ2scg7M59xuA)--