Re: How to Optimize a Black Box

Kaz Kylheku <336-986-7787@kylheku.com>
Fri, 24 Mar 2017 20:51:20 +0000 (UTC)

          From comp.compilers

Related articles
How to Optimize a Black Box seimarao@gmail.com (Seima Rao) (2017-03-24)
Re: How to Optimize a Black Box 336-986-7787@kylheku.com (Kaz Kylheku) (2017-03-24)
Re: How to Optimize a Black Box gneuner2@comcast.net (George Neuner) (2017-03-24)
| List of all articles for this month |

From: Kaz Kylheku <336-986-7787@kylheku.com>
Newsgroups: comp.compilers
Date: Fri, 24 Mar 2017 20:51:20 +0000 (UTC)
Organization: Aioe.org NNTP Server
References: 17-03-010
Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="39077"; mail-complaints-to="abuse@iecc.com"
Keywords: code, optimize
Posted-Date: 27 Mar 2017 22:36:58 EDT

On 2017-03-24, Seima Rao <seimarao@gmail.com> wrote:
> My question is how do we start at all in optimizing a black box ?


If the black box behaves as a function (a pure mapping from some inputs
to some outputs) and that function appears to be expensive, one way to
begin is to look at caching: don't call the black box more than once on
the same combination of inputs. That is, obtain the benefits of the
black box being called M times, with N < M actual calls to the
blackbox, and M - N being canned answers from the cache.


If you can determine some properties of the blackbox without actually
cracking it open, you can exploit them. It could be that, say, outside
of some range of the parameter space, the function has some trivial
result that can be short-circuited; yet the blackbox wastes cycles on
it. A wrapper around it could take a shortcut, bypassing the blackbox.


Like say we have a black-box which calculates the area under the normal
distribution density function, between zero and some x. Suppose the
black box is badly implemented and does lots of expensive calculations
for large magnitudes of x, where the answer just comes out to be the
obvious 0.5 or nearly so. (The "long tail" that outside of x contributes
next to nothing to the area).
We can just put in some logic around it like
(fabs(x)) >= THRESHOLD) ? 0.5 : expensive_blackbox(x);.


In this same vein, we could use a black box side-by-side with a crude
approximation of the black-box. Say we have a black-box which gives
an academically answer for every domain value of some function.
But suppose that in our engineering or scientific application,
most of the time, a "rule of thumb" approximation is completely
satisfactory. We can evaluate the parameters to determine whether the
simple, cheap approximation applies, or whether the blackbox needs
to be invoked because the conditions are such that its superior
model is critically relevant.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.