Tuesday, November 25, 2014
Polygon Offset Using Vector Math in IronPython
The other day I saw a something retweeted by @leppie (I think) about an experimental hyper-fast vector math driven 3D engine for the dot Net Framework. This led me to investigate whether there is a default implementation of vector math in the dot Net Framework. As it turns out, there is.
This is of interest because (I think) this would make IronPython the only Python implementation that has vector math included without having to install a third party library. Java has a utils.Vector object, but it has nothing to do with vector math (it's a specialized array). You do need to use the dot Net Framework instead of standard Python modules, but if you're running IronPython, you should have access to that anyway.
The whole, or at least a big part of the idea of running a Python implementation against the dotNet Framework is that you can leverage the power of that big library collection with a language that's fairly dense, easy, and doesn't require compilation.
This was pretty easy on Windows. The only confusing part is that there are two namespaces in dot Net called System.Windows. You want the one that references the WindowsBase dll. This is the one that has our Vector object in it.
The code (including the plotting by Gnuplot - I had to download the Windows version; I did leave out the monastery.py file with the original shape points in it; also, the writetofile.py file is almost exactly like the one from the previous post except that for a Vector object, the x and y names are capitalized):
# vecipy.py
"""
Polygon offset problem using
dot Net Framework.
"""
import clr
WINX = 'WindowsBase'
clr.AddReference(WINX)
from System.Windows import Vector
import math
import copy
import monastery as pic
OFFSET = 0.15
def scaleadd(origin, offset, vectorx):
"""
From a Vector representing the origin,
a scalar offset, and a Vector, returns
a Vector object representing a point
offset from the origin.
(Multiply vectorx by offset and add to origin.)
"""
# Multiply method that takes scalar and Vector.
multx = Vector.Multiply(vectorx, offset)
return Vector.Add(multx, origin)
def getinsetpoint(pt1, pt2, pt3):
"""
Given three points that form a corner (pt1, pt2, pt3),
returns a point offset distance OFFSET to the right
of the path formed by pt1-pt2-pt3.
pt1, pt2, and pt3 are two tuples.
Returns a Vector object.
"""
origin = Vector(*pt2)
v1 = Vector(pt1[0] - pt2[0], pt1[1] - pt2[1])
v1.Normalize()
v2 = Vector(pt3[0] - pt2[0], pt3[1] - pt2[1])
v2.Normalize()
v3 = copy.copy(v1)
v1 = Vector.CrossProduct(v1, v2)
v3 = Vector.Add(v3, v2)
v3.Normalize()
# In dotNet - Vector.Multiply is overloaded.
# When it gets two Vector objects as arguments
# it returns a dot product.
cs = Vector.Multiply(v3, v2)
# Again multiplication is overloaded.
# Here it gets a scalar and a Vector
# as arguments.
a1 = Vector.Multiply(cs, v2)
a2 = Vector.Subtraction(v3, a1)
if cs > 0:
alpha = math.sqrt(a2.LengthSquared)
else:
alpha =- math.sqrt(a2.LengthSquared)
if v1 < 0.0:
return scaleadd(origin, -1.0 * OFFSET/alpha, v3)
else:
return scaleadd(origin, OFFSET/alpha, v3)
def generatepoints():
"""
Create list of offset points
for points inset from polygon.
Return list.
"""
polyinset = []
lenpolygon = len(pic.MONASTERY)
i = 0
poly = pic.MONASTERY
while i < lenpolygon - 2:
polyinset.append(getinsetpoint(poly[i],
poly[i + 1], poly[i + 2]))
i += 1
polyinset.append(getinsetpoint(poly[-2],
poly[0], poly[1]))
polyinset.append(getinsetpoint(poly[0],
poly[1], poly[2]))
return polyinset
# writetofile.py
"""
Write vector points to file.
Show in gnuplot.
"""
import vecipy as vecx
import os
# We're using gnuplot.
# It doesn't like commas, so
# we'll use whitespace (6).
FMT = '{0:30.28f} {1:30.28f}'
FILEX = 'points'
ORIGSHAPE = 'originalshape'
PLOTCMD = 'set xrange[0.0:6.0]\n'
PLOTCMD += 'set yrange[0.0:6.0]\n'
PLOTCMD += 'plot "{0:s}" with lines lt rgb "red" lw 4, '
PLOTCMD += '"{1:s}" with lines lt rgb "blue" lw 4'
GNUPLOTFILE = 'plotfile'
GNUPLOT = 'gnuplot -p {:s}'.format(GNUPLOTFILE)
pts = vecx.generatepoints()
f = open(FILEX, 'w')
i = 1
for ptx in pts:
print('Printing point {0:d} . . .'.format(i))
print >> f, FMT.format(ptx.X, ptx.Y)
i += 1
f.close()
# Plot original as well.
i = 0
f = open(ORIGSHAPE, 'w')
for ptx in vecx.pic.MONASTERY:
print('Printing point {0:d} of original shape . . .'.format(i))
print >> f, FMT.format(*ptx)
i += 1
f.close()
f = open(GNUPLOTFILE, 'w')
print >> f, PLOTCMD.format(ORIGSHAPE, FILEX)
f.close()
os.system(GNUPLOT)
The result (shown in previous post):
I run OpenBSD on my laptop at home. So I would be using mono in my cross-platform experiment.
Microsoft just recently (Fall 2014) announced the open sourcing of the dotNet Framework and cross platform capability for it. The mono project responded very positively to this announcement. I would imagine this as being good news for IronPython too.
OpenBSD has a package for mono. From there, I just needed to download the IronPython binaries and run mono against them, or so I thought . . .
As it turns out, my script kept crashing on the overloaded Vector.Multiply method - NotImplementedError. I tried to research things, wasn't having any luck, and brute forced the problem by wrapping the method in a class in C# class I called vecx:
Note (26NOV2014): I hacked this C# module up a bit too quickly and didn't have performance or elegance in mind. If you declare those Multiply methods as static you can save yourself the trouble of instantiating a new instance of the class each time you want to call them. In fact, you can do the same thing with all the Vector methods you want to use (Add, CrossProduct, etc.). I was just too hurried and too lazy. CBT
using System;
public class vecx
{
public System.Windows.Vector vectorx;
public vecx()
{
System.Windows.Vector vectorx = new System.Windows.Vector(0.0, 0.0);
this.vectorx = vectorx;
}
public vecx(double x, double y)
{
System.Windows.Vector vectorx = new System.Windows.Vector(x, y);
this.vectorx = vectorx;
}
public Double Multiply(System.Windows.Vector a, System.Windows.Vector b)
{
return System.Windows.Vector.Multiply(a, b);
}
public System.Windows.Vector Multiply(Double a, System.Windows.Vector b)
{
return System.Windows.Vector.Multiply(a, b);
}
public System.Windows.Vector Multiply(System.Windows.Vector a, Double b)
{
return System.Windows.Vector.Multiply(a, b);
}
}
The command line (your paths will probably be different) text for compiling this under mono was:
$ mcs -r:/usr/local/lib/mono/4.5/WindowsBase.dll -target:library vecx.cs
The code using this faux Vector class was a little bit different (and hackish):
"""
Polygon offset problem using
dot Net Framework.
Modified for use with mono.
"""
import clr
# Hacked C# module.
VECX = '/home/carl/vectormath/IronPython/mono/vecx.dll'
clr.AddReference(VECX)
import vecx
import math
import copy
import monastery as pic
OFFSET = 0.15
def scaleadd(origin, offset, vectorx):
"""
From a Vector representing the origin,
a scalar offset, and a Vector, returns
a Vector object representing a point
offset from the origin.
(Multiply vectorx by offset and add to origin.)
"""
# Generic vector for use of Vector type.
vecgeneric = vecx().vectorx
# Multiply method that takes scalar and Vector.
# Using cs module compiled to dll for Multiply
# methods in mono.
multx = vecx().Multiply(vectorx, offset)
return vecgeneric.Add(multx, origin)
def getinsetpoint(pt1, pt2, pt3):
"""
Given three points that form a corner (pt1, pt2, pt3),
returns a point offset distance OFFSET to the right
of the path formed by pt1-pt2-pt3.
pt1, pt2, and pt3 are two tuples.
Returns a Vector object.
"""
# Generic vector for use of type.
vecgeneric = vecx().vectorx
origin = vecx(*pt2).vectorx
v1 = vecx(pt1[0] - pt2[0], pt1[1] - pt2[1]).vectorx
v1.Normalize()
v2 = vecx(pt3[0] - pt2[0], pt3[1] - pt2[1]).vectorx
v2.Normalize()
v3 = copy.copy(v1)
v1 = vecgeneric.CrossProduct(v1, v2)
v3 = vecgeneric.Add(v3, v2)
v3.Normalize()
# In dotNet - Vector.Multiply is overloaded.
# When it gets two Vector objects as arguments
# it returns a dot product.
# Using cs module compiled to dll for Multiply
# methods in mono.
cs = vecx().Multiply(v3, v2)
# Again multiplication is overloaded.
# Here it gets a scalar and a Vector
# as arguments.
# Using cs module compiled to dll for Multiply
# methods in mono.
a1 = vecx().Multiply(cs, v2)
a2 = vecgeneric.Subtract(v3, a1)
if cs > 0:
alpha = math.sqrt(a2.LengthSquared)
else:
alpha =- math.sqrt(a2.LengthSquared)
if v1 < 0.0:
return scaleadd(origin, -1.0 * OFFSET/alpha, v3)
else:
return scaleadd(origin, OFFSET/alpha, v3)
def generatepoints():
"""
Create list of offset points
for points inset from polygon.
Return list.
"""
polyinset = []
lenpolygon = len(pic.MONASTERY)
i = 0
poly = pic.MONASTERY
while i < lenpolygon - 2:
polyinset.append(getinsetpoint(poly[i],
poly[i + 1], poly[i + 2]))
i += 1
polyinset.append(getinsetpoint(poly[-2],
poly[0], poly[1]))
polyinset.append(getinsetpoint(poly[0],
poly[1], poly[2]))
return polyinset
Any port in a storm or whatever it takes, as they say.
Thanks again to Mr. Rafsanjani whom I referenced in my previous post. His methodology and detection of a former bug got me back on track.
And thank you for stopping by.
Labels:
#Csharp,
#dotNet,
#IronPython,
#mono,
#polygonoffset,
#Vector,
#vectormaath
Sunday, November 16, 2014
Polygon Offset With pyeuclid Revisited
A few years back I did two or three posts on polygon offset. It was a
learning experience that I never quite completed to my satisfaction. A
kind visitor to my last post on the subject, Mr. Ahmad Rafsanjani,
actually rewrote some of my code in a comment. I gave him a polite
weasel answer thanking him, but dropped the effort and never felt quite
right about it.
Well, as the saying goes, better late than never. He was quite correct in his assessment, but my understanding of vector math was not strong enough to prove this to myself. I was visually inspecting the results, and, given what I was dealing with at the time, they seemed OK.
Here is the picture we're trying to get (this is with Mr. Rafsanjani's code, but the difference with mine and the original code, although wrong, is not great):
In order to nail down the discrepancy in my original code, I inserted some print statements with a lot of numeric precision (28 digits to the right of the decimal) in the output:
$ more points
1.2231671842700024832595318003 1.7024195134850139687898717966
2.1231671842700023944416898303 1.7024195134850139687898717966
2.2768328157299975167404681997 2.5475804865149860312101282034
1.6635803619063778135966913396 2.5493839809701555054743948858
1.7364196380936223196300716154 3.3506160190298444057077631442
2.5205825797292722434406186949 3.3529128986463621053815131745
2.6794174202707274901058553951 4.1470871013536383387076966756
2.1360193516544989655869812850 4.1228847880778562995374159073
(etc.)
The numbers highlighted in yellow are mismatches in the Y-coordinates of points of the inset offset polygon - each pair of Y coordinates should represent lines parallel to the X axis; in other words, they should be equal. I have a bug.
Contrast that with the numbers yielded by Mr. Rafsanjani's code:
$ more points
1.2251864530113494300422871675 1.7000000000000001776356839400
2.1251864530113491191798402724 1.7000000000000001776356839400
2.2797319075568038826418160170 2.5499999999999998223643160600
1.6642549229616445671808833140 2.5499999999999998223643160600
1.7369821956889173186766583967 3.3500000000000000888178419700
2.5229705854077835169846366625 3.3500000000000000888178419700
2.6829705854077836590931838145 4.1500000000000003552713678801
2.1880983342360056376207921858 4.1500000000000003552713678801
2.6780983342360054066944030637 4.8499999999999996447286321199
3.1219016657639944156699129962 4.8499999999999996447286321199
(etc.)
Much better. Lines that are supposed to be perfectly parallel to the X axis are, at least to 28 decimal places precision and the limits of my platform and the C Python interpreter, parallel to the X axis. For what I am doing, I can more than live with that.
I've included Mr. Rafsanjani's comments in the code. My modifications to his code were mainly for the purpose of printing some things out and organizing the polygon offset part of this exercise into a module.
I've made a separate main script for gnuplot. After not looking at everything for three years I realized I had forgotten everything I ever knew about gnuplot and wanted to record it this time. The file with the 20 points for the shape (monastery.py) is available on request.
Here is the main pyeuclid/polygon offset part of the code (rafsanjanicorrection.py):
"""
Polygon offset problem using
pyeuclid and incorporating corrections
made by Ahmed Rafsanjani.
"""
# Mr. Rafsanjani's comments:
# I think there is a small bug:
# In "getinsetpoint", the vector v3 should be
# normalized before passing to "scaleadd".
# Furthermore, the final offset is not as the
# prescribed OFFSET and the angle between
# vectors should be taken into account.
# A possible solution could be:
import euclid as eu
import math
import copy
import monastery as pic
OFFSET = 0.15
def scaleadd(origin, offset, vectorx):
"""
From a vector representing the origin,
a scalar offset, and a vector, returns
a Vector3 object representing a point
offset from the origin.
(Multiply vectorx by offset and add to origin.)
"""
multx = vectorx * offset
return multx + origin
def getinsetpoint(pt1, pt2, pt3):
"""
Given three points that form a corner (pt1, pt2, pt3),
returns a point offset distance OFFSET to the right
of the path formed by pt1-pt2-pt3.
pt1, pt2, and pt3 are two tuples.
Returns a Vector3 object.
"""
origin = eu.Vector3(pt2[0], pt2[1], 0.0)
v1 = eu.Vector3(pt1[0] - pt2[0], pt1[1] - pt2[1], 0.0)
v1.normalize()
v2 = eu.Vector3(pt3[0] - pt2[0], pt3[1] - pt2[1], 0.0)
v2.normalize()
v3 = copy.copy(v1)
v1 = v1.cross(v2)
v3 += v2
v3.normalize()
cs = v3.dot(v2)
a1 = cs * v2
a2 = v3 - a1
if cs > 0:
alpha = math.sqrt(a2.magnitude_squared())
else:
alpha =- math.sqrt(a2.magnitude_squared())
if v1.z < 0.0:
return scaleadd(origin, -1.0 * OFFSET/alpha, v3)
else:
return scaleadd(origin, OFFSET/alpha, v3)
def generatepoints():
"""
Create list of offset points
(pyeuclid.Vector3 objects) for
points inset from polygon.
Return list.
"""
polyinset = []
lenpolygon = len(pic.MONASTERY)
i = 0
poly = pic.MONASTERY
while i < lenpolygon - 2:
polyinset.append(getinsetpoint(poly[i],
poly[i + 1], poly[i + 2]))
i += 1
polyinset.append(getinsetpoint(poly[-2],
poly[0], poly[1]))
polyinset.append(getinsetpoint(poly[0],
poly[1], poly[2]))
return polyinset
The file that prints stuff out and summons gnuplot (writtofile.py):
"""
Write vector points to file.
Show in gnuplot.
"""
# import blogpost as vecx
import rafsanjanicorrection as vecx
import os
# We're using gnuplot.
# It doesn't like commas, so
# we'll use whitespace (6).
FMT = '{0:30.28f} {1:30.28f}'
FILEX = 'points'
ORIGSHAPE = 'originalshape'
PLOTCMD = 'set xrange[0.0:6.0]\n'
PLOTCMD += 'set yrange[0.0:6.0]\n'
PLOTCMD += 'plot "{0:s}" with lines lt rgb "red" lw 4, '
PLOTCMD += '"{1:s}" with lines lt rgb "blue" lw 4'
GNUPLOTFILE = 'plotfile'
GNUPLOT = 'gnuplot -p {:s}'.format(GNUPLOTFILE)
pts = vecx.generatepoints()
f = open(FILEX, 'w')
i = 1
for ptx in pts:
print('Printing point {0:d} . . .'.format(i))
print >> f, FMT.format(ptx.x, ptx.y)
i += 1
f.close()
# Plot original as well.
# XXX - repetetive - make function.
i = 0
f = open(ORIGSHAPE, 'w')
for ptx in vecx.pic.MONASTERY:
print('Printing point {0:d} of original shape . . .'.format(i))
print >> f, FMT.format(ptx[0], ptx[1])
i += 1
f.close()
f = open(GNUPLOTFILE, 'w')
print >> f, PLOTCMD.format(ORIGSHAPE, FILEX)
f.close()
os.system(GNUPLOT)
pyeuclid, to the best of my knowledge, runs only in Python 2.7 at the moment. In any case, I got an error on the Python 3.4 install with setup.py so I stuck with 2.7.
Thanks to Mr. Rafsanjani for his help with this and for the rest of you for stopping by.
Well, as the saying goes, better late than never. He was quite correct in his assessment, but my understanding of vector math was not strong enough to prove this to myself. I was visually inspecting the results, and, given what I was dealing with at the time, they seemed OK.
Here is the picture we're trying to get (this is with Mr. Rafsanjani's code, but the difference with mine and the original code, although wrong, is not great):
In order to nail down the discrepancy in my original code, I inserted some print statements with a lot of numeric precision (28 digits to the right of the decimal) in the output:
$ more points
1.2231671842700024832595318003 1.7024195134850139687898717966
2.1231671842700023944416898303 1.7024195134850139687898717966
2.2768328157299975167404681997 2.5475804865149860312101282034
1.6635803619063778135966913396 2.5493839809701555054743948858
1.7364196380936223196300716154 3.3506160190298444057077631442
2.5205825797292722434406186949 3.3529128986463621053815131745
2.6794174202707274901058553951 4.1470871013536383387076966756
2.1360193516544989655869812850 4.1228847880778562995374159073
(etc.)
The numbers highlighted in yellow are mismatches in the Y-coordinates of points of the inset offset polygon - each pair of Y coordinates should represent lines parallel to the X axis; in other words, they should be equal. I have a bug.
Contrast that with the numbers yielded by Mr. Rafsanjani's code:
$ more points
1.2251864530113494300422871675 1.7000000000000001776356839400
2.1251864530113491191798402724 1.7000000000000001776356839400
2.2797319075568038826418160170 2.5499999999999998223643160600
1.6642549229616445671808833140 2.5499999999999998223643160600
1.7369821956889173186766583967 3.3500000000000000888178419700
2.5229705854077835169846366625 3.3500000000000000888178419700
2.6829705854077836590931838145 4.1500000000000003552713678801
2.1880983342360056376207921858 4.1500000000000003552713678801
2.6780983342360054066944030637 4.8499999999999996447286321199
3.1219016657639944156699129962 4.8499999999999996447286321199
(etc.)
Much better. Lines that are supposed to be perfectly parallel to the X axis are, at least to 28 decimal places precision and the limits of my platform and the C Python interpreter, parallel to the X axis. For what I am doing, I can more than live with that.
I've included Mr. Rafsanjani's comments in the code. My modifications to his code were mainly for the purpose of printing some things out and organizing the polygon offset part of this exercise into a module.
I've made a separate main script for gnuplot. After not looking at everything for three years I realized I had forgotten everything I ever knew about gnuplot and wanted to record it this time. The file with the 20 points for the shape (monastery.py) is available on request.
Here is the main pyeuclid/polygon offset part of the code (rafsanjanicorrection.py):
"""
Polygon offset problem using
pyeuclid and incorporating corrections
made by Ahmed Rafsanjani.
"""
# Mr. Rafsanjani's comments:
# I think there is a small bug:
# In "getinsetpoint", the vector v3 should be
# normalized before passing to "scaleadd".
# Furthermore, the final offset is not as the
# prescribed OFFSET and the angle between
# vectors should be taken into account.
# A possible solution could be:
import euclid as eu
import math
import copy
import monastery as pic
OFFSET = 0.15
def scaleadd(origin, offset, vectorx):
"""
From a vector representing the origin,
a scalar offset, and a vector, returns
a Vector3 object representing a point
offset from the origin.
(Multiply vectorx by offset and add to origin.)
"""
multx = vectorx * offset
return multx + origin
def getinsetpoint(pt1, pt2, pt3):
"""
Given three points that form a corner (pt1, pt2, pt3),
returns a point offset distance OFFSET to the right
of the path formed by pt1-pt2-pt3.
pt1, pt2, and pt3 are two tuples.
Returns a Vector3 object.
"""
origin = eu.Vector3(pt2[0], pt2[1], 0.0)
v1 = eu.Vector3(pt1[0] - pt2[0], pt1[1] - pt2[1], 0.0)
v1.normalize()
v2 = eu.Vector3(pt3[0] - pt2[0], pt3[1] - pt2[1], 0.0)
v2.normalize()
v3 = copy.copy(v1)
v1 = v1.cross(v2)
v3 += v2
v3.normalize()
cs = v3.dot(v2)
a1 = cs * v2
a2 = v3 - a1
if cs > 0:
alpha = math.sqrt(a2.magnitude_squared())
else:
alpha =- math.sqrt(a2.magnitude_squared())
if v1.z < 0.0:
return scaleadd(origin, -1.0 * OFFSET/alpha, v3)
else:
return scaleadd(origin, OFFSET/alpha, v3)
def generatepoints():
"""
Create list of offset points
(pyeuclid.Vector3 objects) for
points inset from polygon.
Return list.
"""
polyinset = []
lenpolygon = len(pic.MONASTERY)
i = 0
poly = pic.MONASTERY
while i < lenpolygon - 2:
polyinset.append(getinsetpoint(poly[i],
poly[i + 1], poly[i + 2]))
i += 1
polyinset.append(getinsetpoint(poly[-2],
poly[0], poly[1]))
polyinset.append(getinsetpoint(poly[0],
poly[1], poly[2]))
return polyinset
The file that prints stuff out and summons gnuplot (writtofile.py):
"""
Write vector points to file.
Show in gnuplot.
"""
# import blogpost as vecx
import rafsanjanicorrection as vecx
import os
# We're using gnuplot.
# It doesn't like commas, so
# we'll use whitespace (6).
FMT = '{0:30.28f} {1:30.28f}'
FILEX = 'points'
ORIGSHAPE = 'originalshape'
PLOTCMD = 'set xrange[0.0:6.0]\n'
PLOTCMD += 'set yrange[0.0:6.0]\n'
PLOTCMD += 'plot "{0:s}" with lines lt rgb "red" lw 4, '
PLOTCMD += '"{1:s}" with lines lt rgb "blue" lw 4'
GNUPLOTFILE = 'plotfile'
GNUPLOT = 'gnuplot -p {:s}'.format(GNUPLOTFILE)
pts = vecx.generatepoints()
f = open(FILEX, 'w')
i = 1
for ptx in pts:
print('Printing point {0:d} . . .'.format(i))
print >> f, FMT.format(ptx.x, ptx.y)
i += 1
f.close()
# Plot original as well.
# XXX - repetetive - make function.
i = 0
f = open(ORIGSHAPE, 'w')
for ptx in vecx.pic.MONASTERY:
print('Printing point {0:d} of original shape . . .'.format(i))
print >> f, FMT.format(ptx[0], ptx[1])
i += 1
f.close()
f = open(GNUPLOTFILE, 'w')
print >> f, PLOTCMD.format(ORIGSHAPE, FILEX)
f.close()
os.system(GNUPLOT)
pyeuclid, to the best of my knowledge, runs only in Python 2.7 at the moment. In any case, I got an error on the Python 3.4 install with setup.py so I stuck with 2.7.
Thanks to Mr. Rafsanjani for his help with this and for the rest of you for stopping by.
Labels:
#polygonoffset,
#pyeuclid,
#python2.7,
#vectormath
Monday, November 3, 2014
MeetBSD California 2014 Recap
I am returning from MeetBSD in San Jose, California. This isn't a Python-related post per se, but the BSD family of operating systems maintains packages and ports for Python and Python third party libraries, and use of Python on these systems is significant both in the open source development and commercial spheres.
The structure of the conference is a brief weekend unconference. Nonetheless some of the talks were more than worthy of a full fledged mega-con, and the rest were quality. It was a good deal.
Venue: the conference was held at Western Digital. WD sells a variety of hardware. The product they were pushing was a several terabyte little box that updates wirelessly (but not by Bluetooth).
We met in a rectangular conference room. All of Silicon Valley seems to me to be an endless office park with nice weather and some landscaped spots (I've included the obligatory Strelizia/bird of paradise pic from the conference hotel entrance below). It was a fairly intimate setting. The food (a variety of sandwiches) was good. We were warned ahead of time that Wifi was limited; I brought my own Verizon jetpack unit so it wasn't an issue for me.
Talks (that I attended):
1) Rick Reed, “WhatsApp: Half a billion unsuspecting FreeBSD users” - Erlang and FreeBSD at WhatsApp used for scaling. Now 600,000 users. It was a good talk, but I wasn't awake and some of it went over my head.
2) Jordan Hubbard, “FreeBSD: The Next 10 Years” Good talk; I hated it :-(
Hubbard's leaving Apple a couple years ago and signing on with iXSystems (a sponsor and essentially the organizer of this conference) made a big splash. He is an accomplished dev and a good guy by all accounts. His ideas are on many levels very valid in every sense.
I am primarily an OpenBSD user. I run FreeBSD on my RPi and on a spare laptop for easy access to Java. The two OS's have similar philosophies in some respects (correctness, BSD license, etc.). There is cross-polination when it comes to operating system components, apps, and drivers. But where OpenBSD unapologetically maintains new releases for older hardware and uncompromisingly adheres to its leader's approach to security and development, FreeBSD in the framework of Hubbard's talk is looking more towards the future and making changes to attract younger talented core committers and target more modern (read mobile) platforms. Telemetry, scrapping development on older platforms "ruthlessly," getting younger devs involved by providing work that's interesting to them - all this stuff is important for FreeBSD going forward. At one point he even <gasp> suggested systemd as a good strategy for Linux that FreeBSD should, at least in principle if not in form, emulate.
FreeBSD is everywhere - or at least in a lot of places companies just don't make a big deal of. Inside cable (connections) was the one example. In order to accomodate mobile and embedded environments, the OS, although well suited to these platforms now, needs to change.
A lot of this in my mind goes against OpenBSD's philosophy - purity and security at all costs. My personal philosophy lies with the OpenBSD approach, but I may well be wrong. Hubbard is a guy with a lot of industry know how and experience and I am a geologist who uses OpenBSD. He is probably right, but I don't want my fun to stop, so I'm sticking with OpenBSD even if death awaits us . . .
3) David Maxwell, "The Unix command pipeline - using Unix in the renewable energy era"
I always liked Maxwell. He's a Canadian guy and a NetBSD devotee.
His talk was about a command line app he's putting together for better tracking piped commands on the UNIX command line and reproducing, referencing, and inspecting them retroactively in a way that's easier than what you have to do now. I think it's got potential and would like to see it succeed.
After the angst I felt over Hubbard's talk, this was a welcome relief. The UNIX command line is something everyone, or most everyone at the con knows and loves. Everyone uses piped commands. This is a useful approach to a common problem - that's something we can all agree on. My favorite talk of the conference (that I attended).
4) Alex Rosenberg, "Meet PlayStation 4"
By far and away the coolest talk. Rosenberg presented this well and spoke honestly and as openly as he could as a member of a big commercial project about specifics. Games require so much optimization at such a low level. Although this theme came up in a number of the talks, on the PlayStation project it's critical. Essentially, the best hardware and hardware architecture for the project is selected for a given product lifecycle (10 years? IIRC) then you hammer at it with software modifications to get every last bit of efficiency out of it.
It's not like there's a standard laptop install of FreeBSD on PlayStation 4 and you let it rip with your happy traditional UNIX OS. They're optimizing LLVM and clang (the compiler and linkers), talking directly to the metal as much as possible, and just generally nailing performance at the lowest level of the architecture (after they've gotten the low hanging fruit up top, of course).
Another theme that came up in almost all the talks, but especially in this one, was the BSD license. Granted, it was a BSD conference, so organizers and attendees have a bias. Nonetheless, it appears that licensing is really critical in the decision to adopt open source software and operating systems. "business friendly" nowadays often has "capitalism at its worst" overtones, still, it was a theme: the BSD license is the "business friendly" one whereas the GPL, particularly the GPL3, is not . . .
I'm not a gamer, but I enjoyed this. Rosenberg is really easy to talk to as well. He let me take that pic up close when we were posing for the group pic after his talk.
5) Brendan Gregg, "Performance Analysis"
Gregg works for Netflix. He's written a lot of dtrace scripts (including numerous Python ones) and has them readily available on Github.
I found myself wishing I knew more about the subject, because performance monitoring is a really cool netadmin problem when, like Netflix, you're dealing with huge bandwidth challenges (as in other talks, so much comes down to optimization).
That said, Gregg presented some graphical tools that are useful (I'll get the names wrong, so I won't try) - basically histogram-like, color coded performance charts with labels for processes. You don't have to run your own netflix to benefit from these and he's made everything open source and available. If I were a netadmin I would jump on this. I've got to get smarter first before I can benefit from these tools.
Gregg has a soft British accent and a very amiable demeanor. He was the first talk in the morning. It was like a lullabye. This is one I need to revisit on the videos posted online because it's worth it.
6) Corey Vixie, "Web Apps on Embedded BSD..."
The iXSystems surprise talk, but a good one. The youngster Vixie briefed us a bit on what iXSystems is doing with web presentation layer (for lack of a better description) of the FreeNAS implementation.
He started off by saying static web pages are, at least for apps like FreeNAS, not the way to go anymore. Refreshing the DOM (Document Object Model) at regular intervals is not going to work well. He then introduced us to a number of mature and nascent JavaScript/web technologies, some of which no one in the room had yet heard of. Basically he had to rewrite the "old" Django/other technologies implementation to accomodate better simulation of a desktop app in the browser.
The specifics were not something I could follow well because of my ignorance. There was talk of an Open Source, BSD licensed Facebook framework whose name I can't recall, a one-way change propagation architecture for updating the dynamic web page, and, as always, optimization of the process. I asked him about Django after the talk. He said it was the best thing a couple years ago for this app, but now they needed something that could interact directly with the browser - namely JavaScript - it comes down to fine-grained control and optimization.
One humorous interlude during the Q & A was my asking him if he was indeed related to Paul Vixie, historical UNIX tools author (Vixie Cron), to which he replied, "This is the part of my talk where I say, 'I am Worf, son of Mogh.'" Anyone with a sense of humor and a knowledge of STTNG can't be all bad ;-)
A few people pics:
Dru Lavigne. Without the BSDA cert program she helped found, I would never have gotten over the hump learning UNIX. We differ on our choice of specific BSD, but I still consider her my UNIX mentor.
iXSystems old timers Denise and Matt working out conference specifics.
FreeBSD Foundation rep Anne.
Conclusion: MeetBSD is an affordable, pretty meaty con if you like UNIX, hardware, and topics about optimization and scale. It is, fortunately or unfortunately, a pretty well kept secret.
Thanks for stopping by.
Subscribe to:
Posts (Atom)