[bind10-dev] Exception speed
Michael Graff
mgraff at isc.org
Thu Oct 8 20:08:52 UTC 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here is a list of exception and non-exception speeds on my desktop,
using one core of a quad Xeon:
384615: throw_terminal(1)
111111: throw_terminal(10)
333333: rethrow(1)
27027: rethrow(10)
303030: rethrow_ex5(1)
21276: rethrow_ex5(10)
100000000: return_terminal(1)
33333333: return_terminal(10)
These are in calls/second.
throw_terminal() will decrement the value passed into it. If it is
zero, it will throw an exception, otherwise it will recurse with the
freshly decremented value.
rethrow() will do the same, but will catch and re-raise any exceptions.
This captures the exception at each stack level.
rethrow_ex5() does the same, but with 5 catch blocks.
return_terminal() does not throw exceptions, but just returns when the
counter reaches zero. It is the non-exception equivalent to
throw_terminal().
I've checked this into experiments/graff-exceptions. It's a quick hack,
but sort of interesting in that an exception seems to be approximately
300x slower than a non-exception path.
I believe this means, to me anyway, that we raise exceptions only when
they really are exceptions, and not just when we can't do something.
That is, suppose we had a "read this file, and if it exists, parse it."
We could code this to attempt to open a file, and if it's not there,
raise a FileNotFound() exception, otherwise process it (which might
raise a ParseError() exception.) While we won't call that sort of
things rapidly, perhaps it is best to return something indicating that
no file was read, and leave the ParseError() there if there is an actual
parse error.
A lame example, perhaps...
- --Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkrORtMACgkQ+NNi0s9NRJ1ciQCfU32waDuUUyF0z1sREV5wmriZ
F1QAoJlv7ECYekkA6WSNR6xfQg28Loxe
=lp6r
-----END PGP SIGNATURE-----
More information about the bind10-dev
mailing list