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

enabled usage of dirty pages #845

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ SoilIndexedDictionaryTest >> testFirstWithTransactionRemoved [
{ #category : #tests }
SoilIndexedDictionaryTest >> testFlushIndexPages [
| tx capacity txn2 txn1 root1 root2 |
(classToTest = SoilBTreeDictionary ) ifTrue: [ self skip ].
tx := soil newTransaction.
tx root: dict.
capacity := (dict index pageAt: 1) itemCapacity.
Expand Down Expand Up @@ -621,7 +622,6 @@ SoilIndexedDictionaryTest >> testRemoveKeyWithTwoTransactions [
{ #category : #tests }
SoilIndexedDictionaryTest >> testRemovePagesConcurrent [
| tx tx2 index indexManager tx3 tx4 |
self skip.
(classToTest = SoilBTreeDictionary ) ifTrue: [ self skip ].
indexManager := soil objectRepository firstSegment indexManager.
tx := soil newTransaction.
Expand All @@ -636,15 +636,13 @@ SoilIndexedDictionaryTest >> testRemovePagesConcurrent [
tx4 := soil newTransaction.
300 to: 500 do: [ :n | tx2 root removeKey: n ].
tx2 commit.
self assert: indexManager dirtyPages size = 1 description: 'after second transaction should have 1 to maintain'.
self assert: (index pages select: #needsCleanup) size equals: 2.
501 to: 700 do: [ :n | tx3 root removeKey: n ].
tx3 commit.
self assert: indexManager dirtyPages size = 1 description: 'after third transaction should have 1 to maintain'.
self assert: (index pages select: #needsCleanup) size equals: 3.
tx4 commit.
self assert: indexManager dirtyPages size equals: 0.
self assert: (index pages select: #needsCleanup) size equals: 0.
self assert: indexManager dirtyIndexes size equals: 0.
self assert: (index pages select: #needsCleanup) size equals: 3.



Expand All @@ -653,6 +651,7 @@ SoilIndexedDictionaryTest >> testRemovePagesConcurrent [
{ #category : #tests }
SoilIndexedDictionaryTest >> testRemovePagesSequential [
| tx tx2 index indexManager |
(classToTest = SoilBTreeDictionary ) ifTrue: [ self skip ].
tx := soil newTransaction.
tx root: dict.
1 to: 1000 do: [ :n | dict at: n put: n asString ].
Expand All @@ -665,7 +664,7 @@ SoilIndexedDictionaryTest >> testRemovePagesSequential [
index := indexManager indexes anyOne.
self assert: index dirtyPages size equals: 0.
self assert: indexManager dirtyIndexes size equals: 0.
self assert: (index pages select: #needsWrite) size equals: 0
self assert: (index pages select: #needsWrite) size equals: 1


]
Expand Down
3 changes: 1 addition & 2 deletions src/Soil-Core/SoilBasicSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ SoilBasicSkipList class >> isAbstract [

{ #category : #adding }
SoilBasicSkipList >> addDirtyPage: aPage [
"dirtyPages add: aPage."
self flag: #todo
dirtyPages add: aPage
]

{ #category : #accessing }
Expand Down
7 changes: 3 additions & 4 deletions src/Soil-Core/SoilIndexManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ SoilIndexManager >> dirtyIndexes [

{ #category : #accessing }
SoilIndexManager >> flush [
self indexes do: #flush.
dirtyIndexes removeAll.

"dirtyIndexes do: [ :index |
dirtyIndexes copy do: [ :index |
index dirtyPages copy do: [ :page |
page needsWrite ifTrue: [
index store writePage: page.
page isDirty ifFalse: [
index removeDirtyPage: page ] ] ] ]"
index removeDirtyPage: page ] ] ].
index dirtyPages ifEmpty: [ dirtyIndexes remove: index ] ]
]

{ #category : #flushing }
Expand Down
14 changes: 11 additions & 3 deletions src/Soil-Core/SoilTransaction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,19 @@ SoilTransaction >> transactionManager [

{ #category : #'as yet unclassified' }
SoilTransaction >> updatedIndexDictionary: indexedDictionary [
| segment |
| segment realIndex |
segment := self segmentAt: (self objectIdOf: indexedDictionary) segment.

"when indexed dictionaries created the first time the journal creates the
real index with path. In this case we request the real index from the index
manager"
realIndex := indexedDictionary index store isOpen
ifTrue: [ indexedDictionary persistentIndex ]
ifFalse: [
segment indexManager
at: indexedDictionary id
ifAbsent: [ Error signal: 'cannot find index which should have been added before' ] ].
segment indexManager
addDirtyIndex: indexedDictionary persistentIndex
addDirtyIndex: realIndex

]

Expand Down
Loading