Skip to content

Conversation

@dxyinme
Copy link
Collaborator

@dxyinme dxyinme commented Aug 24, 2025

Before fix:
image

After fix:
image

fix design:
before fix, for each get / write operation will generate a new mmap instance, it will make operation very slow.
after that, we make mmapRWManager as a singleton for each data file. And for each mmapRWManager, I split data file as many part of mmap.

@dxyinme
Copy link
Collaborator Author

dxyinme commented Aug 24, 2025

to fix issue: #551

@bigboss2063 bigboss2063 requested a review from Copilot August 26, 2025 03:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes low performance issues in the mmap read-write mode by implementing a singleton pattern for MMapRWManager and introducing block-based memory mapping. The key performance improvement comes from avoiding the creation of new mmap instances for each read/write operation.

  • Implements singleton pattern for MMapRWManager instances per data file
  • Introduces block-based memory mapping with LRU caching for better memory management
  • Adds comprehensive test coverage for edge cases and cross-block operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
rwmanger_mmap.go Core implementation of singleton MMapRWManager with block-based mapping and LRU caching
rwmanager_mmap_test.go Updated and expanded tests for the new MMapRWManager implementation
file_manager.go Simplified MMapRWManager creation to use the new singleton pattern

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dxyinme
Copy link
Collaborator Author

dxyinme commented Aug 26, 2025

@bigboss2063 all comments resolved.

@bigboss2063
Copy link
Member

Thanks!

@bigboss2063 bigboss2063 merged commit 8380e0c into nutsdb:master Aug 26, 2025
4 checks passed
@dxyinme dxyinme deleted the dxyinme/perf/mmap branch August 27, 2025 13:44
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.

2 participants