Hi,

Thank for your help! I will have a look how this can be improved.
Maybe it makes sense to use int or byte, but I want to make sure it
does in fact get faster so I will need to write some benchmarks as
well.

Regards,
Thomas

On Sat, Oct 11, 2008 at 12:00 AM, Alex <[EMAIL PROTECTED]> wrote:
>
> We were looking at some profiles running on large databases and
> noticed that under some circumstances BitField operations are taking a
> large percentage of time when opening the database.
>
> Particularly the BitField class is implemented using "long" data type
> for bit storage. However when it gets used from the DiskFile class
> getSummary() and initFromSummary() methods they are using bytes. The
> code there basically moves the data from the longs into the bytes bit
> by bit which is very inefficient. It would be very easy to modify the
> BitField class to utilize the byte[] for storage and use this byte[]
> directly to store/restore the allocation table.
>
> We also noticed that sometimes the BitField.setRange method is also
> taking considerable time.
> I guess there should be a way to optimize it as well using byte/long
> operations rather than iterating the range bit by bit.
>
> Below are the code snippets in question:
>
> initFromSummary:
> ======================================================
>                for (int i = 0, x = 0; i < b2 / 8; i++) {
>                    int mask = in.read();
>                    if (init) {
>                        for (int j = 0; j < 8; j++, x++) {
>                            if (used.get(x) != ((mask & (1 << j)) !=
> 0)) {
>                                throw Message.getInternalError("Redo
> failure, block: " + x + " expected in-use bit: " + used.get(x));
>                            }
>                        }
>                    } else {
>                        for (int j = 0; j < 8; j++, x++) {
>                            if ((mask & (1 << j)) != 0) {
>                                used.set(x);
>                            }
>                        }
>                    }
>                }
> ======================================================
>
> getSummary()
>
> ======================================================
>                for (int i = 0, x = 0; i < blocks / 8; i++) {
>                    int mask = 0;
>                    for (int j = 0; j < 8; j++) {
>                        if (used.get(x)) {
>                            mask |= 1 << j;
>                        }
>                        x++;
>                    }
>                    out.write(mask);
>                }
> ====================================================
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to