sapling/cstore/py-cstore.cpp
Durham Goode 4fd00d751a cstore: C++ implementation of datapackstore
Summary:
The remaining python parts of the store are a perf bottleneck when accessing
hundreds of thousands of pack file entries (like in treemanifest). Let's
implement them in C++.

This first patch just add the basic boiler plate, and implements a single
function getdeltachain(), with a test. Future patches will add more
functionality and other parts of the store.

Since cstore depends on cdatapack and ctreemanifest (the pythonutils.h part for
now), we need to tweak our setup.py to enforce a certain build order too.

Test Plan: Added a test, yo

Reviewers: #mercurial, simonfar

Reviewed By: simonfar

Subscribers: simonfar, stash, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4547929

Signature: t1:4547929:1487181318:21c146cf370d26cb97efe6a883868b85b4e32f49
2017-02-23 14:03:03 -08:00

56 lines
1.4 KiB
C++

// py-cstore.cpp - C++ implementation of a store
//
// Copyright 2016 Facebook, Inc.
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
//
// no-check-code
// The PY_SSIZE_T_CLEAN define must be defined before the Python.h include,
// as per the documentation.
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "py-cdatapack.h"
#include "py-datapackstore.h"
#include "py-treemanifest.h"
static PyMethodDef mod_methods[] = {
{NULL, NULL}
};
static char mod_description[] =
"Module containing a native store implementation";
PyMODINIT_FUNC initcstore(void) {
PyObject *mod;
mod = Py_InitModule3("cstore", mod_methods, mod_description);
// Init cdatapack
cdatapack_type.tp_new = PyType_GenericNew;
if (PyType_Ready(&cdatapack_type) < 0) {
return;
}
Py_INCREF(&cdatapack_type);
PyModule_AddObject(mod, "datapack", (PyObject *)&cdatapack_type);
// Init treemanifest
treemanifestType.tp_new = PyType_GenericNew;
if (PyType_Ready(&treemanifestType) < 0) {
return;
}
Py_INCREF(&treemanifestType);
PyModule_AddObject(mod, "treemanifest", (PyObject *)&treemanifestType);
// Init datapackstore
datapackstoreType.tp_new = PyType_GenericNew;
if (PyType_Ready(&datapackstoreType) < 0) {
return;
}
Py_INCREF(&datapackstoreType);
PyModule_AddObject(mod, "datapackstore", (PyObject *)&datapackstoreType);
}