There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

MinekPo1 ,
@MinekPo1@lemmygrad.ml avatar

Agh I made a mistake in my code:


<span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">(recalc </span><span style="font-weight:bold;color:#a71d5d;">||</span><span style="color:#323232;"> numbers[i] </span><span style="font-weight:bold;color:#a71d5d;">!= </span><span style="color:#323232;">(hashstate[i] </span><span style="font-weight:bold;color:#a71d5d;">& </span><span style="color:#0086b3;">0xffffffff</span><span style="color:#323232;">)) {
</span><span style="color:#323232;">	hashstate[i] </span><span style="font-weight:bold;color:#a71d5d;">=</span><span style="color:#323232;"> hasher.hash(((</span><span style="color:#0086b3;">uint64_t</span><span style="color:#323232;">)p </span><span style="font-weight:bold;color:#a71d5d;"><< </span><span style="color:#0086b3;">32</span><span style="color:#323232;">) </span><span style="font-weight:bold;color:#a71d5d;">|</span><span style="color:#323232;"> numbers[i]);
</span><span style="color:#323232;">}
</span>

Since I decided to pack the hashes and previous number values into a single array and then forgot to actually properly format the values, the hash counts generated by my code were nonsense. Not sure why I did that honestly.

Also, my data analysis was trash, since even with the correct data, which as you noted is in a lineal correlation with n!, my reasoning suggests that its growing faster than it is.

Here is a plot of the incorrect ratios compared to the correct ones, which is the proper analysis and also clearly shows something is wrong.

!Desmos graph showing two data sets, one growing linearly labeled incorrect and one converging to e labeled

Anyway, and this is totally unrelated to me losing an internet argument and not coping well with that, I optimized my solution a lot and turns out its actually faster to only preform the check you are doing once or twice and narrow it down from there. The checks I’m doing are for the last two elements and the midpoint (though I tried moving that about with seemingly no effect ???) with the end check going to a branch without a loop. I’m not exactly sure why, despite the hour or two I spent profiling, though my guess is that it has something to do with caching?

Also FYI I compared performance with -O3 and after modifying your implementation to use sdbm and to actually use the previous hash instead of the previous value (plus misc changes, see patch).

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines