Foreign.Marshal.Pool functions use inefficient O(n) operations
Foreign.Marshal.Pool
uses Data.List.delete
and Data.List.elem
to determine whether a pointer is already in the pool and to delete them, as a result of newtype Pool = Pool (IORef [Ptr ()])
.
Thus repeated operations on pools with many entries can become very slow.
If possible, we might consider using Ord
on the Ptr
and an O(log n) data structure instead of a [Ptr]
list.
Alternatively, we should warn in the docs that this is the case, but it seems better to just fix the implementation.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | nh2 |
Operating system | |
Architecture |