Use binary search to speedup checkUnload
We are iterating through all object code for each heap objects when checking whether object code can be unloaded. For large projects in GHCi, this can be very expensive due to the large number of object code that needs to be loaded/unloaded. To speed it up, this arrangess all mapped sections of unloaded object code in a sorted array and use binary search to check if an address location fall on them.
For some additional perspective, the repository I'm working on is fairly
large and users frequently have to load up to 6000 modules in GHCi. If
they enable object code and unload them (by calling
:load again on
another module for example), the next major GC in the iserv process can
take almost a minute to finish. I did some rough measurements and the
number of mapped sections that the inner for loop has to wade through can
be up to 50k.