Search Haskell Channel Logs

Saturday, February 11, 2017

#haskell channel featuring tfc, hpc, mangobot, cocreature, exio4, kgadek,

kgadek 2017-02-11 03:11:34
hmm, anyone mind helping a bit with performance? I stumbled upon this thread about hashtable performance http://stackoverflow.com/q/3058529/547223
kgadek 2017-02-11 03:11:41
wanted to try it out with GHC 8.0.2
kgadek 2017-02-11 03:11:47
and I'm dissatisfied :<
kgadek 2017-02-11 03:12:07
OCaml runs in ~4.4s
kgadek 2017-02-11 03:12:13
GHC in ~16
kgadek 2017-02-11 03:12:39
(gimme sec)
kgadek 2017-02-11 03:14:15
https://gist.github.com/kgadek/515e9c36bc79706cba3f5dcdc350fcbe
kgadek 2017-02-11 03:14:56
ideas?
AndreasK 2017-02-11 03:18:54
kgadek: What hashtable implementation are you using?
AndreasK 2017-02-11 03:19:25
kgadek: I think the standard is to use these from unordered-containers
kgadek 2017-02-11 03:19:29
hashtables-1.2.1.0
janos 2017-02-11 03:19:39
Hi, I have a short question regarding QuickCheck:
janos 2017-02-11 03:19:55
I'd like to make Data.UUID an instance of Arbitrary
janos 2017-02-11 03:20:12
UUID is an instance of Random
janos 2017-02-11 03:20:32
and QuickCheck provides the function chooseAny :: Random a => Gen a
cocreature 2017-02-11 03:20:53
kgadek: have you tried the other hash table implementations in that package?
janos 2017-02-11 03:20:59
but for some reason I don't know how to combine these two to get an instance Arbitrary UUID where
janos 2017-02-11 03:21:16
anybody an idea?
mangobot 2017-02-11 03:21:44
can someone help me imrove the color function? http://lpaste.net/352363 can i not access the color directly via "if color == "b" then?
hpc 2017-02-11 03:21:54
janos: arbitrary = chooseAny will work
kgadek 2017-02-11 03:21:58
cocreature: …whoah, BasicHashTable got me into 4.4s range
hpc 2017-02-11 03:21:59
janos: you just need to provide a shrink function
cocreature 2017-02-11 03:22:07
kgadek: nice!
janos 2017-02-11 03:22:10
hpc
kgadek 2017-02-11 03:22:14
cocreature: but this doesn't make too much sense
cocreature 2017-02-11 03:22:16
kgadek: the docs claim it's the fastes hash table so that makes sense
hpc 2017-02-11 03:22:24
janos: which involves having some sense of what UUID values are "simple" to test and "complex" to test
cocreature 2017-02-11 03:22:35
oh no only the fastes lookups
hpc 2017-02-11 03:22:37
janos: or what ones will be more and less likely to expose what kinds of bugs
janos 2017-02-11 03:22:45
hpc: unfortunately I get " Variable not in scope: chooseAny :: Gen UUID"
kgadek 2017-02-11 03:22:46
> Randomized testing shows this implementation of cuckoo hashing to be slightly faster on insert and slightly slower on lookup than Data.Hashtable.ST.Basic, while being more space efficient by about a half-word per key-value mapping
lambdabot 2017-02-11 03:22:49
:1:46: error: parse error on input 'of'
kgadek 2017-02-11 03:23:09
so… yeah
kgadek 2017-02-11 03:23:13
I have a lot of insertions
cocreature 2017-02-11 03:23:15
kgadek: well you are not doing randomized testing at all. you are _only_ inserting
kgadek 2017-02-11 03:23:21
yes
kgadek 2017-02-11 03:23:29
and docs state that cuckoo shall be quicker than basic
hpc 2017-02-11 03:23:31
janos: how are you importing chooseAny?
kgadek 2017-02-11 03:23:48
cocreature: that's why I said "that doesn't make much sense"
janos 2017-02-11 03:24:03
hpc: just by import Test.QuickCheck
pavonia 2017-02-11 03:24:06
mangobot: What exactly is your question? You already have that if expression there
cocreature 2017-02-11 03:24:10
kgadek: fair enough, but general statements like X is faster than Y are pretty meaningless if you only look at a specific workload
hpc 2017-02-11 03:24:20
janos: that won't bring it in scope
hpc 2017-02-11 03:24:24
janos: see https://hackage.haskell.org/package/QuickCheck-2.9.2/docs/Test-QuickCheck-Gen.html#v:chooseAny
janos 2017-02-11 03:24:59
I also import Test.QuickCheck.Gen
janos 2017-02-11 03:25:08
hpc: I also import Test.QuickCheck.Gen
hpc 2017-02-11 03:25:43
what version of quickcheck are you using?
mangobot 2017-02-11 03:25:43
pavonia http://lpaste.net/352380 i get this error when testing parseFEN
kgadek 2017-02-11 03:26:31
cocreature: well, this workload I have is matching precisely the description when Cuckoo shall be quicker. I'll create an issue anyway to discuss with author about this
janos 2017-02-11 03:26:32
hpc: good question, I am just importing QuickCheck into Stack
AndreasK 2017-02-11 03:26:39
kgadek: If your using Integer keys something like IntMap might be better to begin with.
kgadek 2017-02-11 03:26:59
AndreasK: yep, though I didn't want to in this scenario
hpc 2017-02-11 03:27:32
janos: try https://hackage.haskell.org/package/QuickCheck-2.9.2/docs/Test-QuickCheck.html#v:choose too, if that turns out to not work
janos 2017-02-11 03:27:58
hpc: I see...
pavonia 2017-02-11 03:27:59
mangobot: What is (parseColor part !! 1) supporsed to do?
pavonia 2017-02-11 03:28:05
*supposed
janos 2017-02-11 03:28:42
hpc: I just checked: I'm using LTS 7.19 which uses QuickCheck 2.8.2 which hasn't this function
mangobot 2017-02-11 03:30:44
pavonia return the color black or white if the string is "b,b,b,/... b" or "b,b,b,b/... w"
cocreature 2017-02-11 03:31:16
mangobot: the problem is that "parseColor part" is of type Color but you are treating it like a list
cocreature 2017-02-11 03:31:41
the problem is _not_ in parseColor, the problem is in parseFEN where you are trying to get the second element of "parseColor part"
cocreature 2017-02-11 03:32:12
hpc: I thought it had that already?
hpc 2017-02-11 03:32:20
it does?
cocreature 2017-02-11 03:32:25
yep, I just checked
cocreature 2017-02-11 03:32:30
"stack hoogle"
mangobot 2017-02-11 03:32:42
cocreature but parsefen splits the string into lists, no?
hpc 2017-02-11 03:32:49
huh
hpc 2017-02-11 03:33:10
i don't have it
cocreature 2017-02-11 03:33:23
mangobot: parseColor has type "[String] -> Color" so "parseColor part" is going to have type Color (or not typecheck)
hpc 2017-02-11 03:33:48
(at least on my main box, which is an older version)
cocreature 2017-02-11 03:33:56
hpc: it's relatively new
kgadek 2017-02-11 03:34:39
cocreature: FYI, https://github.com/gregorycollins/hashtables/issues/39
hpc 2017-02-11 03:34:42
nix's version might have it
hpc 2017-02-11 03:35:22
just gotta wait for it to download the LTS
mangobot 2017-02-11 03:35:23
cocreature how can i implement it correctly? define parseColor as Color -> Color?
exio4 2017-02-11 03:35:28
cocreature: woah, I didn't know
AndreasK 2017-02-11 03:35:46
kgadek: For what it's worth unordered-containers implementation is also in the same ballpark as your original code
kgadek 2017-02-11 03:36:03
AndreasK: so ~15s?
janos 2017-02-11 03:36:13
hpc: thanks, added the newest quickcheck to extra depends and it works now!
AndreasK 2017-02-11 03:36:19
kgadek: On my machine both where ~18s
cocreature 2017-02-11 03:36:28
mangobot: parseColor is just fine (well at least it's correct haskell, I don't know if it is what you want). the problem is calling !! 1 on the result. I still don't understand why you think that's the right thing to do
kgadek 2017-02-11 03:36:51
AndreasK: that's… not good
mangobot 2017-02-11 03:37:21
cocreature well i dont quite see how can i do it alternatively, if i want tos plit that string into board state, color and move later
cocreature 2017-02-11 03:37:57
mangobot: are you maybe looking for something like parseColor (part !! 1)?
AndreasK 2017-02-11 03:37:59
kgadek: Inserting 10M elements and only doing lookup once is probably not what it's designed for though. If I construct the hashmap from a list of pairs instead it cuts the time almost in halfe
kgadek 2017-02-11 03:38:03
AndreasK: oh yeah, I missed that unordered-containers is THIS unordered-containers. lol. I've tried it as well (.Strict version), got very dissatisfying results
cocreature 2017-02-11 03:38:08
otherwise this parses as (parseColor part) !! 1
cocreature 2017-02-11 03:38:26
that might explain your misunderstanding
mangobot 2017-02-11 03:38:31
cocreture within the parseFEN function?
cocreature 2017-02-11 03:38:39
mangobot: yes
hpc 2017-02-11 03:38:49
:( "stack setup" on nixos fails weirdly
hpc 2017-02-11 03:38:56
configure: error: cannot determine current directory
cocreature 2017-02-11 03:39:06
pavonia: you then need to change the type of parseColor to "String -> Color" which is also more appropriate since it only handles single element lists
kgadek 2017-02-11 03:39:11
AndreasK: well, perks of microbenchmarks. This doesn't make much sense per-se, it's there to test 'insert' performance
kgadek 2017-02-11 03:39:31
creating from [(Int,Int)] should be quicker, yes
kgadek 2017-02-11 03:39:49
but that's something (just a bit) different
kgadek 2017-02-11 03:40:08
still, if that made 18->9 s on your machine
mangobot 2017-02-11 03:40:12
cocreature it gives me the following error http://lpaste.net/352380
kgadek 2017-02-11 03:40:27
then — by my extrapolation — I assume it's still 2x slower than OCaml
tfc 2017-02-11 03:40:28
hey there. i am writing a conduit network app. it's basically "appSource A $$ myconduit =$ appSink A". in myconduit, i want to yield a "hello" string to the server, and then read exactly 13 bytes of which i want the first two bytes to be [0x10, 0], don't care about the rest. but it must be 13. i have problems implementing this conduit because i do not understand conduits well enough yet. can anybody help me?
AndreasK 2017-02-11 03:40:53
kgadek: Do you know any details about ocalms implementation?
cocreature 2017-02-11 03:40:57
mangobot: without seeing the code you're using, helping you is hard
kgadek 2017-02-11 03:41:21
AndreasK: no, unfortunately not. I'm not educated enough to verify what's happening inside as well
mangobot 2017-02-11 03:41:29
cocreature http://lpaste.net/352363
kgadek 2017-02-11 03:41:35
maybe some magic optimization happens that breaks the microbenchmark
kgadek 2017-02-11 03:41:41
because microbenchmarking is HARD
cocreature 2017-02-11 03:41:43
mangobot: you haven't changed the type of parseColor as I told you
kgadek 2017-02-11 03:41:48
I don't know
cocreature 2017-02-11 03:42:14
kgadek: that's why you use criterion for this instead of just writing a main function that runs your benchmark once :)
AndreasK 2017-02-11 03:42:16
kgadek: Does it allow sharing of older hashmaps? Not too familiar with ocalm. The unordered container implementation is still a pure one
mangobot 2017-02-11 03:43:27
cocreature missed that msg, thanks. now its says the where part doesntwork though? test.hs:43:17: parse error on input 'where'
kgadek 2017-02-11 03:43:29
cocreature: oh yes, I know. I have in my TODO list to dissect criterion into runner and stats-summarizer, plug in arbitrary stuff as former and use the latter to be able to benchmark random commands. But I don't have it today
kgadek 2017-02-11 03:43:53
AndreasK: no idea :<