Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BitmapBuilder should be aware of compacted bitmap(all 1 bitmap) #6219

Closed
yuhao-su opened this issue Nov 7, 2022 · 5 comments
Closed

BitmapBuilder should be aware of compacted bitmap(all 1 bitmap) #6219

yuhao-su opened this issue Nov 7, 2022 · 5 comments

Comments

@yuhao-su
Copy link
Contributor

yuhao-su commented Nov 7, 2022

currently, we have a Vis

pub enum Vis {
    Bitmap(Bitmap),
    Compact(usize), // equivalent to all ones of this size
}

When the bitmap got from bitmapbuilder.finish returns a all 1 bitmap, it should actually be compacted.

@fuyufjh
Copy link
Member

fuyufjh commented Nov 10, 2022

Please feel free to reassign

@fuyufjh fuyufjh added the good first issue Good for newcomers label Jan 30, 2023
@fuyufjh fuyufjh removed this from the release-0.1.16 milestone Jan 30, 2023
@fuyufjh fuyufjh added the help wanted Issues that need help from contributors label Jan 30, 2023
@y-wei y-wei self-assigned this Mar 18, 2023
@y-wei
Copy link
Contributor

y-wei commented Mar 18, 2023

I find many callers that expect a Bitmap from .finish(). Sizable refractors were needed if we want to have .finish() returning a Vis. Do we still want this feature?

@TennyZhuang
Copy link
Contributor

Bitmap is used in many places, e.g. Vnodes. If you like to optimize for Vis, you should introduce VisBuilder. Anyway, do you have any performance result that indicates we need to optimize it?

@TennyZhuang TennyZhuang added needs-discussion and removed good first issue Good for newcomers labels Mar 18, 2023
@TennyZhuang
Copy link
Contributor

Sorry @Eurekaaw, I have removed the good first issue label here since we need to discuss it first. Welcome to the discussion.

Here are some backgrounds:

  1. Bitmap is a common utility, similar to bitvec, and it's used in many places, including
  • mask for chunk, for the lazy materialization
  • vnode bitmap, represents the distribution
  • bloom filter
  1. We may always introduce a Compact chunk only for the chunk. In other cases, it's likely a downgrade, since a compacted vnode mapping is rare. So we introduce the Vis to optimize the chunk.
  2. Even for chunks, we have no benchmark about whether it's worth introducing the Vis, since the overhead of a Bitmap is really low. 1024-records only need 128 bytes. I guess it's may introduce a few benefits.
  3. BitmapBuilder is used to build a Bitmap but not Vis. If you really want that, you should wrap a VisBuilder.
  4. The compacted Vis is constructed directly, from the source, table_scan, exchange, etc. If we construct a Bitmap instead, it's likely under a prediction but all true, is it a common case? What's your target scenario?

@TennyZhuang TennyZhuang removed the help wanted Issues that need help from contributors label Mar 18, 2023
@y-wei
Copy link
Contributor

y-wei commented Mar 18, 2023

My intuition is that in cases where we call BitmapBuilder.finish() and optimize if the returned Bitmap.all(), simply returning a Vis::Compact may buy us a few benefits. OTOH I agree with you that Bitmap's over head is not likely to be significant and my intuitively optimized case seems rare. Could you please elaborate more about this issue? @yuhao-su

@y-wei y-wei assigned y-wei and unassigned y-wei Mar 18, 2023
@yuhao-su yuhao-su closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants