Summary: | TpIntSet should cope with larger integers | ||
---|---|---|---|
Product: | Telepathy | Reporter: | Simon McVittie <smcv> |
Component: | tp-glib | Assignee: | Simon McVittie <smcv> |
Status: | RESOLVED FIXED | QA Contact: | Telepathy bugs list <telepathy-bugs> |
Severity: | enhancement | ||
Priority: | high | Keywords: | patch |
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
URL: | http://git.collabora.co.uk/?p=user/smcv/telepathy-glib-smcv.git;a=shortlog;h=refs/heads/sparse-intset | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Bug Depends on: | |||
Bug Blocks: | 23155 |
Description
Simon McVittie
2008-05-30 09:47:40 UTC
Another option is to divide up the malloced bitfield into 4k chunks, only zero chunks in which a bit has been set. Maintain a bitfield for which chunks are currently in use (that would be max 16k). Align the bitfield to a page boundary when (re)allocing if it grows larger than a page for extra points. The kernel should then nicely take care of paging for you, I think. The actual operations should also be able to stay very light. This is more important now that we're seriously thinking about Bug #23155. This single patch: http://git.collabora.co.uk/?p=user/smcv/telepathy-glib-smcv.git;a=shortlog;h=refs/heads/sparse-intset changes TpIntSet to be implemented as a hash from guint to guint32 (the 5 lowest bits are represented by a bitfield in the value, and the rest go in the key). On 64-bit platforms we could in principle use a hash from guint to 64-bit int, and put the 6 lowest bits in the value; all the code is there, except that count_bits32() needs replacing with a version with 64-bit magic numbers (I didn't really want to waste time researching that right now). Iteration will be somewhat slower now due to keeping the (undocumented!) rule that iteration over an int set is ordered, so I also added a TpIntSetFastIter which has a more GHashTable-like API and iterates out-of-order. A bit scary but pretty smart :) The logic and the code looks fine to me. Thanks, will be in 0.11.6. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.