-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Replaced Dict with OrderedDict #37804
Conversation
…ures.jl). Added also other variants, e.g. OrderedRobinDict, for now disabled. UDict is the old unordered (or unpredictable order) Dict. It is for now exported, but unclear it should be as there are better replacements e.g. SwissDict based on Google's Swiss Table.
Note, only real added file is base/ordered_dict.jl and just Dict->UDict renaming in dict.jl, so can ignore the other files. Helpful to merge the other disabled variants(?), and RobinDict, in case people want to experiment with it in base. |
The only CI fail, whitespace (well plus now "makedocs") is I guess:
for me, I wanted it to stand out, as in some sense WIP. Interesting that you can exporst undefined stuff (only UDict of those is really defined). |
We are not going to dump a whole slew of new dictionary types into Base. It would help your case if the PR did only as described, and just made Dict ordered, but it's still very uncertain whether we will do this. |
People asked for not just replacing, but also having the old Dict. I guess that's reasonable, and first with replaced it affectesd types dependent on it e.g. It's very easy to drop the other files, they are even not included (except for old Dict support). I was just working on different implementation of OrderedDict too compare, e.g. OrderedRobinDict, and if anyone would like to compare then I have the files in. We would drop them later, before Julia 1.6 release. This shouldn't stop packageeval? |
This PR isn't building, let alone passing CI, never mind being able to do a PkgEval run. |
[Outdated, see my next comment.] It's (only?) false alarms: A.
B.
The new Dict works for me, I compiled locally (first commit), with
I guess because of my: const Dict = OrderedDict [EDIT: gone in latest commit.] Is it ok to not export UDict from Base (intentionally excluding users of Julia), does it interfere with using it internally? Maybe that broke something in my subsequent commit? |
Linux CI compete (strange as I see "trigger 0 builds, 1 pending builds"). |
The package phase completed but the tests fail, see e.g. https://build.julialang.org/#/builders/34/builds/4250/steps/5/logs/stdio. |
The problem seems to be "unbound type parameters" in Method (really "UndefVarErrors"?), I'm just not sure what that means. See details on error below.
Error in last test, be e.g. not in similar test higher up:
It may be this line (nr 52 in ordered_dict.jl implicated in test failure):
seen by running the tests above from the REPL:
I just took the (working?!) code from elsewhere, and just renamed OrderedDict to Dict. |
I don't know about those test if false alarm or code broken, but I now get 157.5 ms startup of Julia (with change not in PR), faster than my best so far on master 162.2 ms. And also faster than with my current PR (with additional precompile for Revise), while still 12% slower:
[I didn't improve Revive startup speed by much, but as my precompile statements improved unchanged Revise more on my unchanged Julia master (despite now more allocations), now 12% difference. Also since my downloaded Julia master is isn't brandnew, is "Commit a0a68a5 (15 days old master)" master may have regressed and not because of my code.] |
I could silence the test error by commenting out this one line:
Is the former redundant with the latter? As of Julia 1.6 only? It there still time to get this in Julia 1.6? |
The docss test is a false alarm kind of, but the API for OrderedDict isn't the same so I need to look into e.g.: A.
B.
C. |
(from OrderedCollections.jl/DataStructures.jl).
Fixes: #34265 See also my argument: #37761 (comment)
[My first real PR, or I mean the first where I had to recompile Julia.]
Added also other variants, e.g. OrderedRobinDict, for now disabled.
UDict is the old unordered (or unpredictable order) Dict. It is for now
NOT exported, unclear it should be as there are better replacements
e.g. SwissDict based on Google's Swiss Table.
I would like packageeval run on this.
I know there are no tests (they are in the packages I took the code from). The 2x slowdown isn't real. I.e. starting Julia where I have Revise and OhMyREPL with
@time
0.948864 seconds (552.62 k allocations: 34.550 MiB)
0.856972 seconds (747.65 k allocations: 48.796 MiB, 2.50% gc time)
vs. Commit a0a68a5 (14 days old master)
0.592275 seconds (635.56 k allocations: 40.700 MiB, 1.61% gc time)
0.686102 seconds (668.09 k allocations: 44.774 MiB, 2.82% gc time)
is because of precompilation issues. Note, however former has fewer allocations, so I'm optimistic about the speed (for those, after fixing packages themselves). I looked into it and at least OhMyREPL needs more statements, independent of this, and with this a bit more.
By adding precompile statements to Revise I got slowdown limited to 10%:
There are tricks possible to make OrderedDict much faster, but not in time for Julia 1.6.0 (faster than Dict is now, for this/these cases). Startup of Julia itself
is 174.5 msvs. 162.2,extra 12 ms or 7%[EDIT: no longer slower in to come PR], likely could be faster than with Dict as it is now. See: JuliaCollections/OrderedCollections.jl#57 (comment)