forked from matrixorigin/matrixone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
malloc: optimizations (matrixorigin#17131)
malloc: return []byte instead of unsafe.Pointer in Allocator.Allocate malloc: remove pointer param from Deallocator.Deallocate malloc: rename argumentedFuncDeallocator to closureDeallocator; add closureDeallocatorPool malloc: expose closure allocator and pool malloc: add LeaksTrackingAllocator malloc: optimize sharded counter to avoid false sharing Approved by: @zhangxu19830126 malloc: various changes and optimizations (matrixorigin#16990) malloc: add checked allocator malloc: wrap checked allocator in default allocator malloc: add hints malloc: remove checked deallocator malloc: add DoNotReuse hint to checked deallocator malloc: add stack info to checked allocator malloc: more tests for check allocator malloc: add allocator config malloc: check double free before calling upstream in CheckedAllocator deallocation malloc: do not use default allocator in tests to avoid dependency loop malloc: fix stacktrace malloc: more detail infos for checked allocator panic messages malloc: show pointer address in checked allocator panic messages malloc: show allocated size in checked allocator panic messages malloc: fix checked allocator finalizer fileservice: add fuzzFS fileservice: refine TestFuzzingDiskS3 malloc: add NoClear hint malloc: refine ClassAllocator tests malloc: add FixedSizeAllocator malloc: add FixedSizeSyncPoolAllocator malloc: use fixedSizeSyncPoolAllocator as go allocator by default fileservice: fix missing release in tests Approved by: @zhangxu19830126
- Loading branch information
Showing
26 changed files
with
562 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package malloc | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
type ClosureDeallocator[T any] struct { | ||
argument T | ||
fn func(Hints, T) | ||
} | ||
|
||
func (a *ClosureDeallocator[T]) SetArgument(arg T) { | ||
a.argument = arg | ||
} | ||
|
||
var _ Deallocator = &ClosureDeallocator[int]{} | ||
|
||
func (a *ClosureDeallocator[T]) Deallocate(hints Hints) { | ||
a.fn(hints, a.argument) | ||
} | ||
|
||
type ClosureDeallocatorPool[T any] struct { | ||
pool sync.Pool | ||
} | ||
|
||
func NewClosureDeallocatorPool[T any]( | ||
deallocateFunc func(Hints, T), | ||
) *ClosureDeallocatorPool[T] { | ||
ret := new(ClosureDeallocatorPool[T]) | ||
|
||
ret.pool.New = func() any { | ||
closure := new(ClosureDeallocator[T]) | ||
closure.fn = func(hints Hints, args T) { | ||
deallocateFunc(hints, args) | ||
ret.pool.Put(closure) | ||
} | ||
return closure | ||
} | ||
|
||
return ret | ||
} | ||
|
||
func (c *ClosureDeallocatorPool[T]) Get(args T) Deallocator { | ||
closure := c.pool.Get().(*ClosureDeallocator[T]) | ||
closure.SetArgument(args) | ||
return closure | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.