marker icon indicating copy to clipboard operation
marker copied to clipboard

[Feat]: Check the difference of `HashMap` vs `BTreeMap` in Marker's rustc driver

Open xFrednet opened this issue 2 years ago • 1 comments

Summary

Node conversion and linting often requires fetching nodes by their ids. Marker's rustc backend, just uses FxHashMaps right now, as that's the default in rustc.

However, in #246 @Veetaha pointed out that BTreeMap can be better in some circumstances:

Replaced HashMap with BTreeMap in several places to have stable sorting. Meaning, for example, if you run cargo marker several times lint crates will be compiled in the same order (instead of a random one). See also this doc for additional reasoning.

It might be worth to benchmark the driver with BTreeMap :)

xFrednet avatar Sep 18 '23 21:09 xFrednet

That JSON benchmark from David could use a really small amount of elements in the maps, I didn't look into that very closely. I just prefer BTree when it's not performance-sensitive code, but that perf comparison from David makes it sound even sweeter.

I'd trust rustc in their fxhashmap choice, but benchmarking this may still be interesting to see how much of a difference there actually is

Veetaha avatar Sep 19 '23 01:09 Veetaha