Skip to content

fix: lmdb optimizations#63

Open
Tonguechaude wants to merge 9 commits into
temper-mc:devfrom
Tonguechaude:fix/lmdb-optimizations
Open

fix: lmdb optimizations#63
Tonguechaude wants to merge 9 commits into
temper-mc:devfrom
Tonguechaude:fix/lmdb-optimizations

Conversation

@Tonguechaude

@Tonguechaude Tonguechaude commented May 27, 2026

Copy link
Copy Markdown
Collaborator

So this PR fixes :

  1. Deletion of the global Mutex
  • Before we have Arc<Mutex<Env<WithoutTls>>> all operation are serialized over only one lock
  • Now we have Arc<Env<WithoutTls>> all read operation are concurrent, let LMDB handle his own sync
  1. Insert : 2 I/O -> 1 I/O
  • Before: get() + put() to write
  • Now : get_or_put()
  1. Delete : 2 I/O -> 1 I/O
  • More or less same as 2. (see delete func)
  1. Caching handles (DBI)
  • Before: open_database() (mdb_dbi_open called for every operations)
  • Now : DashMap to cache handle after the first time

(btw that fix heap crash append cause mdb_dbi_open isnt thread-safe in concurrent)

  1. use &str instead of String for table name
  • Just because it need to be BlAzInGly fAsT

@Tonguechaude Tonguechaude changed the title fix: remove double I/O useless code fix: lmdb optimizations May 27, 2026
@Tonguechaude

Copy link
Copy Markdown
Collaborator Author

I run the benchmark, this PR reduce read operation by 52%

@Tonguechaude

Copy link
Copy Markdown
Collaborator Author

Single-thread Reads

Size Before After Bonus
512b 412ns 365ns -9.8%
1kb 415ns 383ns -7.8%
4kb 593ns 574ns -6.0%

Concurrents Reads

Threads Before After Bonus
2 6.2µs 6.3µs no changes
4 13.4µs 12.2µs -12.8%
8 38.6µs 26.8µs -35.5%
16 64.3µs 45.6µs -26.4%

@Tonguechaude Tonguechaude requested a review from ReCore-sys June 3, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant