From 65f4f634cb8086008c5e7c90a3e48e6b40d8b592 Mon Sep 17 00:00:00 2001 From: mahlon Date: Thu, 5 Jan 2023 23:16:57 +0000 Subject: [PATCH] Small changes: - Add statistics output example - Fix various compilation warnings - Test/bump ruby version to 3.2 - Fix failing test under OSX FossilOrigin-Name: c5c6d745d854082b8704c8da61dcc315dbc3d99b8ceec4a82ebea65e861f10ea --- .ruby-version | 2 +- README.md | 76 +++++++++++++++++++++++++++++++++++++- ext/mdbx_ext/database.c | 2 +- ext/mdbx_ext/extconf.rb | 2 + ext/mdbx_ext/mdbx_ext.c | 2 +- gem.deps.rb | 2 +- spec/mdbx/database_spec.rb | 5 ++- 7 files changed, 84 insertions(+), 7 deletions(-) diff --git a/.ruby-version b/.ruby-version index 8c50098..a3ec5a4 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1 +3.2 diff --git a/README.md b/README.md index 935ed13..d642bda 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ home docs : https://martini.nu/docs/ruby-mdbx -github mirror +github_mirror : https://github.com/mahlonsmith/ruby-mdbx @@ -332,12 +332,84 @@ Calling `statistics` on a database handle will provide a subset of information about the build environment, the database environment, and the currently connected clients. +```bash +% ruby -rmdbx -rjson -e "puts JSON.generate( MDBX::Database.open( '/tmp/testdb' ).statistics )" | jq +``` + +```json +{ + "build": { + "compiler": "FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)", + "flags": "-DNDEBUG=1 -std=gnu++2b -O2 -pipe -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes -fstack-protector-strong -fno-strict-aliasing -fstack- +protector-strong", + "options": { + "MDBX_DEBUG": 0, + "MDBX_WORDBITS": 64, + "BYTE_ORDER": "LITTLE_ENDIAN", + "MDBX_ENV_CHECKPID": "AUTO", + "MDBX_TXN_CHECKOWNER": "AUTO", + "MDBX_64BIT_ATOMIC": "AUTO", + "MDBX_64BIT_CAS": "AUTO", + "MDBX_TRUST_RTC": "AUTO", + "MDBX_ENABLE_REFUND": 1, + "MDBX_ENABLE_MADVISE": 1, + "_GNU_SOURCE": "NO", + "MDBX_LOCKING": "AUTO", + "MDBX_USE_OFDLOCKS": "AUTO", + "MDBX_CACHELINE_SIZE": 64, + "MDBX_CPU_WRITEBACK_INCOHERENT": 0, + "MDBX_MMAP_INCOHERENT_CPU_CACHE": 0, + "MDBX_MMAP_INCOHERENT_FILE_WRITE": 0, + "MDBX_UNALIGNED_OK": 0, + "MDBX_PNL_ASCENDING": 0 + }, + "target": "x86_64-unknown-freebsd13.1" + }, + "system_memory": { + "pagesize": 4096, + "total_pages": 33522850, + "avail_pages": 4170509 + }, + "environment": { + "pagesize": 4096, + "branch_pages": 0, + "leaf_pages": 0, + "overflow_pages": 0, + "btree_depth": 0, + "entries": 0, + "last_txnid": 3, + "last_reader_txnid": 3, + "max_readers": 120, + "readers_in_use": 1, + "datafile": { + "size_current": 12288, + "pages": 3, + "type": "dynamic", + "size_lower": 12288, + "size_upper": 1048576, + "growth_step": 65536, + "shrink_threshold": 131072 + } + }, + "readers": [ + { + "slot": 0, + "pid": 16731, + "thread": 34374492160, + "txnid": 0, + "lag": 0, + "bytes_used": 0, + "bytes_retired": 0 + } + ] +} +``` ## Contributing You can check out the current development source with Fossil via its [home repo](https://code.martini.nu/fossil/ruby-mdbx), or with Git at its -[project mirror](https://gitlab.com/mahlon/ruby-mdbx). +[project mirror](https://github.com/mahlonsmith/ruby-mdbx) After checking out the source, run: diff --git a/ext/mdbx_ext/database.c b/ext/mdbx_ext/database.c index 04cf56c..980eaa9 100644 --- a/ext/mdbx_ext/database.c +++ b/ext/mdbx_ext/database.c @@ -857,7 +857,7 @@ static VALUE rmdbx_init_copy( VALUE copy, VALUE orig ) * Initialization for the MDBX::Database class. */ void -rmdbx_init_database() +rmdbx_init_database( void ) { rmdbx_cDatabase = rb_define_class_under( rmdbx_mMDBX, "Database", rb_cObject ); diff --git a/ext/mdbx_ext/extconf.rb b/ext/mdbx_ext/extconf.rb index d5f9299..47580c2 100755 --- a/ext/mdbx_ext/extconf.rb +++ b/ext/mdbx_ext/extconf.rb @@ -3,6 +3,8 @@ require 'mkmf' +$CFLAGS << ' -Wno-suggest-attribute=format' + have_library( 'mdbx' ) or abort "No mdbx library!" have_header( 'mdbx.h' ) or abort "No mdbx.h header!" diff --git a/ext/mdbx_ext/mdbx_ext.c b/ext/mdbx_ext/mdbx_ext.c index 773fa65..8bd7eeb 100644 --- a/ext/mdbx_ext/mdbx_ext.c +++ b/ext/mdbx_ext/mdbx_ext.c @@ -64,7 +64,7 @@ rmdbx_log( const char *level, const char *fmt, va_dcl ) * MDBX initialization */ void -Init_mdbx_ext() +Init_mdbx_ext( void ) { rmdbx_mMDBX = rb_define_module( "MDBX" ); diff --git a/gem.deps.rb b/gem.deps.rb index 63b4e02..e2cb01f 100644 --- a/gem.deps.rb +++ b/gem.deps.rb @@ -6,7 +6,7 @@ group( :development ) do gem 'pry', '~> 0.13' gem 'rake', '~> 13.0' gem 'rake-compiler', '~> 1.1' - gem 'rake-deveiate', '~> 0.15', '>= 0.15.1' + gem 'rake-deveiate', '~> 0.22' gem 'rdoc-generator-sixfish', '~> 0.2' gem 'rspec', '~> 3.9' gem 'rubocop', '~> 0.93' diff --git a/spec/mdbx/database_spec.rb b/spec/mdbx/database_spec.rb index 3af2396..20e0fa8 100644 --- a/spec/mdbx/database_spec.rb +++ b/spec/mdbx/database_spec.rb @@ -71,7 +71,10 @@ RSpec.describe( MDBX::Database ) do # here for behavior. expect { described_class.open( TEST_DATABASE.to_s ) - }.to raise_exception( MDBX::DatabaseError, /resource \w+ unavailable/i ) + }.to raise_exception( + MDBX::DatabaseError, + /(?:resource \w+ unavailable|environment is already used)/i + ) end end