Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #1831 > unrolled thread
| Started by | Seima Rao <seimarao@gmail.com> |
|---|---|
| First post | 2017-03-24 12:22 +0530 |
| Last post | 2017-03-24 22:05 -0400 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.compilers
How to Optimize a Black Box Seima Rao <seimarao@gmail.com> - 2017-03-24 12:22 +0530
Re: How to Optimize a Black Box Kaz Kylheku <336-986-7787@kylheku.com> - 2017-03-24 20:51 +0000
Re: How to Optimize a Black Box George Neuner <gneuner2@comcast.net> - 2017-03-24 22:05 -0400
| From | Seima Rao <seimarao@gmail.com> |
|---|---|
| Date | 2017-03-24 12:22 +0530 |
| Subject | How to Optimize a Black Box |
| Message-ID | <17-03-010@comp.compilers> |
Hi,
In our software development process, we decided that we will
be using Open Source libraries as a plug-in into our software.
Permissive licenses like BSD, MIT & Apache allow us
some freedom in redistributing the code for commercial purposes.
However, when cutting across licensing options, one is often
held due to a library(Open Source) as a black box.
Since we are plugging in a third party library, at some point
of time in the future, we envision visiting it to optimize
starting with the hotpath and then meandering into
the visible items in a profile.
My question is how do we start at all in optimizing a black box ?
Because these open source initiatives have become synonymous
with business (someone using them for commercial purposes) in
many countries, I suspect that many have felt the need to
"peek inside" as well as "work from the outside".
Can anyone help ?
p.s. Rewrite is an option but still ...
--
Sincerely,
Seima Rao.
[I don't understand the problem. With every open source licence I've
ever seen, if you can use the code at all, you've got the source code
and you can recompile it and optimize it. -John]
[toc] | [next] | [standalone]
| From | Kaz Kylheku <336-986-7787@kylheku.com> |
|---|---|
| Date | 2017-03-24 20:51 +0000 |
| Message-ID | <17-03-011@comp.compilers> |
| In reply to | #1831 |
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.
[toc] | [prev] | [next] | [standalone]
| From | George Neuner <gneuner2@comcast.net> |
|---|---|
| Date | 2017-03-24 22:05 -0400 |
| Message-ID | <17-03-012@comp.compilers> |
| In reply to | #1831 |
On Fri, 24 Mar 2017 12:22:56 +0530, Seima Rao <seimarao@gmail.com>
wrote:
> In our software development process, we decided that we will
> be using Open Source libraries as a plug-in into our software.
>
> Permissive licenses like BSD, MIT & Apache allow us
> some freedom in redistributing the code for commercial purposes.
>
> However, when cutting across licensing options, one is often
> held due to a library(Open Source) as a black box.
>
> Since we are plugging in a third party library, at some point
> of time in the future, we envision visiting it to optimize
> starting with the hotpath and then meandering into
> the visible items in a profile.
>
> My question is how do we start at all in optimizing a black box ?
In some sense, that is a "system engineering" question.
If you have source, you can *try* compiling with different
optimizations (vs the vendor's preferred build). But there is no
guarantee that you actually will improve performance, and a very real
possibility that a different set of optimizations might break the
code.
If you don't have - or can't modify - the source, then you have to
look to hardware solutions: faster cores and/or larger caches for
serial code, more cores for parallel code, more RAM for more RAM, SSDs
vs spinning disks, etc. What you need depends on what overall
performance you want to achieve.
Even without source, you often can infer from operation whether code
is serial or parallel.
[In this context, SIMD should be considered "serial" needing a faster
core, vs multi-{thread|process} "parallel" that can use more cores.]
> Because these open source initiatives have become synonymous
> with business (someone using them for commercial purposes) in
> many countries, I suspect that many have felt the need to
> "peek inside" as well as "work from the outside".
>
> Can anyone help ?
>
> p.s. Rewrite is an option but still ...
You need to be careful with the "rewrite" option too. The license
may, in general, give you the right to modify the code, but there may
be some specific provision or technicality that will prevent you from
doing exactly what you want.
Even if the license itself is ok, there may still be copyright and/or
attribution issues - e.g., you don't own the API your code implements.
Occasionally also there may be (software) patent issues to consider.
Just to be safe ... particularly for business use ... if you really
feel you need to rewrite/redesign the library, then you should get
your lawyers involved. Even if the intended use currently is private,
you need to be concerned about the future: e.g., what happens if your
modified library becomes public and comes to the attention of the
library vendor or its contributers?
YMMV,
George
[toc] | [prev] | [standalone]
Back to top | Article view | comp.compilers
csiph-web