haskell / haskell/containers

IntMap.delete allocates even for absent keys

Open
#1,220 3 comments 0 reactions 0 assignees View on GitHub
performance
Dominant language
Haskell
Stars
355
Forks
194
Avg merge
3d 4h
Merged PRs (30d)
4

Description

https://github.com/haskell/containers/blob/78da761ebcda243134218c062e4a9b94aaa39068/containers/src/Data/IntMap/Internal.hs#L966-L974

I noticed some code in GHC that performs a bunch of deletions (on the very similar `Word64Map`) with keys that are most likely absent from the map. So now I'm wondering whether to introduce pointer-checks in `Word64Map.delete` or to split off a `delete_possiblyAbsent` version or…

But since `Word64Map` is derived from `IntMap`, my first question is: why doesn't `IntMap.delete` perform these pointer-checks already, even though `Map.delete` does?

https://github.com/haskell/containers/blob/78da761ebcda243134218c062e4a9b94aaa39068/containers/src/Data/Map/Internal.hs#L941-L955

Contributor guide

Open the contributing guide

Research direction

Compare the linked IntMap.delete implementation in containers/src/Data/IntMap/Internal.hs at lines 966-974 with Map.delete in containers/src/Data/Map/Internal.hs at lines 941-955. Start by understanding why the implementations differ and how Word64Map is derived from IntMap. Done means establishing whether pointer checks or a separate deletion variant is warranted, with the chosen scope and expected behavior clearly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.