Ah, yes, indeed it matters "where" the array is amended.

Somehow I was expecting sparse arrays to use hashing, rather than sorting,
but then again 4$. is always sorted (and it's above my league). I will try
to understand what's going on in the "farewell for now" discussion and see
what comes out of that, because it might include what I'm actually looking
for. Meanwhile, thanks for the fix (in the next beta).

Ben

On Thu, 15 Apr 2021 at 06:14, Henry Rich <[email protected]> wrote:

> Interesting problem.  Sparse amend sorts the indices; they are mostly in
> order but with some small values at the end.  I previously implemented a
> quicksort for integer lists, usually fast but this hit a worst-case.
> Since I think the case is not unusual I have changed the choice of
> pivot.  Fixed for next beta.
>
> Henry Rich
>
> On 4/13/2021 7:52 PM, Ben Gorte wrote:
> > Perhaps in a bit of a clumsy way I tried to report last Thursday that
> > inserting a value in a large sparse array (changing an element from
> "zero"
> > into something else) had become quite slow.
> >
> > SIZE=:1000000000000000
> >
> > A =: 1 $. SIZE
> >
> > i =: ?1000000 $ SIZE
> >
> > v =: 1+?1000000 $ 1000
> >
> > 6!:2 'A =: v i } A' NB. insert 1 million values
> >
> > 0.179232
> >
> > 6!:2 ' A =: (999) 12345678901234 } A' NB. one more value
> >
> > 99.8308
> >
> >
> > The time depends strongly (quadratically?) on the number of elements
> > already in the array.
> >
> >
> > This is J-903. In J-902 the same amend takes 220s. Apparently it is a J9
> > thing, because I had not noticed it earlier. I checked with j64-807 and
> it
> > is only 0.24s.
> >
> >
> > Usually I'm on Linux, but meanwhile I tried the same in Windows 10 with
> > similar results.
> >
> >
> > Perhaps I'm the only one with this issue, but I wonder whether this
> >
> > is this a glitch in the current J system that may be repaired -- or am I
> > somehow doing something inappropriate and is there a much better
> solution?
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to