Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Neo Store UT] Add leveldb thread UT and readme. #3427

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jul 18, 2024

Description

Leveldb itself is not thread safe, thus having this pr to demonstrate how leveldb snapshot behaves under multi thread env.

Quote from leveldb document https://github.com/google/leveldb/blob/main/doc/index.md :

A database may only be opened by one process at a time. The leveldb implementation acquires a lock from the operating system to prevent misuse. Within a single process, the same leveldb::DB object may be safely shared by multiple concurrent threads. I.e., different threads may write into or fetch iterators or call Get on the same database without any external synchronization (the leveldb implementation will automatically do the required synchronization). However other objects (like Iterator and WriteBatch) may require external synchronization. If two threads share such an object, they must protect access to it using their own locking protocol. More details are available in the public header files.

Fixes # (issue)

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • TestMultiThreadLevelDbSnapshotPut
  • TestMultiThreadLevelDbSnapshotPutWithoutCommit
  • TestMultiThreadLevelDbSnapshotPutWithLocker
  • TestOneSnapshotPerThreadLevelDbSnapshotPut

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Member

@cschuchardt88 cschuchardt88 left a comment

Choose a reason for hiding this comment

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

But leveldb does support multi-threading and so does the interface (IStore). The classes that inherit IStore are not thread safe. I said this at the begin when i started work here.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 18, 2024

But leveldb does support multi-threading and so does the interface (IStore). The classes that inherit IStore are not thread safe. I said this at the begin when i started work here.

No, it does not. Did i do anything saying it does here? Aren't we are saying exactly the same thing?

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jul 18, 2024

Then why you think your tests are failing than? Your testing the wrong thing, you need to be testing SnapshotCache and DataCache

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 18, 2024

Then why you think your tests are failing than? Your testing the wrong thing, you need to be testing SnapshotCache and DataCache

which test are failing, aren't they all passed? Will test snapshotcache later.

@cschuchardt88
Copy link
Member

Then why you think your tests are failing than? Your testing the wrong thing, you need to be testing SnapshotCache and DataCache

which test are failing, aren't they all passed? Will test snapshotcache later.

image

@Jim8y Jim8y added the NGD Review This pr is an UT/Benchmark PR, NGD can review. label Jul 19, 2024
@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 19, 2024

Then why you think your tests are failing than? Your testing the wrong thing, you need to be testing SnapshotCache and DataCache

which test are failing, aren't they all passed? Will test snapshotcache later.

image

Will update.

@Jim8y Jim8y changed the title [Neo Store UT] Add leveldb thread UT. [Neo Store UT] Add leveldb thread UT and readme. Jul 19, 2024
@Jim8y Jim8y removed the need update label Jul 19, 2024
Jim8y and others added 2 commits July 21, 2024 01:09
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
Co-authored-by: Christopher Schuchardt <cschuchardt88@gmail.com>
@shargon
Copy link
Member

shargon commented Sep 11, 2024

one UT is faulted :S

shargon
shargon previously approved these changes Sep 27, 2024
@shargon
Copy link
Member

shargon commented Sep 28, 2024

@Jim8y one test fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NGD Review This pr is an UT/Benchmark PR, NGD can review. unit tests waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants