Opened 20 years ago
Last modified 18 months ago
#63 assigned enhancement
Improve visibility annotations for the library — at Version 12
Reported by: | Olly Betts | Owned by: | Olly Betts |
---|---|---|---|
Priority: | low | Milestone: | 2.0.0 |
Component: | Library API | Version: | git master |
Severity: | minor | Keywords: | |
Cc: | Richard Boulton | Blocked By: | |
Blocking: | Operating System: | Linux |
Description (last modified by )
See http://gcc.gnu.org/wiki/Visibility
This should make the shared library much smaller, and a little faster!
Change History (11)
comment:1 by , 20 years ago
Status: | new → assigned |
---|
comment:2 by , 18 years ago
Priority: | high → normal |
---|
comment:3 by , 18 years ago
Blocking: | 118 added |
---|
comment:4 by , 18 years ago
Cc: | added |
---|
comment:5 by , 18 years ago
I've put this off previously as visibility annotations are only useful for GCC >= 4.0. However, such versions are now deployed by many linux distros, so I think the time has come for this, and it's not really something we can retrofit into the 1.0 releases. It shouldn't be a lot of work, but it would be good to do it now so any issues have a chance to be shaken out before release.
So I've just made a first pass. The library builds, as do simple utilities like "delve". Things like "quartzcheck" which hook into quartz don't build, and neither does the test harness, so it needs some more work still.
Currently (on x86_64) the stripped libxapian.so is 8% smaller (unstripped is 2.6% smaller), while the number of external symbols drops from 2851 to 508.
comment:6 by , 18 years ago
Hmm, what a mess!
The test harness uses a few bits of the library internals, which is a bit unclean but we can expose those for now at least.
Doing that, apitest builds and passes, which is a promising sign.
But quartztest, btreetest, and internaltest don't stand a chance without exposing shedloads of library internals.
Looking at quartztest, much of it can either just be removed or turned into API level tests where such tests don't already exist.
Not sure what to do about the rest. Unit tests are a good idea, so deleting them isn't really a good option (btreetest and quartztest are less important now flint is the default, but we ought to at least consider a flint btree-level test).
We could try to just link against the object files which are actually needed, but then we also need utility functions, debug functions, etc and this seems likely to be a maintenance headache.
Passing "-static" when linking these problematic binaries is a fix which works (though it's not ideal either). This only links libxapian statically at least - libstdc++ and the shared library aren't affected. Also, we only need to do this for GCC >= 4.0. If we go this route, I think we should merge all the affected tests into a single binary (or fewer binaries at least).
Any other ideas?
comment:7 by , 18 years ago
Possibly not a helpful comment - but don't the utilities in xapian-core/bin/ also need to link to various internals? It would be nice if we could move sufficient amounts of their functionality into the API, so the utilties could be implemented with just the public API (with the side benefit that things like the python bindings could perform a check of a database without needing to exec a sub-process). However, that's not going to happen in the near future.
The -static approach seems the only way forward to me: if the symbols aren't exported by the library, there's no way that utilities are going to be able to link to it, however clever we are. So, the question is whether it's worth doing given that cost.
This isn't a particularly urgent fix, in my mind; though 8% would be a nice size improvement, I've not come across anywhere recently where size is a problem (though if someone wanted to use Xapian in an embedded system it might become one). The attraction of doing this is more to keep the API neat, and reduce the probability of symbol collisions. Perhaps we should defer this to 1.1, and try and move tests into fewer binaries and work on the utilities in the meantime.
comment:8 by , 18 years ago
The utilities in xapian-core/bin do indeed, but the API we need to expose there is fairly limited, so for now I've just marked those as visible (which isn't actually worse than just using them because they happen to be visible if you include the right header!) As you say, longer term it would be better to make those implementable through the API. In particular, being able to merge databases would be handy when writing an indexer.
Given I've got this far, I'm inclined to do a bit more work and commit this, even if it means marking all the classes and functions used by the testsuite as visible (at least some things will be hidden, which would be a step forward).
In the longer term, a coherent approach to allowing unit testing of things like the serialisation functions would be useful though...
comment:9 by , 18 years ago
As you say, hiding even some bits of the internals is better than nothing at all, and getting the infrastructure in place to remove more when we are able to is also good. I hadn't thought of doing a partial implementation like that.
comment:10 by , 18 years ago
Blocking: | 118 removed |
---|---|
Operating System: | → Linux |
Priority: | normal → low |
Summary: | Add visibility annotations to the library → Improve visibility annotations for the library |
I've just committed changes to implement this.
For now, all the internals required by stuff in xapian-core/bin and xapian-core/tests is simply marked as visible. We can look at removing the need for some of these dependencies (e.g. by adding API methods to allow databases to be merged or checked) and think about a strategy to allow sane unit testing.
I've also not worried about marking internal members of visible classes as non-visible - the gain from that is likely to be fairly small, so that can wait until later too I think.
So I'm retitling this bug, and removing the blockage on 1.0.
comment:12 by , 17 years ago
Description: | modified (diff) |
---|---|
Milestone: | → 1.1.1 |
Flag for reassessing during the 1.1.x series.
It would be lovely to do this for 1.0. Possibly not important enough to worry about right now, though.