Logs: freenode/#haskell
| 2021-03-08 18:53:22 | <NieDzejkob> | yeah, print $ length $ ... uses almost the same amount of memory |
| 2021-03-08 18:53:57 | → | DataComputist joins (~lumeng@50.43.26.251) |
| 2021-03-08 18:53:59 | → | mirrorbird joins (dwsjeid911@gateway/vpn/mullvad/dwsjeid911) |
| 2021-03-08 18:54:23 | <ephemient> | e.g. if you imagine sequence specialized to list as being defined like sequence (xs:xss) = [(x:xs') | x <- xs, xs' <- sequence xss] |
| 2021-03-08 18:57:02 | <NieDzejkob> | okay, looks like sequence = sequenceA = traverse id, and traverse for List is defined with foldr, so all the combinations of tl xs need to be stored |
| 2021-03-08 18:58:56 | <ephemient> | I was trying to find the actual definition just now, you got there faster. yep, looks like inner list is shared so that accounts for the memory usage |
| 2021-03-08 18:59:11 | <NieDzejkob> | what's the best way to fix that? |
| 2021-03-08 18:59:18 | <hololeap> | :t \n -> sequence $ replicate n [1..n] |
| 2021-03-08 18:59:19 | <lambdabot> | Int -> [[Int]] |
| 2021-03-08 19:00:00 | <NieDzejkob> | > sequence $ replicate 3 [1..3] |
| 2021-03-08 19:00:03 | <lambdabot> | [[1,1,1],[1,1,2],[1,1,3],[1,2,1],[1,2,2],[1,2,3],[1,3,1],[1,3,2],[1,3,3],[2,... |
| 2021-03-08 19:00:05 | → | gitgood joins (~gitgood@82-132-219-97.dab.02.net) |
| 2021-03-08 19:00:10 | → | quackrabbit joins (8102b464@129-2-180-100.wireless.umd.edu) |
| 2021-03-08 19:01:14 | <ephemient> | try defining your own sequence like I did there? as long as the recursive call isn't shared I think it'll be O(n) |
| 2021-03-08 19:01:38 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-03-08 19:02:36 | → | ADG1089__ joins (~aditya@223.226.235.12) |
| 2021-03-08 19:03:09 | <NieDzejkob> | your definition still uses 300m |
| 2021-03-08 19:03:26 | → | berberman_ joins (~berberman@unaffiliated/berberman) |
| 2021-03-08 19:03:31 | <hololeap> | maybe define it with foldr and BangPatterns ? |
| 2021-03-08 19:03:53 | <hololeap> | i would suggest foldl', but that would mess up the order |
| 2021-03-08 19:04:01 | <NieDzejkob> | oh, but only with -O. without optimizations, it's well-behaved |
| 2021-03-08 19:04:50 | × | berberman quits (~berberman@unaffiliated/berberman) (Ping timeout: 264 seconds) |
| 2021-03-08 19:04:53 | → | HenryCH joins (~henry@2001:8e0:2003:e600:f81a:d892:d808:737d) |
| 2021-03-08 19:04:56 | <ephemient> | hololeap, I don't see what BangPatterns would help |
| 2021-03-08 19:05:26 | <koz_> | What's the goal here? Print a big-as list? |
| 2021-03-08 19:05:29 | <hololeap> | doesn't BangPatterns allow you to define eager evaluation in a function? |
| 2021-03-08 19:05:37 | <ephemient> | NieDzejkob, yeah if CSE lifts it for sharing... |
| 2021-03-08 19:05:50 | <ephemient> | hololeap: that's not the issue |
| 2021-03-08 19:06:17 | <hololeap> | oh... |
| 2021-03-08 19:06:29 | <NieDzejkob> | koz_: pretty much, print all combinations with replacement |
| 2021-03-08 19:06:53 | <NieDzejkob> | in my actual code I run another map over the list of combinations, but that's not relevant here |
| 2021-03-08 19:06:58 | <koz_> | NieDzejkob: I think you're being bitten by the fact that lists stop being lazy when they touch IO. |
| 2021-03-08 19:07:04 | <koz_> | Aka 'the thing pipes was written to fix'. |
| 2021-03-08 19:07:14 | <ephemient> | looks just like https://gitlab.haskell.org/ghc/ghc/-/issues/12620 actually |
| 2021-03-08 19:07:14 | × | augnun quits (~augnun@2804:14c:658b:41bb:7293:21b:60d:209c) (Ping timeout: 264 seconds) |
| 2021-03-08 19:07:30 | <NieDzejkob> | koz_: not really, evaluating length of the list also takes the same memory |
| 2021-03-08 19:07:49 | <koz_> | OK, then ephemient is probably right. |
| 2021-03-08 19:08:19 | × | thevishy quits (~Nishant@103.210.43.206) (Quit: Leaving) |
| 2021-03-08 19:08:50 | → | geekosaur joins (82650c7a@130.101.12.122) |
| 2021-03-08 19:09:11 | <ephemient> | -I - fno-cse :-/ |
| 2021-03-08 19:09:47 | <ephemient> | err, autocorrect turned my -O into - I |
| 2021-03-08 19:10:21 | × | Mrbuck quits (~Mrbuck@gateway/tor-sasl/mrbuck) (Quit: WeeChat 1.9.1) |
| 2021-03-08 19:10:29 | → | nineonin_ joins (~nineonine@50.216.62.2) |
| 2021-03-08 19:10:55 | × | jacks2 quits (~bc8134e3@217.29.117.252) (Quit: http://www.okay.uz/) |
| 2021-03-08 19:12:01 | <NieDzejkob> | -O -fno-cse still leaks |
| 2021-03-08 19:13:50 | × | nineonine quits (~nineonine@2604:3d08:7785:9600:d8fe:8116:376f:ddd2) (Ping timeout: 264 seconds) |
| 2021-03-08 19:14:03 | <ephemient> | hmm I don't know how to prevent that from happening then. :-( |
| 2021-03-08 19:15:49 | → | barnowl_ joins (~barnowl@gateway/tor-sasl/barnowl) |
| 2021-03-08 19:16:31 | × | HenryCH quits (~henry@2001:8e0:2003:e600:f81a:d892:d808:737d) () |
| 2021-03-08 19:16:38 | × | Yumasi quits (~guillaume@2a01cb0506313c00e14be01ac4a050f7.ipv6.abo.wanadoo.fr) (Ping timeout: 260 seconds) |
| 2021-03-08 19:16:54 | × | barnowl quits (~barnowl@gateway/tor-sasl/barnowl) (Remote host closed the connection) |
| 2021-03-08 19:18:02 | × | justanotheruser quits (~justanoth@unaffiliated/justanotheruser) (Ping timeout: 264 seconds) |
| 2021-03-08 19:20:25 | <dolio> | It can't be due to that cse example. The reason the cse example uses memory is that [1..] is retained. However, [1..8] is not big, nor is the list of 8 copies of [1..8]. |
| 2021-03-08 19:21:00 | <NieDzejkob> | it's the xs' <- sequence xss that gets retained |
| 2021-03-08 19:21:05 | <NieDzejkob> | and it's of size 7^8 |
| 2021-03-08 19:21:17 | <NieDzejkob> | or 8^7, whatever |
| 2021-03-08 19:21:22 | × | DataComputist quits (~lumeng@50.43.26.251) (Ping timeout: 276 seconds) |
| 2021-03-08 19:24:54 | × | Nikotiini quits (~ubuntu@ec2-52-213-118-142.eu-west-1.compute.amazonaws.com) (Quit: WeeChat 1.4) |
| 2021-03-08 19:26:32 | → | Nikotiini joins (~ubuntu@ec2-52-213-118-142.eu-west-1.compute.amazonaws.com) |
| 2021-03-08 19:27:36 | → | carbolymer_ joins (~carbolyme@dropacid.net) |
| 2021-03-08 19:27:38 | → | usr25 joins (~usr25@unaffiliated/usr25) |
| 2021-03-08 19:28:34 | × | carbolymer quits (~carbolyme@dropacid.net) (Ping timeout: 260 seconds) |
| 2021-03-08 19:28:46 | carbolymer_ | is now known as carbolymer |
| 2021-03-08 19:29:09 | ← | jakalx parts (~jakalx@base.jakalx.net) ("Error from remote client") |
| 2021-03-08 19:29:54 | → | DataComputist joins (~lumeng@50.43.26.251) |
| 2021-03-08 19:30:43 | → | justanotheruser joins (~justanoth@unaffiliated/justanotheruser) |
| 2021-03-08 19:31:23 | → | waleee-cl joins (uid373333@gateway/web/irccloud.com/x-jygrmrkardidqebh) |
| 2021-03-08 19:31:26 | × | bartemius quits (~bartemius@109-252-32-214.nat.spd-mgts.ru) (Remote host closed the connection) |
| 2021-03-08 19:31:43 | × | heatsink quits (~heatsink@2600:1700:bef1:5e10:9814:d93f:56c2:c87) (Remote host closed the connection) |
| 2021-03-08 19:33:16 | × | rj quits (~x@gateway/tor-sasl/rj) (Ping timeout: 268 seconds) |
| 2021-03-08 19:33:24 | × | ystael quits (~ystael@209.6.50.55) (Ping timeout: 265 seconds) |
| 2021-03-08 19:33:30 | <koz_> | Try something like 'runEffect $ each (sequence . replicate 3 $ [1 .. 3]) >-> P.print' using pipes stuff. |
| 2021-03-08 19:33:43 | <koz_> | Raise the 3s to 8s and see if it still has the same memory issues. |
| 2021-03-08 19:34:50 | → | crobbins joins (~crobbins@2603:300c:3ec:c0f0:dc2a:3f3:5dcc:77f4) |
| 2021-03-08 19:35:33 | <koz_> | (P here is Pipes.Prelude, and Pipes is imported for each, runEffect and >->) |
| 2021-03-08 19:36:00 | → | rj joins (~x@gateway/tor-sasl/rj) |
| 2021-03-08 19:36:18 | × | malumore quits (~malumore@151.62.126.188) (Ping timeout: 245 seconds) |
| 2021-03-08 19:40:48 | → | __minoru__shirae joins (~shiraeesh@46.34.207.143) |
| 2021-03-08 19:43:29 | × | justsomeguy quits (~justsomeg@unaffiliated/--/x-3805311) (Ping timeout: 260 seconds) |
| 2021-03-08 19:45:35 | × | tfl^ quits (tfl@ip98-184-89-2.mc.at.cox.net) () |
| 2021-03-08 19:46:28 | → | smctwo joins (~smctwo@86.98.5.100) |
| 2021-03-08 19:46:38 | <monochrom> | NieDzejkob: -fno-full-laziness is also worth a try |
| 2021-03-08 19:46:56 | <dolio> | This isn't caused by optimizations. |
| 2021-03-08 19:47:06 | <monochrom> | Ah OK sorry. |
| 2021-03-08 19:47:44 | <NieDzejkob> | the sequence (xs:xss) = [(x:xs') | x <- xs, xs' <- sequence xss] version is caused by optimizations, as compiling without -O gives the proper memory usage |
| 2021-03-08 19:51:36 | <monochrom> | You may want this: https://stackoverflow.com/questions/3190098/space-leak-in-list-program/5494561#5494561 |
| 2021-03-08 19:51:39 | × | notzmv quits (~zmv@unaffiliated/zmv) (Ping timeout: 260 seconds) |
| 2021-03-08 19:52:03 | <monochrom> | It is kind of well known actually. Oleg also complained bitterly on haskell-cafe. |
| 2021-03-08 19:52:29 | × | Aquazi quits (uid312403@gateway/web/irccloud.com/x-mpmnsdwmroeaiymh) (Quit: Connection closed for inactivity) |
| 2021-03-08 19:53:00 | <koz_> | OK, tried that thing above with 8s. No memory leaks at all. |
| 2021-03-08 19:56:10 | <dolio> | Oh, okay. I guess I was breaking my own rule. In ghci it behaves poorly regardless. |
| 2021-03-08 19:56:22 | <dolio> | Even with -fno-it. |
| 2021-03-08 19:57:05 | <curiousgay> | hololeap: well, actual solution to problem was simply installing ncurses-tinfo-libs in void linux, without that stack refuses to work |
| 2021-03-08 19:57:51 | × | kiweun quits (~kiweun@2607:fea8:2a62:9600:4005:e720:96ce:453e) (Remote host closed the connection) |
| 2021-03-08 19:57:55 | <hololeap> | curiousgay: hm, ok |
| 2021-03-08 19:58:19 | <dolio> | The full laziness flag would be more likely to matter, because there's no common subexpression in that code. |
| 2021-03-08 19:58:46 | → | jakalx joins (~jakalx@base.jakalx.net) |
| 2021-03-08 20:00:17 | × | LKoen quits (~LKoen@194.250.88.92.rev.sfr.net) (Remote host closed the connection) |
| 2021-03-08 20:00:22 | → | ByteEater joins (57cd846a@gateway/web/cgi-irc/kiwiirc.com/ip.87.205.132.106) |
| 2021-03-08 20:00:59 | × | frozenErebus quits (~frozenEre@94.128.82.20) (Ping timeout: 260 seconds) |
All times are in UTC.