Skip to content

Figure out a story for experimental APIs #567

Open

Description

@davidtgoldblatt

There are some interesting experiments we could try. Some examples:

These would expose an API or ABI that we don't necessarily want to commit to until the end of time. We should try to have a way to allow this experimentation without making experiments permanent fixtures.

Straw-proposal:

  • Experimental APIs #defined away by default.
  • No ABI guarantees. If you want to use the internal APIs, you have to recompile against the new headers in order to upgrade the jemalloc version.
  • API guarantees for at least the longer of M major versions or N years after deprecation.

Alternatively, we could strengthen the API guarantee to "indefinite API support, but we'll degrade deprecated APIs back to plain old malloc/free" (or some combination of the two).

Activity

  1. antirez commented on Jan 19, 2017

    @antirez

    Hello, it is great that you are going in this direction. In the case of Redis the above proposal and limitations of the experimental API perfectly fit our goals without issues.

  2. davidtgoldblatt commented on Feb 16, 2017

    @davidtgoldblatt
    ContributorAuthor

    We’ve talked about this some offline. The tricky thing is that most of the time we’ll try very hard not to break backwards ABI compatibility, and we’re unsure to what extent we can enforce any usage restrictions we put in place.

    We can make an API available with varying degrees of strength:

    • No guarantees: Users must compile jemalloc with a special configure flag, and link against the result statically. We break the API when and if convenient. When users want to upgrade the jemalloc version they link against, they may have to modify their code; this is part of the deal they make when they use experimental APIs.
    • Weak mallctl guarantee: structs passed to mallctl functions get a version number as their first field. If the version number of the struct isn’t what we want to support, we return EFAULT. If the mallctl function has been deprecated, return ENOENT.
    • Strong mallctl guarantee: stricts passed to mallctl functions versioned as above. If the version number isn’t what we expect, we try to map from the given version to the current one. (The difference between strong and weak mallctl availability is sort of fuzzy, since the amount of effort we can put into supporting old versions of mallctl functions is a spectrum).
    • Long-term availability: Something like mallocx -- likely here for the lifetime of the project. Exported to everyone who links against jemalloc, in any form.

    The stronger the guarantee for end users, the harder it is for us to iterate quickly. We’re unlikely to take a chance on an API if we have to worry that we’ll break user code if we decide that the experiment was a failure and should be ended. The mallctl options each have their own issues: weak mallctl availability doesn’t provide end users much stability (and if we don’t provide that, there’s little benefit over the “no guarantees” options), and I worry that providing strong mallctl guarantees will be complicated and error-prone.

    The silly thing about this is that most of the anticipated uses of experimental APIs should happen in ways that are tightly bound to jemalloc development: either features meeting a specific user’s needs, who have a fix in mind and are willing to work with us on it (e.g. #566), or else efforts by the jemalloc team to support internal FB efforts. In both these cases, backwards compatibility doesn’t matter, since we can fix any uses ourselves (or leave it to users to fix their uses when they upgrade jemalloc versions, which is work they opted-in for when they tweaked their jemalloc configurations to support experimental APIs).

    Having written up and reworked the notes some, I think that the ordering above of API availability strengths is a good framework for how we could handle this. We start out with the weakest guarantee, then add support for dynamically linked users, then add stronger backwards compatibility, then make it official, making each jump as we gain confidence.

  3. davidtgoldblatt commented on Feb 16, 2017

    @davidtgoldblatt
    ContributorAuthor

    CCing some external contributors -- @cferris1000, @antirez, @glandium, @oranagra, @cpeterso: do you have any thoughts (even stuff like "neat, but we wouldn't run ever want to try out an experimental API" would be useful too).

  4. oranagra commented on Feb 19, 2017

    @oranagra

    @davidtgoldblatt i would use any form of experimental API if it helps me make a more efficient software. be that memory consumption or speed.

    maybe the only case in which i would think twice is if using that experimental API requires me to writes large portions of the code that are tightly bound with the API, which would mean that when it changes i'll have to throw it away and write it again for the new form of the API.

    but if i expect to make moderate adjustments for new versions, that's perfectly fine with me.

  5. davidtgoldblatt commented on Mar 8, 2017

    @davidtgoldblatt
    ContributorAuthor

    Status update: we're going to support this sort of thing with the broad strategy outlined above. To protect against people linking against an out-of-tree jemalloc version, we're going to do some sort of name-mangling in a build step (possibly involving the revision sha1), and define names to their mangled equivalents in a header.

    This probably won't happen until the build system work for 5.0 (#303) has been completed, so it will be a couple of months before we get there.

  6. added this to the 5.1.0 milestone on Mar 9, 2017
  7. modified the milestones: 5.1.0, 5.2.0 on Apr 11, 2018
  8. gnzlbg commented on Nov 4, 2018

    @gnzlbg
    Contributor

    To keep this up-to-date, for the experimental smallocx API we ended up:

    Experimental APIs #defined away by default.

    and also making the symbol name depend on the git hash.

  9. modified the milestones: 5.2.0, 6.0 on Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions