« first day (2611 days earlier)      last day (868 days later) » 

10:41 AM
I get to rewrite Java to Rust and I'm beyond excited to see what the differences will be. The person that requested it was interested in lower memory consumption.
4
 
10:53 AM
Cool
 
I more and more wonder if I will recode vector....
there is SO MANY thing I don't like in std
and the from is quite easy just use raw parts
to allow conpatibility
 
@DenysSéguret Denys, you are more familiar with Java, right? I am not that familiar with Java, but the idea I have of it is that it isn't the most performant when it comes to memory consumption? Of course it depends on what the program does, but in general is it hard to beat for Rust?
It's mostly focused on multi-threading, reading/parsing json and a HashMap.
I think in some sense I'm asking you to look into a crystal ball and give the most generic answer, so I'll eventually see for myself once I have some benchmarks running, but … I'm incredibly excited! It'll be my first rewrite of something else to Rust for performance reasons.
 
11:10 AM
Well, if you don't have to interface with a language where you have to give away your internals (i.e. share stuff in a thread-safe way that you also hold a reference to) then it will be a pretty smooth sail.
Pro tip: sometimes regular Vecs make things surprisingly faster over HashMaps. I couldn't believe when I looked at the profiled results -- as if all the mental models I had about datastructures and how they map to modern hardware were completely obsolete at that point.
 
yes the number of people who tell me no hashmap is faster, don't understand hashmap looked are NOT o(1)
not even counting the hashing time
but hashmap are still wonderfull
but not always the faster
 
@PeterVaro I'll experiment with these things!
 
@Stargateur Maybe you don't get it either? ;) (Perhaps I don't get it either..) It's not about amortisation and expected costs as you stated, that's negligible still. It is about cache and miss I believe.
 
both
 
@Stargateur Isn't it constant? I thought even though it's constant that doesn't mean it's fast, but still constant?
 
11:16 AM
@Jason At the very end -- just make sure they are easy to swap in and out (i.e. you have a solid isolation / abstraction around them)
 
@Jason N O P E
 
@Jason Yes, reducing memory consumption when going from Java to Rust will be a very easy goal. Perf will depend on the problem. What's the program doing ?
 
Nice dupe
 
@Stargateur Is this referring to it being probabilistic?
 
11:34 AM
Amortization costs are costs
 
even if... HashMap is probably my favorite data structure with linked list
but I get angry when people lie
but my point about recode vector was about alloc api
that try_reserve is live BUT
imagine I want to check every item I want to push doc.rust-lang.org/src/alloc/collections/vec_deque/…
this mean for EVERY ITEM it's made a lot of calcul
I want a try_push that is optimised for one item
but they refuse it
angry
99% of my use case are for one item
 
@DenysSéguret I'll unfortunately have to keep it very abstract, but it involves a ) a lot of deserialization b ) keeping many items in memory and performing expensive calculations on these as it's a graph.
It's also multi-threaded.
 
11:54 AM
This looks like something that Java does very badly
of course you'll have to be smart when replacing the "graph" structure. But it helps to have a finite application which lets you start with the right data structure
 
12:14 PM
@DenysSéguret I am already excited!
@DenysSéguret That's what I worry about the most, as (to me) it's much more difficult to do in Rust.
Then again, much more difficult to mess up than with e.g. JavaScript as well.
 
What I like for graphs is to use arenas (a simple vec is usually good) and define an indexing type by aliasing usize. You then have no borrowing problem, you have Option<MyIndex> or MyIndex instead of pointers. This doesn't protect you against logic error but it's quite easy to deal with once your mind is clear
 
(aka the lazy child tactic, they know it)
 
12:39 PM
@DenysSéguret I'll look into this, thanks! That seems to somewhat tie into Peter's tip to look into Vec as well :-)
 
12:50 PM
Vecs (and sequential accesses) are faster than most complicated solutions, yes
 
keep it simple
cause hardware is simple
 
or maybe cause hardware is complex and optimizes and prepares queues of instructions and memory and doesn't like to branch when it thought you were going to read some part of the memory cache or to execute some instructions
 
you ruin my quote but yeah
branch == bad
 
leaf == good
 

« first day (2611 days earlier)      last day (868 days later) »