Comments (4)
Hi @Zoxc -- thanks for bringing this up; I think it is not a bug but nevertheless I agree the naming and use is inconsistent. In particular, the name MI_HUGE_BLOCK_SIZE
is confusing as it is just a large value used in xblock_size
to signify that we need to calculate the block size from the segment size (for very large allocations). But it is orthogonal to the block actually being huge as > MI_LARGE_OBJ_SIZE_MAX
. And as you saw, the MI_BIN_HUGE
can contain either huge or large blocks. This really need to be fixed/clarified.
I will go through and rename some of these and add further comments, and check for possible bugs in particular for blocksizes around MI_LARGE_OBJ_SIZE_MAX
(on first glance it looks actually ok though)
Thanks!
from mimalloc.
The specific case I'm worried about is when creating a huge page for an allocation with small size and high alignment.
When allocating it will use unconditionally use MI_HUGE_OBJ_SIZE_MAX
to pick the queue to use, but when freeing using mi_page_queue_of
it will instead use page->xblock_size
which will result in a different queue.
I'm also kind of wondering why MI_HUGE_OBJ_SIZE_MAX
isn't 0 or -1 if it just represents an unknown block size?
from mimalloc.
Ah I see. Just to clarify, you mean MI_HUGE_BLOCK_SIZE
instead of MI_HUGE_OBJ_SIZE_MAX
. (since dev-slice
uses a different value for MI_HUGE_BLOCK_SIZE
(I should make this consistent as well)).
Hmm, I think you are right but I need to look into it in more detail. I consider it a bug but I think it actually works as it is because such special huge allocation with a small size but large alignment will always consist of a single block in a single page and thus it will be in the BIN_FULL
queue when it is freed which is checked for in mi_page_queue_of
. So, I think it actually works, but still, it would be better to maintain a stronger invariant. I need to think about this a bit more.
There is no special reason I think to not use ~0
(as it is unsigned) -- maybe 0
is used already for uninitialized pages.
btw. nice you try to rewrite this in Rust !
from mimalloc.
Thanks for the feedback; I made various improvements including an is_huge
field in the page to ensure the correct page queue is used.
from mimalloc.
Related Issues (20)
- Mismatched use of fiber and thread locals HOT 9
- Multiple large pages per segment cause `mi_segment_insert_in_free_queue` to fail HOT 1
- [Feature Request] Support of `musl libc` HOT 3
- mimalloc vs2015 debug version is slower than windows malloc, is there any option to accelerate the speed?
- mimalloc vs2015 debug version is slower than windows malloc, is there any option to accelerate the speed?
- Debug memory allocation HOT 1
- `slice_count` overflow for very large allocations HOT 2
- Calling mi_heap_collect does not decommits all unused pages HOT 2
- `unix/prim.c` uses deprecated Apple `TARGET_` symbols HOT 1
- Patching a 32-bit image with `minject` doesn't tell you to use `minject32`. HOT 1
- Segment check range exceeds 40TB for asan builds HOT 1
- Test 'malloc-nomem1' failure on 32-bit architectures after v2.1.4 HOT 1
- 2.1.4 Failure build for ppc64le error: โ__builtin_thread_pointerโ is not supported on this target HOT 12
- 2.1.4 and error mingw/msys2 HOT 4
- 2.1.4: build fail on centos7 HOT 7
- CMake install with namespace and add corresponding alias targets
- Rss memory usage increase in version 2.1.4 HOT 2
- Add dllhook mode HOT 1
- oversize allocation in mi_heap_malloc_zero_aligned_at HOT 6
- Concurrency bugs that cause hanging HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mimalloc.