Re: How to Optimize a Black Box

George Neuner <>
Fri, 24 Mar 2017 22:05:38 -0400

          From comp.compilers

Related articles
How to Optimize a Black Box (Seima Rao) (2017-03-24)
Re: How to Optimize a Black Box (Kaz Kylheku) (2017-03-24)
Re: How to Optimize a Black Box (George Neuner) (2017-03-24)
| List of all articles for this month |

From: George Neuner <>
Newsgroups: comp.compilers
Date: Fri, 24 Mar 2017 22:05:38 -0400
Organization: A noiseless patient Spider
References: 17-03-010
Injection-Info:; posting-host=""; logging-data="39305"; mail-complaints-to=""
Keywords: code, optimize
Posted-Date: 27 Mar 2017 22:37:32 EDT

On Fri, 24 Mar 2017 12:22:56 +0530, Seima Rao <>

> 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

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?


Post a followup to this message

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