Re: RFR: 8300487: Store cardinality as a field in BitSet [v7]

2023-01-22 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet [v6]

2023-01-20 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-20 Thread fabioromano1
On Thu, 19 Jan 2023 23:14:12 GMT, John R Rose wrote: > I'll pile on: This optimization doesn't buy much in today's world, where most > machines execute `bitCount` in one cycle. It saves a trivial loop. Over very > large bitsets that saves something, but most bitsets are likely to be medium > t

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread John R Rose
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread Martin Buchholz
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread fabioromano1
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread Martin Buchholz
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread fabioromano1
On Thu, 19 Jan 2023 14:03:38 GMT, fabioromano1 wrote: > Libraries cannot be all things to all users. A library provides a service > that would be difficult for a majority of users to implement on their own. > Sometimes a library needs specialization for certain use cases. That is why > we use

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread fabioromano1
On Thu, 19 Jan 2023 13:24:03 GMT, Jim Laskey wrote: > Libraries cannot be all things to all users. A library provides a service > that would be difficult for a majority of users to implement on their own. > Sometimes a library needs specialization for certain use cases. That is why > we use su

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread Jim Laskey
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-19 Thread fabioromano1
On Wed, 18 Jan 2023 21:51:02 GMT, Martin Buchholz wrote: > Like other reviewers, changing the performance tradeoffs in BitSet make me > uncomfortable. > > 30 years of code has adapted to the current performance tradeoffs. Those > users who really need O(1) cardinality() can fairly easily imple

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Martin Buchholz
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread fabioromano1
On Wed, 18 Jan 2023 14:15:17 GMT, Uwe Schindler wrote: > As one dealing with bitsets very often: In my opinion, adding this to bitset > adds too much overhead on the hot methods like set/clear methods. Especially > loops that populate a BitSet with values, I am not sure if the whole loop can >

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Uwe Schindler
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Uwe Schindler
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Claes Redestad
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Jim Laskey
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread Alan Bateman
On Wed, 18 Jan 2023 12:43:31 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Simon Tooke
On Wed, 11 Jan 2023 16:02:40 GMT, Sergey Kuksenko wrote: > It would be better to see benchmark results other than cardinality operation. > To understand how big performance regression is. Agreed - I suspect this is adding unnecessary overhead to the most common uses of BitSet; I'd be tempted t

Re: RFR: 8300487: Store cardinality as a field in BitSet [v4]

2023-01-18 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet [v2]

2023-01-18 Thread fabioromano1
On Wed, 18 Jan 2023 11:37:05 GMT, Alan Bateman wrote: > It looks all the javadoc and several areas of the code have been > re-formatted. Please revert all of this as it's impossible to see what has > been changed. Done. - PR: https://git.openjdk.org/jdk/pull/11837

Re: RFR: 8300487: Store cardinality as a field in BitSet [v5]

2023-01-18 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet [v3]

2023-01-18 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet [v2]

2023-01-18 Thread Alan Bateman
On Wed, 18 Jan 2023 11:31:23 GMT, fabioromano1 wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> wor

Re: RFR: 8300487: Store cardinality as a field in BitSet [v2]

2023-01-18 Thread fabioromano1
> The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in use by the bit set. > This optimization reduces the co

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread fabioromano1
On Wed, 11 Jan 2023 15:33:47 GMT, Claes Redestad wrote: >> I agree with the fact that is less intrusive, but certainly not potentially >> quicker, since the complete recalculation of cardinality requires linear >> time in the value of wordsInUse > > A perhaps slightly less racy way would be to

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Claes Redestad
On Wed, 11 Jan 2023 13:23:44 GMT, fabioromano1 wrote: >> src/java.base/share/classes/java/util/BitSet.java line 421: >> >>> 419: final long bitMask = 1L << bitIndex; >>> 420: words[wordIndex] ^= bitMask; >>> 421: cardinality += (words[wordIndex] & bitMask) != 0 ? 1 : -1;

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread fabioromano1
On Wed, 11 Jan 2023 12:57:47 GMT, Jim Laskey wrote: >> The enanchment is useful for applications that make heavy use of BitSet >> objects as sets of integers, and therefore they need to make a lot of calls >> to cardinality() method, which actually require linear time in the number of >> words

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Jim Laskey
On Tue, 3 Jan 2023 23:25:39 GMT, fabioromano1 wrote: > The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread fabioromano1
On Wed, 18 Jan 2023 06:36:56 GMT, Julian Waters wrote: > @fabioromano1 Would you like me to create an entry for you for the Pull > Request is linked to the appropriate mailing list? When I do that you will > have to change the name of this Pull Request though Yes, thank you very much. ---

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Julian Waters
On Tue, 3 Jan 2023 23:25:39 GMT, fabioromano1 wrote: > The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Sergey Kuksenko
On Tue, 3 Jan 2023 23:25:39 GMT, fabioromano1 wrote: > The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in

Re: RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread Simon Tooke
On Tue, 3 Jan 2023 23:25:39 GMT, fabioromano1 wrote: > The enanchment is useful for applications that make heavy use of BitSet > objects as sets of integers, and therefore they need to make a lot of calls > to cardinality() method, which actually require linear time in the number of > words in

RFR: 8300487: Store cardinality as a field in BitSet

2023-01-18 Thread fabioromano1
The enanchment is useful for applications that make heavy use of BitSet objects as sets of integers, and therefore they need to make a lot of calls to cardinality() method, which actually require linear time in the number of words in use by the bit set. This optimization reduces the cost of call