Issue 8500 - DList extremely wasteful in node allocation
Summary: DList extremely wasteful in node allocation
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-02 14:18 UTC by Alex Rønne Petersen
Modified: 2024-12-01 16:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Alex Rønne Petersen 2012-08-02 14:18:38 UTC
The DList container currently allocates a Node struct with the GC instead of managing their memory manually. I don't know if there's anything preventing manual memory management here, but the current approach is extremely wasteful.
Comment 1 Jonathan M Davis 2012-08-02 15:38:29 UTC
I wouldn't expect it to do anything else until custom allocators are implemented. Then the allocator used will determine the allocation scheme used.
Comment 2 Andrei Alexandrescu 2012-08-02 15:45:27 UTC
This is following the traditional approach of Java and other languages. Allocators will take care of this.
Comment 3 Alex Rønne Petersen 2012-08-02 17:57:31 UTC
> I wouldn't expect it to do anything else until custom allocators are implemented. Then the allocator used will determine the allocation scheme used.

I'd honestly expected it to use malloc/free like Array(T).

> This is following the traditional approach of Java and other languages.
Allocators will take care of this.

Right, I'm just saying that the inefficiency of insertions (which is one of the most common operations next to removal) in DList almost negates any performance gained by using it instead of a plain Array(T) for some use cases (for me, instruction streams in a JIT compiler). For large workloads, it'll induce a lot of GC cycles, scanning, and freeing, which is way worse for throughput than the slightly less efficient insertion and removal algorithms on an Array(T) which at least use malloc/free.

I know allocators will solve this, but I think that a malloc/free approach in the meantime would be reasonable enough (if doable).
Comment 4 dlangBugzillaToGithub 2024-12-01 16:15:27 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9933

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB