commit aa1f9ac6bd53fabee4e1b38311de4474ad28dfb9
parent 4435501754dca260c04f392e87356b6caf212c67
Author: William Casarin <jb55@jb55.com>
Date: Fri, 11 Aug 2023 21:08:51 -0700
benchmark very large file
Diffstat:
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
@@ -122,6 +122,9 @@ bench: bench.c $(DEPS)
bench-ingest: bench-ingest.c $(DEPS)
$(CC) $(CFLAGS) bench-ingest.c $(LDS) -o $@
+bench-ingest-many: bench-ingest-many.c $(DEPS)
+ $(CC) $(CFLAGS) $< $(LDS) -o $@
+
testdata/db/.dir:
@mkdir -p testdata/db
touch testdata/db/.dir
diff --git a/nostrdb.c b/nostrdb.c
@@ -519,6 +519,7 @@ static int ndb_write_profile(struct ndb_lmdb *lmdb, MDB_txn *txn,
static uint64_t ndb_write_note(struct ndb_lmdb *lmdb, MDB_txn *txn,
struct ndb_writer_note *note)
{
+ int rc;
uint64_t note_key;
struct ndb_tsid tsid;
MDB_dbi note_db, id_db;
@@ -537,8 +538,8 @@ static uint64_t ndb_write_note(struct ndb_lmdb *lmdb, MDB_txn *txn,
val.mv_data = note->note;
val.mv_size = note->note_len;
- if (mdb_put(txn, note_db, &key, &val, 0)) {
- ndb_debug("write note to db failed\n");
+ if ((rc = mdb_put(txn, note_db, &key, &val, 0))) {
+ ndb_debug("write note to db failed: %s\n", mdb_strerror(rc));
return 0;
}
@@ -550,8 +551,9 @@ static uint64_t ndb_write_note(struct ndb_lmdb *lmdb, MDB_txn *txn,
val.mv_data = ¬e_key;
val.mv_size = sizeof(note_key);
- if (mdb_put(txn, id_db, &key, &val, 0)) {
- ndb_debug("write note id index to db failed\n");
+ if ((rc = mdb_put(txn, id_db, &key, &val, 0))) {
+ ndb_debug("write note id index to db failed: %s\n",
+ mdb_strerror(rc));
return 0;
}
@@ -932,7 +934,7 @@ int ndb_process_event(struct ndb *ndb, const char *json, int json_len)
return ndb_ingester_queue_event(&ndb->ingester, json_copy, json_len);
}
-int ndb_process_events(struct ndb *ndb, const char *ldjson, int json_len)
+int ndb_process_events(struct ndb *ndb, const char *ldjson, size_t json_len)
{
const char *start, *end, *very_end;
start = ldjson;
diff --git a/nostrdb.h b/nostrdb.h
@@ -150,7 +150,7 @@ int ndb_note_verify(void *secp_ctx, unsigned char pubkey[32], unsigned char id[3
// NDB
int ndb_init(struct ndb **ndb, size_t mapsize, int ingester_threads);
int ndb_process_event(struct ndb *, const char *json, int len);
-int ndb_process_events(struct ndb *, const char *ldjson, int len);
+int ndb_process_events(struct ndb *, const char *ldjson, size_t len);
int ndb_get_profile(struct ndb *, unsigned char pubkey[32], void **out);
struct ndb_note *ndb_get_note_by_id(struct ndb *, unsigned char *id);
void ndb_destroy(struct ndb *);