New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deterministic random in UUID #19411
Deterministic random in UUID #19411
Conversation
I don't think it's a good idea to make I also don't understand why you change |
Or you not believe in math or something? We will choose equally good function. Math.random actually a bad PRNG, but it use time inside. |
@Mugen87 the idea of using a deterministic random function is to make sure the screenshots used for CI testing are always the same and the tests are actually reliable. But I also don't understand how
I don't think that is necessary. Mugen asked a straight forward question, there's no need for this sort of stance. We're all trying to work together towards a better library, let's try and be courteous to one another. |
The reason why UUID can use another random function (or big integer iterator) actually quite simple. For example after refactoring in the core, you create a new textures/meshed that invoke Math.Random() in another sequence. After that we need to recreate 92 screenshots. We don't have any non deterministic part in the core except this UUID generation. So the easiest way to prevent this in future was this commit. Yes exist a way how to fix it in other style. For example we can use PRNG in all examples directly. But I need to find all the places and fix it. If he meant this, why he didn’t say? Especially when he block the same commit from WestLangley. We also can proof that this commit with sin() function was not good enough and will cause to collision, because it was based cyclic function with some period P in one random, and P+1 with P+2 will also collide in this situation, because of the nature of this cycles. Obviously that current situation with refactoring in the core not good and should be fixed. And we should work in collaborative way and give a good feedback, instead of such a dumb questions when he knew what's wrong was with this commit. Straight forward way is to say what's wrong and suggest another way. Right now we talking about all off this, instead of solving problems. |
I am suggesting to use special build of a library with fixed random for testing. |
I see several issues:
|
Sorry, but what you are saying is really offensive and I refuse to review code from you any longer. |
@Mugen87 I will glad for that, thanks. This commit is good and solve a problem generally because we need another deterministic function in UUID for testing to prevent such a problem with refactoring in future. But it not fit to production and we can make special build for testing. That's all. |
Can you please explain what does this PR solve? Also, when changing You can read more here: #13069 |
This PR is not ready for merge, but I am already explained two times, while you guys not and I need to guess what's wrong. We need two deterministic random functions in tests because simple hook for the Math.Random not enough, also we can't change all 92 example, this is contr-productive and makes examples harder to read. The idea is to have another seed for random functions in UUID. |
Actually current UUID generator is interesting. We not measured probability of collisions and just trust to 3 built-in Math.Random with some time based hash. BigInt probably better fit, but it's not widely supported. |
Sorry, I don't have time to read the discussion and related discussions. Can you share a link to the post where you explained it? |
Why is not enough? |
We use window.Math.Random in UUID and same window.Math.Radnom in examples. Give collaborator right back and I will explain 5-th time :D |
@mrdoob I think he gist of it is, if the screenshot is based on value №123, 124 and 125, and then you make a change in 3js that makes one more uuid to be created, the same example is now based on values 127, 128 and 129. Since Mugen does not want prng in uuid, I suggested getRandomValues for uuid instead |
@makc Thank you! I understand now. |
How about doing: /* Deterministic random */
let seed = Math.PI / 4;
window.Math.random2 = function () {
const x = Math.sin( seed ++ ) * 10000;
return x - Math.floor( x );
}; And then dynamically replace all the Basically, separating the |
Probably will solve a problem but maybe not. The hard part here:
So I guess this solution will be not robust, since we can't find a moment when all resources created. |
We need to load all resources prior to rendering once with a deterministic generator. We generally do not write the examples that way. |
Need to try it, it’s easier in implementation. |
This comment has been minimized.
This comment has been minimized.
Need to try it again, maybe UUID cycled or something. Looks a good hack, actually. |
This comment has been minimized.
This comment has been minimized.
here is a russian saying for you: после драки кулаками не машут. it was 2 weeks ago, no point to ask that now. |
|
Follow up discussion in #17949