mattwparas / steel

An embedded scheme interpreter in Rust
Apache License 2.0
1.05k stars 49 forks source link

Replaces HashSet and HashMap with FxHashSet and FxHashMap #165

Open TheRealLorenz opened 6 months ago

TheRealLorenz commented 6 months ago

Closes #92

Should I also migrate files that are not currently included in the project? Like, the jit mod under steel-core.

TheRealLorenz commented 6 months ago

Should I migrate the jit mod? It's not currently included in the project

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/jit/ir.rs#L1

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/jit/lower.rs#L8

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/jit/code_gen.rs#L16

TheRealLorenz commented 6 months ago

Should I migrate this commented out blocks?

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/values/contracts.rs#L3

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/steel_vm/contract_checker.rs#L4

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/steel_vm/vm.rs#L5043-L5048

mattwparas commented 6 months ago

Should I migrate this commented out blocks?

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/values/contracts.rs#L3

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/steel_vm/contract_checker.rs#L4

https://github.com/mattwparas/steel/blob/40cd3532d29b940fbd69e63f00d5444467b9a1fc/crates/steel-core/src/steel_vm/vm.rs#L5043-L5048

Anything that is commented out or not included you can skip

TheRealLorenz commented 6 months ago

Sorry if I bulk swapped everything, I initially meant to look into every single case, but I figured it would be way faster to swap everything and wait for a review, since I’m not familiar at all with the codebase.

I’m applying the corrections as soon as I can

Il giorno sab 10 feb 2024 alle 17:41 Matthew Paras @.***> ha scritto:

@.**** commented on this pull request.

Thanks for the changes! I do think I should have been more clear on "blanket" replace things, since there are some spots we don't want that, however I left some comments on where we don't want the changes.

We should try to run some benchmarks on this as well before merge to make sure we're not introducing any regressions. Once we're ready we can do that

In libs/steel-webserver/src/lib.rs https://github.com/mattwparas/steel/pull/165#discussion_r1485192860:

  • query_parameters: HashMap<String, String>,
  • query_parameters: FxHashMap<String, String>,

Can we leave these the same?

In crates/steel-core/src/rvals.rs https://github.com/mattwparas/steel/pull/165#discussion_r1485193204:

     SteelHashMap(value)

} }

[derive(Clone, PartialEq)]

-pub struct SteelHashSet(pub(crate) Gc<im_rc::HashSet>); +pub struct SteelHashSet(pub(crate) Gc<im_rc::HashSet<SteelVal, FxBuildHasher>>);

I realize this was unclear - however I would prefer if these do not take the FxBuildHasher

In crates/steel-core/src/rvals.rs https://github.com/mattwparas/steel/pull/165#discussion_r1485193360:

     SteelVector(value)

} }

[derive(Clone, PartialEq)]

-pub struct SteelHashMap(pub(crate) Gc<HashMap<SteelVal, SteelVal>>); +pub struct SteelHashMap(pub(crate) Gc<ImmutableHashMap<SteelVal, SteelVal, FxBuildHasher>>);

Same here - if we could leave these as the default hasher since these are how hash maps are implemented for values in steel

In crates/steel-core/src/steel_vm/primitives.rs https://github.com/mattwparas/steel/pull/165#discussion_r1485193787:

  • table: HashMap<SteelVal, SteelVal>,
  • table: ImmutableHashMap<SteelVal, SteelVal, FxBuildHasher>,

I think this is an erroneous change - this shouldn't be changed to an immutable hash map

— Reply to this email directly, view it on GitHub https://github.com/mattwparas/steel/pull/165#pullrequestreview-1873738135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOE5M75CXI7V224WH7KDBULYS6PLBAVCNFSM6AAAAABDB5NMH2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNZTG4ZTQMJTGU . You are receiving this because you authored the thread.Message ID: @.***>

mattwparas commented 6 months ago

Sorry if I bulk swapped everything, I initially meant to look into every single case, but I figured it would be way faster to swap everything and wait for a review, since I’m not familiar at all with the codebase. I’m applying the corrections as soon as I can Il giorno sab 10 feb 2024 alle 17:41 Matthew Paras @.> ha scritto: @*.*** commented on this pull request. Thanks for the changes! I do think I should have been more clear on "blanket" replace things, since there are some spots we don't want that, however I left some comments on where we don't want the changes. We should try to run some benchmarks on this as well before merge to make sure we're not introducing any regressions. Once we're ready we can do that ------------------------------ In libs/steel-webserver/src/lib.rs <#165 (comment)>: > - query_parameters: HashMap<String, String>, + query_parameters: FxHashMap<String, String>, Can we leave these the same? ------------------------------ In crates/steel-core/src/rvals.rs <#165 (comment)>: > SteelHashMap(value) } } #[derive(Clone, PartialEq)] -pub struct SteelHashSet(pub(crate) Gc<im_rc::HashSet>); +pub struct SteelHashSet(pub(crate) Gc<im_rc::HashSet<SteelVal, FxBuildHasher>>); I realize this was unclear - however I would prefer if these do not take the FxBuildHasher ------------------------------ In crates/steel-core/src/rvals.rs <#165 (comment)>: > SteelVector(value) } } #[derive(Clone, PartialEq)] -pub struct SteelHashMap(pub(crate) Gc<HashMap<SteelVal, SteelVal>>); +pub struct SteelHashMap(pub(crate) Gc<ImmutableHashMap<SteelVal, SteelVal, FxBuildHasher>>); Same here - if we could leave these as the default hasher since these are how hash maps are implemented for values in steel ------------------------------ In crates/steel-core/src/steel_vm/primitives.rs <#165 (comment)>: > - table: HashMap<SteelVal, SteelVal>, + table: ImmutableHashMap<SteelVal, SteelVal, FxBuildHasher>, I think this is an erroneous change - this shouldn't be changed to an immutable hash map — Reply to this email directly, view it on GitHub <#165 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOE5M75CXI7V224WH7KDBULYS6PLBAVCNFSM6AAAAABDB5NMH2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNZTG4ZTQMJTGU . You are receiving this because you authored the thread.Message ID: @.>

No worries! I should provide some more detail next time in the issue. Take your time, no rush

TheRealLorenz commented 6 months ago

Benchmarks

Unfortunately, I couldn't get rid of:

Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

TheRealLorenz commented 6 months ago

The other benches seems like they're disabled. Should I run them too? Otherwise, I'm rebasing against master and marking this PR as ready for review