GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace emulated unsigned shorts with chars by richardstartin · Pull Request #364 · RoaringBitmap/RoaringBitmap

Conversation

@richardstartin

@richardstartin richardstartin commented Dec 6, 2019

Copy link
Copy Markdown
Member

The main aim here is to make signedness bugs impossible, which are frequent in this library, by using Java's unsigned char type in place of short. This also leads to the elimination of methods toIntUnsigned and compareUnsigned, which will likely improve performance marginally. I will follow up with some rough benchmark numbers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
richardstartin added 4 commits December 6, 2019 18:20
@richardstartin
replace short[] with char[] to eliminate signedness bugs
6dbfe1b
@richardstartin
eliminate toIntUnsigned
de7ce62
@richardstartin
eliminate compareUnsigned and simplify conditions
c2a5901
@richardstartin
rename short iterators
19be7ce
@richardstartin
richardstartin requested a review from lemire December 6, 2019 21:13
@lgtm-com

lgtm-com Bot commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 4 when merging 19be7ce into 9f2041e - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 3 for Implicit narrowing conversion in compound assignment
  • 1 for Useless comparison test
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lemire

lemire commented Dec 6, 2019

Copy link
Copy Markdown
Member

I love it. This is so incredibly clever.

@richardstartin Can you check the "2 for Useless comparison test" warnings that LGTM reported?

https://lgtm.com/projects/g/RoaringBitmap/RoaringBitmap/rev/pr-0eda70b1bd9843efdad8f13174a40fff20474957

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Dec 6, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 91.505% when pulling 076f594 on richardstartin:chars into 9f2041e on RoaringBitmap:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
optimise imports, remove some unnecesary lowbits masks
69cf65c
@lgtm-com

lgtm-com Bot commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 4 when merging 69cf65c into 9f2041e - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 3 for Implicit narrowing conversion in compound assignment
  • 1 for Useless comparison test
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin

richardstartin commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

The LGTM alerts are in existing code where the emulated unsigned types made the code too difficult to analyse. I'll remove these checks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lemire

lemire commented Dec 6, 2019

Copy link
Copy Markdown
Member

I see this. Neat.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
remove some useless comparisons
7291703
@lgtm-com

lgtm-com Bot commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 9 when merging 7291703 into 9f2041e - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 5 for Useless comparison test
  • 3 for Implicit narrowing conversion in compound assignment
  • 1 for Useless null check
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lemire
lemire approved these changes Dec 6, 2019
View reviewed changes

@lemire lemire left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever. Go!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@richardstartin

richardstartin commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

There's still the 2 new useless checks to find - struggling with the LGTM interface because the offending classes are too large to render effectively, it seems.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
remove some warnings from run containers
00d73cf
@lgtm-com

lgtm-com Bot commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 10 when merging 00d73cf into 9f2041e - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 6 for Useless comparison test
  • 3 for Implicit narrowing conversion in compound assignment
  • 1 for Useless null check
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin

richardstartin commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

LGTM is wrong about the introduced cases - I put a breakpoint in RunContainer.smartAppendExclusive and the final condition certainly is sometimes true (also obvious if you read the code below)

  private void smartAppendExclusive(char start, char length) {
    int oldend;
    if ((nbrruns == 0)
        || ((start) > (oldend = (getValue(nbrruns - 1))
            + (getLength(nbrruns - 1)) + 1))) { // we add a new one
      valueslength[2 * nbrruns] = start;
      valueslength[2 * nbrruns + 1] = length;
      nbrruns++;
      return;
    }
    if (oldend == (start)) {
      // we merge
      valueslength[2 * (nbrruns - 1) + 1] += length + 1;
      return;
    }

    int newend = (start) + (length) + 1;

    if ((start) == (getValue(nbrruns - 1))) {
      // we wipe out previous
      if (newend < oldend) {
        setValue(nbrruns - 1, (char) newend);
        setLength(nbrruns - 1, (char) (oldend - newend - 1));
        return;
      } else if (newend > oldend) {
        setValue(nbrruns - 1, (char) oldend);
        setLength(nbrruns - 1, (char) (newend - oldend - 1));
        return;
      } else { // they cancel out
        nbrruns--;
        return;
      }
    }
    setLength(nbrruns - 1, (char) (start - (getValue(nbrruns - 1)) - 1));
    if (newend < oldend) {
      setValue(nbrruns, (char) newend);
      setLength(nbrruns, (char) (oldend - newend - 1));
      nbrruns++;
    } else if (newend > oldend) {
      setValue(nbrruns, (char) oldend);
      setLength(nbrruns, (char) (newend - oldend - 1));
      nbrruns++;
    }
  }
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
remove some redundant parentheses
374be1e
@lgtm-com

lgtm-com Bot commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 10 when merging 374be1e into 9f2041e - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 6 for Useless comparison test
  • 3 for Implicit narrowing conversion in compound assignment
  • 1 for Useless null check
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lemire

lemire commented Dec 7, 2019

Copy link
Copy Markdown
Member

Ok. Then let us merge.

I expect that we can’t go wrong (performance-wise).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin

richardstartin commented Dec 7, 2019

Copy link
Copy Markdown
Member Author

Regarding performance, I ran some of the real data benchmarks (ForEach and Or) and found there were a few big improvements, but also some small regressions. I don't know why.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
basic cleanup for LGTM analysis
076f594
@lgtm-com

lgtm-com Bot commented Dec 7, 2019

Copy link
Copy Markdown
Contributor

This pull request introduces 2 alerts and fixes 16 when merging 076f594 into 3f0424d - view on LGTM.com

new alerts:

  • 2 for Useless comparison test

fixed alerts:

  • 9 for Implicit narrowing conversion in compound assignment
  • 6 for Useless comparison test
  • 1 for Useless null check
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lemire

lemire commented Dec 7, 2019

Copy link
Copy Markdown
Member

@richardstartin I take it that you recommend merging?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin

richardstartin commented Dec 7, 2019

Copy link
Copy Markdown
Member Author

Yes I think so, we can revert if performance regressions materialise.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lemire
lemire merged commit bc7275e into RoaringBitmap:master Dec 7, 2019
@lemire

lemire commented Dec 7, 2019

Copy link
Copy Markdown
Member

Released.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@richardstartin
richardstartin deleted the chars branch December 10, 2019 10:28
Smallhi pushed a commit to Smallhi/RoaringBitmap that referenced this pull request Jun 14, 2021
@richardstartin @lemire
Replace emulated unsigned shorts with chars (RoaringBitmap#364)
6ce5a5e
* replace short[] with char[] to eliminate signedness bugs
* eliminate toIntUnsigned
* eliminate compareUnsigned and simplify conditions
* rename short iterators
* optimise imports, remove some unnecesary lowbits masks
* remove some useless comparisons
* remove some warnings from run containers
* basic cleanup for LGTM analysis
@chychkan chychkan mentioned this pull request Jun 19, 2021
Upgrade RoaringBitmap from 0.6.47 to 0.9.14 (latest) jnthnclt/lab#7
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lemire lemire lemire approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@richardstartin @lemire @coveralls
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.