Hashtbl.MakeSeeded.{add,replace,of}_seq use wrong hash function#2202
Hashtbl.MakeSeeded.{add,replace,of}_seq use wrong hash function#2202xavierleroy merged 2 commits intoocaml:trunkfrom
Conversation
The current implementation is not satisfactory, but is it really buggy? In this case you mention, the |
|
It appears to be a necessary fix for the compiler, but I agree that it doesn't look like it should be fixing it. I'll dig further. |
|
It's definitely a bug, but not exactly the one I'd stated. The problem is actually Further commit following - thanks @alainfrisch! |
Hashtbl.MakeSeeded.{add,replace}_seq were not using the hash function
provided by the functor (Hashtbl.MakeSeeded.of_seq uses replace_seq and
so also has to be redefined locally).
Book-keeping error only - although it does potentially initialise the PRNG unnecessarily.
8166903 to
b8e4c61
Compare
|
So, this time it should pass CI. cd5f93c is very important (the functor is broken, so that's a bug), 14dee98 fixes the crime of initialising the PRNG when it's not actually needed (i.e. it's not that serious, but it's better to be correct) and then b8e4c61 is what IMO the API should look like (i.e. it's much more optional a change) |
|
Ah, this was a serious bug indeed. Two comments:
|
|
For the refactor, yes agreed - although presumably better done after merging (the bug fix) since it's quite disruptive to the diff. Equally, there's a lot of duplication - is that just because the functorial interface is younger than the module itself, or is it that we need flambda for For the optional arguments, I'd marked as breaking simply because, as an interface change, it is breaking! My opinion, surprisingly at the moment for someone British, is that perhaps you cannot have your Warning 48 cake and then grumble when your use I could cope with the |
|
I find Warning 48 quite reasonable; without it, a simple identifier reference can end up executing code and allocating. It would be interesting to see how performance is degraded for code such as Anyway, the bug fix part should obviously be accepted quickly, so splitting the PR is a good idea. |
|
I wasn't arguing against warning 48, per se - it was the combination of the two features! In terms of performance, wouldn't we be micro-managing this a bit - |
|
LGTM. One could merge as is if needed, but it would be better if you could add a non-regression test for that bug. |
|
What's the status of this PR? It looks like something we want to have in 4.08 if we have it. |
|
Will be this a part of the upcoming 4.08 release if I might ask? |
|
Rebased. @gasche - sorry, this slipped off my radar, but both commits should really go into 4.08 (just to clarify, as this PR got split - there are no interface changes in this PR) @alainfrisch - I just started trying to write a test, but it seems really fake here - the only way this would break would be by actively removing those functions and any regression test wouldn't guard against the additional of some future |
|
Thanks for the ping, @XVilka! |
|
Yes, ok @dra27, we really want the fix in 4.08, with or without tests. |
|
I agree with the idea of getting this in 4.08 and I think there is still time for this. (Someone needs to approve the PR.) If we don't have tests, I would personally be interested in seeing the suggested refactoring done -- I'm assuming that @alainfrisch approves now and would be willing to review the refactoring as an extra commit. |
xavierleroy
left a comment
There was a problem hiding this comment.
Looks good to me as well.
|
@xavierleroy - we have another snap! 🙂 I was just about to push the refactor commit, but I'll put in a separate PR (it's not for 4.08 anyway) |
This GPR initially addresses a bug, which is that
Hashtbl.Make.of_seqcreates hash tables in randomized mode, if it has been turned on (e.g. withOCAMLRUNPARAM=R). It then goes one step further and, given that it wrapsHashtbl.create, adds the?randomparameter toHashtbl.of_seq.of_seqalso creates hash tables with a hard-coded initial size of16, so while I was there, I added?size. This gets propagated toEphemeron.The first commit should really go in 4.08
- the interface change in the second only adds optional parameters, so should also be safe to go in, even at this stage? Are we planning 4.07.2 (@damiendoligez)?cc @c-cube, @bobot