-
Notifications
You must be signed in to change notification settings - Fork 426
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
Added blockpool struct #2602
base: master
Are you sure you want to change the base?
Added blockpool struct #2602
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2602 +/- ##
==========================================
+ Coverage 78.09% 78.13% +0.03%
==========================================
Files 108 109 +1
Lines 11860 11894 +34
==========================================
+ Hits 9262 9293 +31
- Misses 2088 2091 +3
Partials 510 510
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
// createBlock creates a new block. | ||
func (ib *BlockPool) createBlock() (Block, error) { | ||
prot, flags := syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_ANON|syscall.MAP_PRIVATE | ||
addr, err := syscall.Mmap(-1, 0, int(ib.blockSize), prot, flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we doing this purely for performance reasons?
Just to confirm, we also need to take care of deallocating resources at the end of WriteFile operation completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, can we add freeBlock() function as well so its abstracted here with totalcount and other free related things.
assert.Equal(t.T(), int64(0), block.Size()) | ||
} | ||
|
||
func (t *BlockPoolTest) TestCreateBlock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is same as TestGetWhenTotalBlocksIsLessThanThanMaxBlocks
Shall we remove one?
bp, err := InitBlockPool(1024, 10) | ||
|
||
require.Nil(t.T(), err) | ||
assert.NotNil(t.T(), bp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
assert.NotNil(t.T(), bp) | |
require.NotNil(t.T(), bp) |
// BlockPool handles the creation of blocks as per the user configuration. | ||
type BlockPool struct { | ||
// Channel holding free blocks. | ||
blocksCh chan Block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*nit = Can we rename to blocksChannel or similar like freeBlocksChannel instead to signify its usage and helps in readability.
Description
Added blockpool struct which is responsible for creating and maintaining blocks as per the user configuration.
Link to the issue in case of a bug fix.
NA
Testing details