This is an archive of the discontinued Mercurial Phabricator instance.

datapack: add getdelta api
ClosedPublic

Authored by durham on Dec 14 2017, 2:24 PM.
Tags
None
Subscribers

Details

Reviewers
quark
Group Reviewers
Restricted Project
Commits
rFBHGX38db46cc245c: datapack: add getdelta api
Summary

In order to improve repack performance, we need to be able to fetch a single
delta from a data store. This diff adds the new api and implements it in all our
existing interfaces.

Diff Detail

Repository
rFBHGX Facebook Mercurial Extensions
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

durham created this revision.Dec 14 2017, 2:24 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptDec 14 2017, 2:24 PM
quark requested changes to this revision.Dec 14 2017, 4:46 PM
quark added a subscriber: quark.
quark added inline comments.
cstore/py-cdatapack.h
476

nit: &args[0] is the same as args.

args is not a C array but a Python tuple. Use PyTuple_GET_ITEM(x, 0) instead of [0] here:

PyErr_SetObject(PyExc_KeyError, PyTuple_GET_ITEM(args, 0));

That said, KeyError accepts a tuple so the old code won't crash.

503–506

s/PyString_/PyBytes_/ to decouple from Python 2.

I think it's worthwhile to use:

delta = PyBuffer_FromMemory(link.delta, (Py_ssize_t) link.delta_sz)

(and move`free() below to be inside if (!delta)`).

519–533

PyXDECREF(NULL) is also a no-op. So the block is equivalent to:

free((void *)link.delta);
return tuple;
530

nit: free(NULL) is a no-op. So if is unnecessary.

This revision now requires changes to proceed.Dec 14 2017, 4:46 PM
quark added inline comments.Dec 14 2017, 5:01 PM
cstore/py-cdatapack.h
503–506

I take that back. PyBuffer_FromMemory won't take care of deallocation. So we have to do a copy here.

durham updated this revision to Diff 4439.Dec 14 2017, 5:46 PM
durham marked 5 inline comments as done.Dec 14 2017, 5:47 PM
durham added inline comments.
cstore/py-cdatapack.h
476

This is just a copy of the code in cdatapack_getmeta. I'll update it though.

quark accepted this revision.Dec 14 2017, 10:19 PM
This revision is now accepted and ready to land.Dec 14 2017, 10:19 PM
durham marked an inline comment as done.Dec 15 2017, 2:34 PM
This revision was automatically updated to reflect the committed changes.