<< 10-09-2018 >>

00:02:33*druonysus quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
00:02:46FromGitter<gogolxdong> push to channel, sleep every 3 seconds.
00:03:24FromGitter<bung87> it's about syntax
00:08:11FromGitter<gogolxdong> ```import posix ⏎ ⏎ while sleep(3) == 0: ⏎ do something``` [https://gitter.im/nim-lang/Nim?at=5b95b5ebe481f854a694e915]
00:14:44FromGitter<bung87> thanks , but I'm asking about syntax,I want code exactly write as that.
00:15:37FromGitter<bung87> seems `do` will treats 3.seconds as a proc ,I give up
00:16:13*druonysus joined #nim
00:16:13*druonysus quit (Changing host)
00:16:13*druonysus joined #nim
00:21:23FromGitter<gogolxdong> have no idea there is schedule and every syntax.
00:22:47FromGitter<kayabaNerve> @bung87 A macro.
00:23:01FromGitter<kayabaNerve> You can have a macro parse that and emit valid Nim code.
00:24:03FromGitter<bung87> @kayabaNerve I tried, but the `do` command will take left as proc first
00:24:58FromGitter<kayabaNerve> Write a better macro
00:25:12FromGitter<kayabaNerve> πŸ€”
00:25:22FromGitter<bung87> ```code paste, see link``` ⏎ ⏎ these 3 ways I have now. [https://gitter.im/nim-lang/Nim?at=5b95b9f1a04db554a700f274]
00:25:52FromGitter<kayabaNerve> That is unhelpful af. I know. That said, to get that exact line of Nim to work properly... You need a macro.
00:28:34FromGitter<bung87> hmm not familar with macro, I tried template and macro even not implements just leave `discard` , the `do` requires left is proc will first come up.
00:29:59FromGitter<bung87> that says I need 3.seconds return a proc that would rewrites procs in `times` module
00:30:03*seni quit (Quit: Leaving)
00:31:36FromGitter<kayabaNerve> I don't know macros myself. I'm just commenting it's the only surefire way to have the compiler see invalid statement X as valid statement Y.
00:32:21FromGitter<kayabaNerve> Depending on what of `schedule.every 3.seconds do:` is actually valid, you may be able to not need macros. I just don't know what module you're working off of.
00:32:43FromGitter<gogolxdong> do is a syntax sugar alias of closure in you context I think.
00:32:45FromGitter<bung87> thanks! anyway I'm fine now with current I have, 3 ways to do same thing I think that's enough.
00:33:43FromGitter<bung87> I push it to github https://github.com/bung87/scheduler/blob/master/src/scheduler.nim
00:34:11FromGitter<gogolxdong> spend some time on macro ,might findd it helpful.
00:34:23FromGitter<bung87> I'll think about what's next lib I'm interested to write.
00:40:06FromDiscord<exelotl> I'm so confused on how to achieve what I want in Nim :(
00:42:31FromGitter<bung87> I'm using vscode with Nim extension, the nimsuggest will tell me whats wrong I'm doing. think it helpful.
00:42:51*Calinou quit (Remote host closed the connection)
00:44:00*Calinou joined #nim
00:44:19*xomachine[m] quit (Ping timeout: 264 seconds)
00:44:33FromGitter<gogolxdong> why don't you just define Scheduler as ref object?
00:44:54*sg-james[m] quit (Ping timeout: 264 seconds)
00:45:49*xomachine[m] joined #nim
00:46:20*sg-james[m] joined #nim
00:47:21FromGitter<bung87> to simply init a Scheduler with one line? I think
00:51:30FromDiscord<exelotl> I think Nim's methods are a poor fit for my game engine idea because there will be a broad, shallow heirarchy (everything extends Entity). My understanding is that with dispatch trees, the more subclasses you have, the slower each method call becomes.
00:51:37FromDiscord<exelotl> So I need a vtable or something. But I have no idea how to implement that with the available tools (how does 'of' work at runtime? Can I get that info too? is it possible to pull internal info out of a typedesc?)
00:54:13FromGitter<gogolxdong> you can do that with ref object too , new returns ref managed by GC, once uses ptr ,you manage memory by yourself.
00:56:43FromGitter<gogolxdong> result is an implicit variable of proc, better not define a variable named result explicitly.
01:00:39FromGitter<bung87> didnot see much differences in my case. and second every implements base on copy first implements that's why there's result,but have no return type
01:06:14FromGitter<bung87> @exelotl I tried `method` once ,feels like an alias to `proc` but less mentioned on documents.
01:09:17*SenasOzys joined #nim
01:14:12FromGitter<gogolxdong> How about the memory of a ptr Scheduler which addr references to ?
01:15:11*dddddd quit (Remote host closed the connection)
01:24:19FromGitter<bung87> can you show some code explain what would be a problem?
01:30:22*krux02 quit (Remote host closed the connection)
02:00:38FromGitter<gogolxdong> No. I just wonder whether the memory allocated by object constructor and passed its address to an object field via ptr will leak. ptr declares untraced references.
02:06:13FromGitter<gogolxdong> There is no difference if it doesn't since Nim syntax is flexible enough to achieve the same goal, except I wouldn't like to write ref in every proc arguements list.
02:15:55*SenasOzys quit (Remote host closed the connection)
02:16:20*SenasOzys joined #nim
02:17:58FromGitter<DanielSokil> What is the difference between `assert` and `doAssert`?
02:23:56FromGitter<gogolxdong> https://github.com/nim-lang/Nim/blob/devel/lib/system.nim#3790
02:24:13*SenasOzys quit (Ping timeout: 245 seconds)
02:24:21FromGitter<gogolxdong> assert raises Raises ``AssertionError``
03:19:13*druonysus quit (Read error: No route to host)
03:42:55FromGitter<arnetheduck> bumped `nlvm` to latest upstream - though it's a bit of a pain, I'm happy that so many globals are gone - first step towards compiler-as-a-library which can open up a wide array of uses cases - nice @Araq !
04:16:32FromGitter<DanielSokil> @gogolxdong Thanks!
04:37:39*darithorn joined #nim
04:38:41*endragor joined #nim
05:32:18*nsf joined #nim
06:07:57*darithorn quit (Quit: WeeChat 2.2)
06:22:00*couven92 joined #nim
07:18:33FromGitter<Grabli66> Hi! I want to find a way to build dynamic libraries in Nim, with async io. And i see that i can't use async io and compile dynamic library with nimrtl. Will my dynamic library work as it should, if i compile it with gc:stack and without nimrtl?
07:36:26*tiorock joined #nim
07:36:26*rockcavera quit (Killed (livingstone.freenode.net (Nickname regained by services)))
07:36:26*tiorock is now known as rockcavera
07:36:26*rockcavera quit (Changing host)
07:36:26*rockcavera joined #nim
07:37:44*floppydh joined #nim
07:44:54*cwilby joined #nim
07:51:05*PMunch joined #nim
08:03:47*gmpreussner quit (Ping timeout: 240 seconds)
08:03:52*gmpreussner_ joined #nim
08:10:19*cwilby quit (Remote host closed the connection)
08:10:33*cwilby joined #nim
08:11:22*xet7 joined #nim
08:16:54*ginger_bill_ joined #nim
08:18:00*Vladar joined #nim
08:25:17*ginger_bill_ quit (Quit: Page closed)
08:26:32*ginger_bill joined #nim
08:37:18*ginger_bill quit (Ping timeout: 252 seconds)
09:12:36*stefanos82 joined #nim
09:14:50*ftsf joined #nim
09:29:18FromDiscord<gingerBill> Hello
09:29:50FromDiscord<gingerBill> Could some help me with a syntax question/design decision?
09:30:05FromDiscord<gingerBill> Why are both of these allowed?
09:30:05FromDiscord<gingerBill> ```nim
09:30:05FromDiscord<gingerBill> proc foo(a, b: int; c, d: int): int = # semicolon as separator
09:30:05FromDiscord<gingerBill> return a+b+c+d
09:30:05FromDiscord<gingerBill>
09:30:06FromDiscord<gingerBill> proc foo(a, b: int, c, d: int): int = # comma as separator
09:30:07FromDiscord<gingerBill> return a+b+c+d
09:30:07FromDiscord<gingerBill> ```
09:30:17FromDiscord<gingerBill> Reading the compiler shows that it allows both, but I question why.
09:30:17FromDiscord<gingerBill> https://github.com/nim-lang/Nim/blob/c033ff990acceac6d2095242fa17501e98555973/compiler/parser.nim#L1031
09:34:50*ftsf quit (Quit: Leaving)
09:36:47*kapil___ joined #nim
09:42:14PMunchWell, you are also allowed to do (x, y, z: int, a, b, c: string)
09:42:28PMunchIn this case it might be clearer to do (x, y, z: int; a, b, c: string)
09:43:00PMunchAraq in fact wants to use ; as the separator, but most people seem to prefer ,
09:43:23PMunchI think both are allowed because of this, you can choose between clarity or familiarity
09:48:07*Sembei joined #nim
09:48:27FromDiscord<gingerBill> That just seems like a very weird and arbitrary decision.
09:48:43FromDiscord<gingerBill> So you support both because some people like one way.
09:48:47*Pisuke quit (Ping timeout: 240 seconds)
09:50:08FromGitter<mratsim> no
09:50:17FromDiscord<gingerBill> So you support both because some people like one way?
09:50:23FromGitter<mratsim> comma carries the type declaration to the next argument
09:50:36FromGitter<mratsim> while semicolon does not
09:50:54FromGitter<mratsim> proc foo(a, b: int) is valid, proc foo(a; b: int) is invalid
09:50:55FromDiscord<gingerBill> Could you give me an example, please?
09:51:09PMunchOh yeah, they are functionally different
09:51:12FromDiscord<gingerBill> `proc foo(a, b: int; c, d: int)` and `proc foo(a, b: int, c, d: int)` are same, is what I am talking about.
09:51:27FromDiscord<gingerBill> How is that functionally different?
09:51:47PMuncha, b: int is allowed a; b: int is not, that's how they differ
09:51:52FromGitter<mratsim> this is useful for generics `proc fooT; U: SomeInteger (a: T, b: U)` is very different from `proc fooT, U: SomeInteger (a: T, b: U)`
09:52:07PMuncha: int, b: string and a: int; b: string does the same thing
09:52:11FromGitter<mratsim> in the first case T can be anything while U is an integer types
09:52:25FromGitter<mratsim> in the second both T and U are integer types (but an differ from each other)
09:52:30FromGitter<mratsim> can*
09:53:20PMunchHmm strange, the FromGitter bot removes [] in your code snippets..
09:53:39FromGitter<mratsim> gitter is broken with brackets :/
09:53:58FromDiscord<gingerBill> To be clear `a: int, b: string` and `a: int; b: string` are identical then?
09:54:04FromGitter<mratsim> yes
09:54:09FromDiscord<gingerBill> Is this just a quirk of the syntax or a design choice?
09:54:29FromGitter<mratsim> it’s less rules when parsing
09:54:54FromGitter<mratsim> comma carries unless a type is declared, semicolon never carries type.
09:54:54FromDiscord<gingerBill> Interesting.
09:55:23FromGitter<mratsim> otherwise you would have to add an extra rule to prevent either semicolon or comma
09:55:25FromDiscord<gingerBill> Thank you for the help. I was a little confused as I have seen most people use `,` but the official docs use `;`.
09:55:52FromGitter<mratsim> it might be that when generating docs the compiler uses semicolon by default as well
09:56:36FromDiscord<gingerBill> I was reading the source and it seems that the `when defined(nimpretty2)` uses semicolons.
09:57:01FromGitter<mratsim> ah that :P there is a RFC/debate on that iirc
09:57:04PMunchYes according to NEP-1 you should use ;
09:57:47PMunchOh wait, maybe not
09:57:54PMunchBut araq certainly prefers ;
09:58:39FromDiscord<gingerBill> I'm on Pascal programmer and I do like `;` so neither bothers me.
09:59:03FromDiscord<gingerBill> *I'm an old
10:04:17*cwilby quit (Ping timeout: 250 seconds)
10:04:49FromDiscord<gingerBill> Thank you all your help everyone. This was a little confusing to see that was all.
10:04:59*cwilby joined #nim
10:07:10FromGitter<mratsim> you’re welcome
10:21:58*endragor_ joined #nim
10:22:21FromGitter<Grabli66> People. Is it possible to create working dll, with async io, GC, and without nimrtl?
10:22:47*endragor quit (Ping timeout: 240 seconds)
10:24:07PMunchGrabli66, last time I tried to create a Nim dll I ran into lots of trouble with the GC
10:25:25PMunchhttps://github.com/nim-lang/Nim/issues/6886
10:26:05PMunchPlus I think nimrtl is required to let Nim connect to the GC, why do you want to do without it?
10:32:52FromGitter<Grabli66> PMunch, cause it's impossible to use async with nimrtl https://github.com/nim-lang/Nim/issues/6855
10:33:54PMunchAh
10:34:06PMunchWell, I think dynlibs in Nim is broken atm..
10:34:15PMunchThe GC doesn't seem to work at all
10:34:52FromGitter<Grabli66> It's sad :(
10:37:11PMunchYeah..
10:38:35FromGitter<Grabli66> Maybe it's possible to turn on --gc:stack, and don't use nimrtl in DLL. But i don't know will it work right or not :(
10:40:33PMunchHmm, maybe
10:40:37PMunchHaven't tried it
10:43:22*pwntus joined #nim
10:46:06*krux02 joined #nim
10:48:24FromGitter<krux02> @kaushalmodi are you still planning to fix issues on nim-mode in emacs?
10:49:39FromGitter<krux02> I was digging very deep into creating a major mode in emacs, and it is a real pain for me to do so.
10:50:18FromGitter<krux02> I could find out what is causing pig preformance problems in nim-mode, but I don't have the expertise alone to fix it.
10:50:44FromGitter<krux02> maybe you have a better idea
10:58:50*vivus joined #nim
11:01:12vivushi all. I have a table type that has an object (of 2 strings) stored in each key:value set of the table. How do I print out each string from the table on its own?
11:02:18*dddddd joined #nim
11:03:05vivushttps://www.zerobin.net/?650ab716226743a8#qXFwcRjvsBshM52X9S/gpd6ZZS1aCI2K/lGifc3nIYQ=
11:03:20PMunchvivus, for obj in myTable: echo obj.strA; echo obj.strB
11:03:25PMunchSomething like that?
11:04:07vivusPMunch: current I am doing this: for key, value in myitems: echo value ... but it shows both the strings when I echo value.
11:04:32PMunchYes, because value is the object
11:04:39PMunchkey is the key in the table
11:04:54vivusPMunch: how do I access each value separately?
11:05:09PMunchLike you normally would with an object
11:06:44vivusPMunch: im unfamiliar with that. I tried: `value.name` but got a compile error
11:06:58FromGitter<xmonader> what was the command to autoformat nim code? is it a separate package? nimfmt or nimpretty? or is it in core bins?
11:08:35FromGitter<narimiran> @vivus: `for key in myitems: for category in myitems[key]: echo category.name, category.color` ?
11:09:13PMunchOr just myitems.items
11:09:51vivusit says .items is an undeclared field
11:10:39PMunchHmm, maybe it's called something else. Look under iterators in the manual page for tables
11:13:10FromGitter<bung87> nimpretty your.nim
11:14:22FromGitter<xmonader> @bung87 is that in 0.18 binaries?
11:14:51FromGitter<bung87> I build all from source not sure if it packed with release
11:15:02vivushere is my code and the compile error I get: https://www.zerobin.net/?88e517c6464a95c3#0EUuDEuB1peYiDKZQvQE7SzY1uPXO/cBezE+kXucme8=
11:18:00vivusokay I fixed it
11:18:12vivusneeded to understand sequences
11:25:27*zachcarter quit (Ping timeout: 252 seconds)
11:28:34FromGitter<kaushalmodi> @krux02 I'll find some time this week to analyze what part of nim-mode degrades the performance, even with nimsuggest disabled.
11:29:24FromGitter<kaushalmodi> @xmonader nimpretty is in devel branch
11:29:52FromGitter<xmonader> I see. thanks
11:31:09FromGitter<xmonader> can someone approve this? https://github.com/nim-lang/packages/pull/853 ⏎ ⏎ also do i've to release the packages to be used as dependency in my local system? or do they have to be under 1 project? because it's not the case
11:36:28FromGitter<mratsim> use nimble develop
11:39:47FromGitter<xmonader> thanks @mratsim
11:40:00*jxy quit (Read error: Connection reset by peer)
11:40:11*jxy joined #nim
11:49:57*kapil___ quit (Quit: Connection closed for inactivity)
11:53:44FromGitter<kaushalmodi> > also do i've to release the packages to be used as dependency in my local system?
11:53:46FromGitter<kaushalmodi> No
11:54:21FromGitter<kaushalmodi> You can just do `nimble install` on the local dependencies without first publishing them.
11:54:34vivusis `id` a special keyword in nim?
11:54:35*Etheco joined #nim
11:56:54FromGitter<mratsim> no
12:04:28PMunchvivus, oh sorry. I couldn't look at your code and didn't realize you had a sequence of objects
12:04:32PMunchSorry if I confused you
12:04:57vivusPMunch: np :) not your fault, I just needed to investigate and understand it better myself
12:16:16FromGitter<krux02> @kaushalmodi according to my benchmarks most performance is lost in nim-backtick-matcher
12:16:42FromGitter<krux02> and within that, it is syntax-pps
12:16:54FromGitter<krux02> so fewer calls to syntax-ppss would be an improvement
12:18:10krux02@kaushalmodi I really wonder if there is a better way to support a language within a language.
12:18:57vivuswhat string proc can I use to convert a float to a string?
12:19:10krux02I would search for parse float
12:20:12krux02vivus, parseFloat is the acutal name
12:20:29vivuslike this: parseFloat(id) ?
12:20:51krux02what do you mean with id?
12:21:00krux02parseFloat("123.456") should work
12:21:22vivusdo I need to import strutils?
12:21:32krux02that functoin is in strutils, yes
12:22:26vivuskrux02: parseFloat converts a string to a float, I want to to from float to string
12:23:09krux02oh, sorry
12:23:19krux02$ should work
12:23:45krux02there should also be a format float proc somewhere
12:23:49krux02not sure about the syntax
12:24:18*Sembei quit (Read error: Connection reset by peer)
12:25:09vivusty, I found the formatFloat in strutils
12:25:26*Sembei joined #nim
12:26:54vivushow do I reduce my float to 1 decimal?
12:27:16krux02reduce?
12:27:21krux02you mean truncate
12:28:51vivusyeah reduce it from: 1.100000000000000 to 1.1
12:30:01FromGitter<jrfondren> 1) 100000.formatFloat(ffdecimal, 1)
12:32:44vivusty
12:32:45vivusthat worked
12:34:51*nsf quit (Quit: WeeChat 2.2)
12:35:41FromGitter<Bennyelg> check the length of set?
12:35:47FromGitter<Bennyelg> var t1 = set[char]
12:35:51FromGitter<Bennyelg> t1.len ? not working
12:35:53FromGitter<tim-st> card?
12:36:14FromGitter<Bennyelg> thanks I would never guess it alone
12:36:20FromGitter<Bennyelg> why not just do len?
12:36:25FromGitter<tim-st> len is there in devel
12:36:36FromGitter<tim-st> cardinality is math term for length of set
12:37:00FromGitter<krux02> well in "math" I use "number of elements"
12:37:12FromGitter<Bennyelg> how do I get the first element in my set
12:37:18FromGitter<Bennyelg> t1[0] not working too :|
12:37:25FromGitter<jrfondren> if you put 10x of the same element a set, it only has 1 item
12:37:26FromGitter<tim-st> set is not ordered
12:37:37FromGitter<Bennyelg> I know
12:38:04FromGitter<krux02> and in Nim ``len`` means "number of elements"
12:38:04FromGitter<tim-st> only ordered collection can be indexed
12:38:04FromGitter<Bennyelg> so tell me the "number of elements" in my set :)
12:38:14FromGitter<krux02> @tim-st these terms are stupid, maybe they make sense in math, but in Nim a set is very much ordered
12:38:47FromGitter<krux02> it is always ordered the same way, and there is no way to change the order, but it is ordered
12:39:10FromGitter<tim-st> https://nim-lang.org/docs/sets.html#OrderedSet should have index
12:39:35FromGitter<Bennyelg> tRIED ORDEREDsET
12:39:40FromGitter<Bennyelg> tried orderset * no index.
12:40:21FromGitter<tim-st> not implemented, likely because array has wholes, but can be implemented
12:40:45FromGitter<krux02> don't use OrderedSet
12:40:48FromGitter<Bennyelg> So said sets not beahive like seq / array at most of the time
12:40:53FromGitter<jrfondren> same reason that hash tables don't have numerical indexes, even though the backing array is certainly ordered
12:40:55FromGitter<krux02> I never had a use case for that data structure
12:41:17FromGitter<Bennyelg> I have one now and I impleminted it using seq and then deduplicate
12:41:28FromGitter<Bennyelg> but I want more efficiant solution with set
12:41:40FromGitter<krux02> is it a performance bottleneck?
12:41:55FromGitter<tim-st> it's only more efficient with a bigger size, how much entries expected?
12:41:57FromGitter<Bennyelg> It can be,
12:42:24FromGitter<Bennyelg> not much I assume now that Im thinking of it
12:42:34FromGitter<Bennyelg> But set solution is more programatic
12:42:48FromGitter<krux02> people underestimate the performance of flat data structures
12:42:58FromGitter<krux02> seq[T] is very fast
12:43:05FromGitter<krux02> when T is POD
12:43:09FromGitter<krux02> (plain old data)
12:43:20FromGitter<Bennyelg> I roll it back to seq ;]
12:43:36FromGitter<krux02> good.
12:43:45FromGitter<jrfondren> anyway you might want an OrderedSet with .items.toSeq after you populate it, as an alternate to building a seq and then deduping it
12:43:53FromGitter<krux02> when it really becomes big, it might be worth it to use something more intelligent
12:44:04FromGitter<Bennyelg> yea
12:44:29FromGitter<krux02> @jrfondren no
12:44:37FromGitter<tim-st> I now test if `async` really makes problems or if socket is the real problem regarding memory leaks
12:46:07FromGitter<krux02> @jrfondren the point is that is is faster to scan through the entire seq of elements that hashing a single element, look in the hash table and do the comparison there.
12:47:12FromGitter<krux02> hashing has O(1) performance, but it is not fast
12:48:12FromGitter<jrfondren> the only part of the intended work that I've followed is "I want to build a seq of arbitrary size and then dedupe it". For that it should be hard to beat OrderedSet for time and space efficiency. but if it's some trivial task, fine
12:51:42FromGitter<tim-st> without `async` it leaks too, but like 10mb less, but still too much
12:52:39FromGitter<tim-st> I also tested Pythons version: click download it increases 2mb ram, download finished: goes back to normal ram size
12:55:05FromGitter<tim-st> for the first two calls it goes up then for the next it stays at this memory amount, I cannot trust this
12:56:35FromGitter<dm1try> @tim-st what are you testing? is this repo https://github.com/tim-st/nim-zim?
12:57:03FromGitter<tim-st> yes, different commits (latest and older before changing to async)
12:57:23FromGitter<tim-st> but many people (also in on forum and jester and mofuw and so on) reported this
12:57:36FromGitter<dm1try> I tested it yesterday and did not notice some memory leaks
12:57:54FromGitter<tim-st> Did you chose "Project Gutenberg" that ships out pdf files?
12:58:05FromGitter<tim-st> with html you will have to open many files
12:58:44FromGitter<dm1try> > Did you chose "Project Gutenberg" that ships out pdf files? ⏎ ⏎ nope, will try later to reproduce
12:58:57FromGitter<tim-st> ok, thanks, I tested windows and linux
12:59:01FromGitter<tim-st> sync and async
12:59:18*zacharycarter joined #nim
13:01:30FromGitter<dm1try> actually I tried to open many links and when tested one link with `wrk`; memory usage had some "plato" value ~20Mb; it is on MacOS
13:02:25FromGitter<tim-st> dont know if wrk is good, it doesnt react to the response
13:02:59FromGitter<tim-st> I will try to play with gc settings, I read a few times: "It's not a bug it's a feature" (memory strategy)
13:03:37zacharycarterIf I passed an untyped parameter a macro that has some Nim code in it - how can I execute that Nim code and put the result in the code's place in the AST?
13:03:45zacharycarterto a macro*
13:07:27krux02so you want to pass code to a macro that generates the code
13:08:14zacharycarterlet me give you an example
13:08:36krux02zacharycarter, you can create a local macro with the body, and call that
13:09:12zacharycarterhttps://gist.github.com/zacharycarter/fb5e29214fd9f06fe7d2e9ad8c0a4652
13:09:50FromGitter<dm1try> > I will try to play with gc settings, I read a few times: "It's not a bug it's a feature" (memory strategy ⏎ ⏎ when digging in `coro` module I noticed that GC does not return the memory to OS if `alloc0` is used and the memory chunk is "small enough"(on my machine this value is 1GB), so if some code uses `alloc0` and this allocation is less than 1GB the memory is not returned to OS but "reserved" to the future usage
13:10:09FromGitter<dm1try> is this correct? could someone to confirm?)
13:10:29zacharycarterI want to execute the Nim code after the !
13:10:33zacharycarterand stick the result in its place
13:11:01zacharycarterI'll try putting a local macro in krux02
13:11:11zacharycarterwhat should I create in that macro? a call node?
13:11:15FromGitter<dm1try> @tim-st how do you measure a memory stats btw?
13:11:33FromGitter<xmonader> do i need special configurations for nimble tests using a package i ran `nimble develop` on ? ?
13:11:57krux02zacharycarter, http://ix.io/1mop
13:12:16FromGitter<tim-st> @dm1try I look in the taskmgr (the same like for python)
13:12:50zacharycarterkrux02: thank you
13:14:20*TheLemonMan joined #nim
13:20:01FromGitter<tim-st> @dm1try I think there is a problem with the gc, when I add `getOccupiedMem` and `getOccupiedMem` for each request sometimes the number of free mem just doubles without need
13:24:00FromGitter<dm1try> @tim-st ok, will try to reproduce/re-test the issue a little bit later and let you know)
13:24:34FromGitter<tim-st> thanks, do you know how I can set a gc strategy?
13:25:08FromGitter<tim-st> I want GC_Strategy.gcOptimizeSpace
13:25:21FromGitter<tim-st> and see if it behaves different
13:26:31FromGitter<tim-st> ok, I read it's deprecated and is a nop
13:29:31zestyrtim-st: you can run `GC_getStatistics()` to print some proper info about the memory usage
13:29:52FromGitter<tim-st> zestyr: thanks, will try
13:31:02krux02@kaushalmodi gl.nim is full of backticked identifiers that are not in comments at all. I guess this cases a lot af trouble and performance problems
13:35:22FromGitter<Grabli66> How to efficent store HashSet in Table? HashSet is not a referrence object. It will be copied everytime when i take it from table?
13:36:38leorizeyou certainly can make a table of `ref HashSet`
13:36:50FromGitter<xmonader> ```code paste, see link``` ⏎ ⏎ How to debug this? [https://gitter.im/nim-lang/Nim?at=5b9673720fb4232e38a239ac]
13:37:52FromGitter<tim-st> @xmonader if you found the bug, please report the `???` thing, that's an import bug
13:37:58FromGitter<tim-st> important
13:37:59FromGitter<krux02> @xmonader you check out the nim source code and search for "n is not nil" as error message
13:38:19leorizexmonader: it's in sem pass IIRC
13:38:19FromGitter<krux02> and then you see how that bug can occur
13:38:47FromGitter<Grabli66> leorize, i tried to do so. But i dont undertand how to create new ref HashSet. There is initSet procedure but it creates HashSet, not a ref HashSet
13:38:47FromGitter<tim-st> @xmonader here: https://github.com/nim-lang/Nim/issues/7268
13:38:47FromGitter<krux02> @tim-st befere reporting, the bug needs to be analyzed
13:39:33FromGitter<xmonader> I'm using 0.18 is that still a problem? I can't tell ppl in the company to use devel branch
13:40:59FromGitter<Vindaar> @xmonader I think that's a known issue, see here: https://github.com/nim-lang/nimble/issues/456
13:41:12leorizeGrabli66: use this proc https://nim-lang.org/docs/sets.html#init,HashSet[A],int
13:41:50leorizeuse new to generate a reference, then pass it to that proc for initialization
13:48:24*cspar_ joined #nim
13:50:28FromGitter<xmonader> @Vindaar thank you, i'll try :( i wish it was smoother...
13:51:42*cspar quit (Ping timeout: 244 seconds)
13:53:33FromGitter<tim-st> From my tests with gc I'd it works quite good as long as the total amount of memory is enough, if not it makes it larger but then does not make it smaller again (or maybe at a time in a future)
13:54:49FromGitter<tim-st> because of this people only reported this problem "when shipping out big files" because for small files the total amount is always enough
13:55:17FromGitter<Grabli66> leorize, init does not work ⏎ type mismatch: got <ref HashSet[collector_device.CollectorDevice]> ⏎ ⏎ but expected one of: ⏎ proc initA (s: var OrderedSet[A]; initialSize = 64) ... [https://gitter.im/nim-lang/Nim?at=5b9677c433ebb72e37f81584]
13:56:20leorizeyou have to de-reference it like this `init(hash[], ...)`
13:56:39leorizethe `[]` is the dereference operator
13:59:08FromGitter<Grabli66> Great. Now it works. Thanks
14:00:20FromGitter<Grabli66> Don't understand why HashSet is not a referrence type by default.
14:07:37Guest21953Ok guys, I have to give up on Nim again, I'll (we) probably revisit it again. The major reason seems to be "unpredictability" of asyncdispatch and related.
14:08:32FromGitter<Grabli66> Is there a possibility to pretty print content of Table to console?
14:08:59TheLemonManunpredictability?
14:09:23TheLemonManGrabli66, $table ?
14:09:31Guest21953eaten exceptions, "hidden dragons"
14:10:00Guest21953or weird behaviours like socket.send("SOMETHING") always finshes without error when socket was connected and some transmission was done through it
14:10:24FromGitter<arnetheduck> @Guest21953 you might be interested in https://github.com/status-im/nim-asyncdispatch2 which is a fork to deal with some of the problems and start using it in a p2p setting that should stress it to its core
14:10:31Guest21953at least that's how it behaves now, because pretty sure that some time ago it was behaving differently (fut.failed is false which means that it succeeeded)
14:10:59Guest21953I checked it already
14:11:06Guest21953it also had critical bug
14:12:06*Guest21953 is now known as pigmej
14:12:28pigmejbasically you change code in one place other place explodes
14:13:42pigmejI wanted to also check reactor but then dom96 said (he was right) that for language consistency I should try asyncdispatch
14:15:23TheLemonManzacharycarter, ping
14:15:33zacharycarterhi TheLemonMan
14:16:26TheLemonManpigmej, if you didn't already please open a few tickets on github, that's the only way to improve the ecosystem:)
14:16:35*endragor_ quit (Remote host closed the connection)
14:16:36pigmejI already did :)
14:16:47pigmejeven submitted PR for async dispatch
14:16:52pigmej(it have been merged)
14:17:22pigmejThe thing is .... I can't trust the code
14:18:39TheLemonManzacharycarter, sorry, wrong person (and chan, and window :)! How's your templating lib going?
14:19:25pigmejand the funny thing is that I still hope that nim will rock, but it seems to be too inmature for me (at least async part) to trust it enough for production system
14:19:36zacharycarterTheLemonMan - good thank you! I finished the initial port of hyperHTML, and switched gears to working on a macro to produce ES2015 classes and CustomElements etc...
14:20:21zacharycarterso at this point it's just improving and iterating the macro and porting a few remaining bits of hyperHTML - hopefully will have our first web component done later today with Nim
14:21:45TheLemonMannoice, I've seen the gist you posted yesterday(?) and was amazed heh, you can do so much with some macros
14:22:09zacharycarter thanks! yeah :D they are super powerful;
14:23:08TheLemonManan ES6-targeting backend would also be a nice side project...
14:25:45FromGitter<gogolxdong> Will there be a demo or example of hyperHTML, what's the concept behind?
14:30:51FromDiscord<awr> hi
14:30:58zacharycartergogolxdong: https://viperhtml.js.org/hyperhtml/documentation/
14:35:51FromGitter<gogolxdong> which would you suggest our production frontend migrate to , karax or hyperHtml?
14:36:05*Etheco- joined #nim
14:36:50FromGitter<gogolxdong> we use vue.js at the moment.
14:40:06*Etheco quit (Ping timeout: 264 seconds)
14:40:54*PMunch quit (Quit: Leaving)
14:41:05FromGitter<gogolxdong> I want frontend be material design style, only succeed partially using DOM.
14:42:29FromGitter<tim-st> @gogolxdong do you use a http server written in nim?
14:42:55FromGitter<gogolxdong> yes.
14:43:16FromGitter<gogolxdong> which we have worked on for half a year.
14:43:30FromGitter<tim-st> does it work without leaks? how many requests at max and how long does it run?
14:44:59*leorize quit (Read error: Connection reset by peer)
14:45:43*leorize joined #nim
14:46:31FromGitter<krux02> @kaushalmodi are you online?
14:46:55FromGitter<kaushalmodi> Yep
14:47:15FromGitter<krux02> I would really like to contribute to nim-mode, but I need support to do so
14:47:17FromGitter<gogolxdong> good question, you can test https://www.bafang.cloud
14:47:52FromGitter<krux02> nim-mode is really quite complex and big and I only understand a fraction of what is going on
14:47:58FromGitter<kaushalmodi> @krux02 I am not the nim-mode developer. But you can start an issue/PR in the nim-mode repo and I will join in
14:48:23FromGitter<krux02> then who is the nim-mode developer?
14:49:11FromGitter<gogolxdong> memory leakage is what I am concerning , but with packedjson, the memory usage has been reduced dramatically.
14:49:20FromGitter<kaushalmodi> @krux02 https://github.com/nim-lang/nim-mode
14:49:39FromGitter<kaushalmodi> https://github.com/nim-lang/nim-mode/graphs/contributors
14:50:07FromGitter<kaushalmodi> It's mainly Yuta Yamada
14:50:14FromGitter<tim-st> @gogolxdong ok, do you use `asynchttpserver` with nims default gc?
14:50:30FromGitter<DanielSokil> Hello, I have a question regarding `iterator`.
14:50:33FromGitter<tim-st> I thought about finishing my jsonstream lib that uses nearly no memory
14:50:33FromGitter<gogolxdong> --gc:regions
14:50:35FromGitter<kaushalmodi> I see that he's not very active lately.. but if you open an issue/PR and if he doesn't respond in timely manner, then I can fork it
14:50:45FromGitter<krux02> I need to chat in person with Yuta Yamada otherwise there is no chance for me to improve nim-mode
14:50:45*zacharycarter quit (Ping timeout: 252 seconds)
14:50:50FromGitter<gogolxdong> good to know.
14:51:00pigmejkrux02: why?
14:51:10FromGitter<gogolxdong> might help.
14:51:19FromGitter<kaushalmodi> @krux02 Just ping him in an issue and explain this issue
14:51:47FromGitter<krux02> I have several issues in nim-mode
14:51:52FromGitter<krux02> no response
14:52:05FromGitter<tim-st> @gogolxdong thanks, I will test this regions thing, maybe this helps
14:52:16FromGitter<krux02> https://github.com/nim-lang/nim-mode/issues/198
14:52:21*gangstacat quit (Quit: Ĝis!)
14:52:26pigmejI'm pretty sure that I still have merge rights if sth
14:52:29pigmej(in nim-mode)
14:53:06krux02pigmej: do you understand emacs and nim-mode?
14:53:40krux02I need someone to talk to, it is very frustrating to fix nim-mode issues in isolation and then get refused pull requests
14:53:49pigmejI authored some stuff there ~3y ago
14:53:49krux02that is my experience with nim-mode in the past
14:54:02krux02what did you author?
14:54:24pigmejcompany afair
14:54:34krux02I disabled company mode
14:54:37pigmej;D
14:54:38krux02in nim
14:54:40krux02too slow
14:54:44pigmejhmmm
14:54:57krux02basically everything in nim-mode is too slow to work with
14:54:59krux02even font lock
14:55:05pigmejnimsuggest is probably the cause
14:55:08krux02yes, syntax highlighting is too slow
14:55:11FromDiscord<awr> yeah i had to disable nimsuggest too
14:55:14FromGitter<gogolxdong> asynchttpserver yes , another thing is public resource runs out of 8G memory in 2 mins, because the response of different providers from different regions concurrently is memory consuming, which have not been profiled.
14:55:15FromDiscord<awr> company mode too
14:55:38pigmejlet me check something, there was some setting that I used to enable
14:55:42FromDiscord<awr> eldoc too
14:55:46krux02I do computer graphics programming, I know how to implement things fast
14:56:10krux02and what I understood so far from font-lock mode, it is horribly slow
14:56:12pigmejsome parts that are used to connect to nimsuggest are in sync mode
14:56:24pigmejbut font-lock mode .... that would be weird
14:56:40krux02yes font-lock mode is freezing my editor
14:56:42FromDiscord<awr> honestly we really need a whole new emacs for the 21st century rather than an emacs that pretends like it's in the 21st century
14:56:46krux02and I found out the problem
14:56:51krux02it is the backtick matching
14:56:57krux02I don't understand fully how it works
14:57:23krux02I don't like the coding stylie of nim-syntax very much, I have problems reading the code
14:57:31krux02I need a day to understand 20 lines of code
14:57:38krux02full time
14:57:48krux02because everything is new in there
14:57:53pigmejthat's a part that is mystery to me too ;/
14:57:57krux02every used function I need to look up, then I need to learn it
14:57:58krux02etc
14:59:18FromGitter<kaushalmodi> krux02: The font-lock freezing up would be, I think, just bad code
14:59:18krux02pigmej, but you can try to fix the performance problems with nimsuggest
14:59:32FromGitter<kaushalmodi> Org mode, et al use much more complex font locking and those don't freeze up
14:59:44pigmejthere is one easy fix that I'm trying to remind myself now
15:00:32*vivus quit (Remote host closed the connection)
15:00:36pigmejfor sure you can try to remove --refresh option from nimsuggest
15:00:41krux02kaushalmodi: yeas the code is bad. But "your code sucks in every possible way" it is not the best opener to get help
15:00:45pigmejbecause it tend to explode everything
15:01:09krux02pigmej, no I don't dig into nimsuggest now
15:01:18krux02syntax highlighting is more important
15:01:30pigmejfrankly speaking I never had problem with syntax highlighting
15:01:32krux02but you can try to fix the problem it is important
15:01:35pigmejmaybe it's because of my environment
15:01:54pigmejkrux02: I have literaly 0 time, and as I wrote I'm probably stepping back from Nim again ;/
15:02:09pigmejbut company should be fast enough with `--refresh` removed
15:02:15krux02pigmej, did you ever open the opengl bindings file in nim-mode?
15:02:21pigmejno
15:02:21FromGitter<kaushalmodi> krux02: I can help intermittently this week; step by step we will improve the syntax highlighting
15:02:29krux02that is a file that is for the most part generated from the openGL spec
15:02:37krux02much bigger than other files
15:02:51krux023300 lines
15:02:58krux02but still not vastly big
15:03:12krux02but that just kills the syntax highlighting
15:03:44krux02kaushalmodi, as I said, it is the backtick matcher
15:03:46pigmejlink
15:04:27krux02aparently to highlight the ``backticks`` in comments, there is a function that scans to a comment start, then scanns to all backticks from there
15:04:43krux02no matter if they are still in the comment or not
15:04:49pigmejaha
15:04:56pigmejok then I can imagine how bad it becomes
15:04:58FromGitter<kaushalmodi> krux02: Yes, I read that.
15:05:05krux02`nim-syntax.el'
15:05:14krux02`nim-backtick-matcher'
15:05:19pigmejkrux02: I meant opengl file :)
15:05:25krux02ah
15:05:30FromGitter<kaushalmodi> I'd start by first disabling that matcher altogether and see what that could break.
15:05:53krux02https://github.com/krux02/opengl-sandbox/blob/master/glad/gl.nim
15:06:17pigmejhmm you can safely remove it nothing will break
15:06:28krux02I modified that file to disable font-lock-mode but still enable syntax highlighting once
15:07:05pigmejsubmit PR to disable backtick highlihgting?
15:07:30krux02pigmej, for sure that will be rejected
15:08:29FromGitter<kaushalmodi> pigmej: That's not a solution. I suggested that as a means to start debugging.
15:09:08krux02this is the end of my nim-mode hook:http://ix.io/1moR
15:09:11FromGitter<kaushalmodi> The solution should allow doing the backtick highlighting without notable performance impact.
15:09:38FromGitter<kaushalmodi> krux02: Pinging on emacs help mailing list would also help. Post the offending snippet and the profiler report
15:11:52pigmejI don't know that part of a code that much that I could help folks
15:14:03krux02kaushalmodi: I am in emacs irc, and I got the hint to do fontlock-studio
15:14:06krux02it helped
15:14:46FromGitter<kaushalmodi> krux02: Yes, I have heard of that package. That dev is Emacs font locking pro
15:15:07FromGitter<kaushalmodi> Anders Lindgren
15:16:05FromGitter<kaushalmodi> I see that he responds to font locking issue emails on the emacs devel mailing list
15:19:40*kapil___ joined #nim
15:20:40FromGitter<gogolxdong> Is there any way to test memory leakage?
15:22:28*Trustable joined #nim
15:22:52leorizegogolxdong: there's LeakSanitizer if you use gcc/clang
15:24:15*gangstacat joined #nim
15:24:28FromGitter<gogolxdong> thanks, will check out.
15:29:43FromGitter<tim-st> this is a minimum reproducable example without dependencies to see what I mean with leaks: https://gist.github.com/tim-st/30eb88b2a96fdd77623be945dff5fc2a
15:31:15FromGitter<tim-st> After the file is downloaded the RAM should go down but for `http://localhost:8080/blob/size/100000000` it stays at 436mb, and I dont want to try bigger downloads...
15:32:20TheLemonManwell, that's not a memory leak
15:32:27FromGitter<tim-st> what is it?
15:32:30TheLemonManit's just how the GC behaves
15:33:07FromGitter<tim-st> it always stays at the biggest size that was requested once and increases from this size slowly by time
15:33:20FromGitter<tim-st> why not go down again like python?
15:33:36FromGitter<tim-st> I heard the nim forum servr crashes after a month or so
15:34:07TheLemonManhmm, it should not increase if the heap becomes large enough
15:34:13*cwilby quit (Ping timeout: 245 seconds)
15:34:46FromGitter<tim-st> My guess is that `resize` is called for increasing and decreasing but `resize` only increases
15:34:50pigmejanyone have exp with reactor.nim ?
15:35:13pigmejprobably besides zielmicha__
15:36:02TheLemonManyeah but once you make the heap big enough to handle the peak value its size should be quite constant (unless another bigger chunk is requested)
15:36:19TheLemonManbut yeah, GC are often very reluctant to release memory back to hte OS
15:37:19FromGitter<tim-st> no, there is another problem: once the total gc amount was resized (increased) the current occupied amount is now higher than it was in a smaller total amount although the same "work" was done or nothing was done at all
15:37:55pigmejTheLemonMan: for me it always grows too
15:38:05FromGitter<tim-st> you can see this by following gcStatistics after some time
15:38:17FromGitter<tim-st> I tried ~60 minutes
15:38:32pigmejI'm already at GC_getStatistics: [GC] total memory: 112558080
15:38:55pigmejGC_getStatistics: [GC] total memory: 151158784 now
15:39:09FromGitter<tim-st> the total memory is not a hard problem, the hard problem is the currentOccupied Memory is not consistent but grows too
15:39:34FromGitter<tim-st> the total memory could be made smaller but the totcal occupied not, that's a bug/leak imo
15:39:43FromGitter<tim-st> but I'm not an expert of course
15:41:40pigmejI ran wrk against it
15:41:51pigmejand well.... memory ended on my server :)
15:45:05FromGitter<krux02> @kaushalmodi I wrote Anders Lindgrep a personal e-mail
15:45:19FromGitter<krux02> I don't want to be part of any mailing list.
15:46:03FromGitter<krux02> I never worked with mailing lists and I don't want to. I fear too much spam in mail mail inbox.
15:46:09FromGitter<krux02> It is already too much today
15:46:18pigmejTry notmuch :)
15:46:21FromGitter<kaushalmodi> @krux02 You have some wrong notion about mailing lists
15:46:34FromGitter<kaushalmodi> You just email to the list and request that you be CC'd
15:46:39FromGitter<kaushalmodi> You don't have to subscribe to one.
15:46:48*zacharycarter joined #nim
15:47:05FromGitter<kaushalmodi> For the record, I have been subscribing to emacs-help, emacs-devel, org mode mailing list for about 8 years now; 0 spike in spam
15:47:37FromGitter<krux02> that is unknown technology to me
15:47:51FromGitter<kaushalmodi> umm.. it's plain email
15:48:00FromGitter<krux02> yea
15:48:02FromGitter<krux02> I kno
15:54:08FromGitter<tim-st> TheLemonMan: if I download repeadetly from `http://localhost:8080/blob/size/100000000` not at the same time it still increases ram by much; now I'm from 365mb at 925mb
15:56:49TheLemonManI think that happens because the cycle checker threshold grows as the heap gets larger and you end up overallocating
15:57:13FromGitter<tim-st> so it's a bug?
15:58:06FromGitter<tim-st> on Python I never reach more than 80mb
16:00:12FromGitter<tim-st> why does it say: `[GC] occupied memory: 704745664` isnt that cleaned before increasing size?
16:01:33TheLemonManlet Araq tell if it's a bug or not (a feature perhaps? :)
16:03:00FromGitter<tim-st> I mean I understand that the gc increases total amount when it thinks it doesnt has enough free memory left, but afaik I shouldnt have any occupied mem and it tells me I have 700mb occupied
16:08:08*miran joined #nim
16:09:15miranhey all! i've (finally) started experimenting with macros. is there any tutorial about macros?
16:12:31miran`dumpAstGen` is great, but i still have trouble connecting everything into a coherent macro
16:14:24FromGitter<Vindaar> @miran: `dumpTree` or from within a macro `treeRepr` as well as `repr` itself are really useful too. I don't know about any real tutorials though (besides what's in Nim in Action, but to me that was way too advanced when I first read it)
16:15:53FromGitter<Vindaar> for me just playing around (sometimes with macros other people wrote) helped the most
16:16:28FromGitter<Vindaar> I wanted to learn macros in the beginning, but looking back what held me back the most, was not realizing what might be possible with a macro and what isn't
16:17:39miranok, i've manged to create a type declaration for a ref object, and a proc that receives an instance of that object and does something with it. now i need to create an instance and call the proc - i'm not sure how to do it
16:17:48FromGitter<kaushalmodi> Sorry @Vindaar, I was supposed to get back to you after trying out Nim macros.. I am faced with some block that just prevents me from doing that.
16:17:50FromGitter<kaushalmodi> some day ..
16:18:31FromGitter<Vindaar> @kaushalmodi haha, no worries at all! :) I get lost "getting back to things" all the time too
16:19:21FromGitter<Vindaar> @miran: that sounds like you're already well under way
16:20:04miran@Vindaar: as i said, `dumpAstGen` is the real hero. i just copy-pasted stuff produced by it
16:20:24FromGitter<Vindaar> haha, ok. I've been surprised by how well that worked, too :D
16:20:59FromGitter<Vindaar> If you have some code you want to produce from what kind of input, I
16:21:12FromGitter<Vindaar> I'm happy to try to help
16:21:44miranok, let me make an example, just a sec
16:21:52TheLemonMandon't forget about "quote"
16:22:17FromGitter<Vindaar> good point, that's even more useful :)
16:23:50miranhttp://ix.io/1mpg
16:24:10miranunder the line is what i'm trying to do curently
16:24:41miranTheLemonMan: i have seen `quote do` here and there, but haven't used/understood it yet
16:25:32FromGitter<Vindaar> `quote do` basically allows you to write normal Nim code and have that converted to the `NimNode` representation
16:26:33TheLemonManyeah, but it allows you to plug various pieces (NimNodes) from the outer scope
16:29:26FromGitter<mratsim> think of it as interpolating compile-time with run-time
16:29:57FromGitter<mratsim> just like &”My fixed and {interpolated} string"
16:30:39FromGitter<Vindaar> hehe, I should let smarter people than me talk :D ⏎ miran: I assume that `Shape` and the `kind` enum would already be defined, yes?
16:31:02miranyes, they are defined, as is `calcArea` proc
16:36:46*abm joined #nim
16:36:46mirani did this in my macro: http://ix.io/1mpn and `a` is `IntLit` - don't know how to pass that to a proc which creates an instance of `Shape`, there is no `IntLit` type!?
16:37:02*nsf joined #nim
16:38:48*shadowbane quit (Remote host closed the connection)
16:40:31*shadowbane joined #nim
16:42:20FromGitter<Vindaar> using `quote do`, something like what you did there and a lot of hardcoded things (:P), you can do something like this: http://ix.io/1mps/nim
16:43:46miranthanks @Vindaar! from a quick look, it seems like `toNimIdent` is what i need
16:44:24miranand it seems this `quote do` is something i really need to start using :)
16:44:36FromGitter<Vindaar> yes, it's *really* helpful
16:46:55miranOMG, this `quote do` is magic!!
16:47:21miransorry `dumpAstGen`, i now have a new best friend!
16:47:22FromGitter<kaushalmodi> miran: Please enlighten with a blog post or something :)
16:47:48FromGitter<kaushalmodi> I need to bookmark this conversation for now
16:48:00miran@kaushalmodi: once i get more familiar with it β€” i'll do it
16:48:05FromGitter<Vindaar> and it's good to keep in mind that you can just define compile time procs, which handle certain parts of the code you construct by having them work on `NimNode`. e.g. refactoring the above to: http://ix.io/1mpu/nim
16:48:54mirani'll post my coplete code when i finish it, so y'all can take a look (and give me advice what to change :))
16:49:33FromGitter<Vindaar> :)
16:50:11mirani managed to do it!!! wooohooo!
16:50:33miran@Vindaar thank you very much for the example, it was very helpful!
16:51:46FromGitter<Vindaar> cool, glad I could be of service :D
16:53:47*Trustable quit (Remote host closed the connection)
16:56:13miranhere it is: http://ix.io/1mpv/
16:59:23miranand with some comments to see what each proc does: http://ix.io/1mpw/
17:00:18FromGitter<Vindaar> nice!
17:00:31miranprocs were created with `dumpAstGen`, don't know if this was the way to go, or there is some simpler way to do these things
17:00:41FromGitter<Vindaar> and the types defined like this make a lot more sense :D
17:00:46FromGitter<dm1try> > this is a minimum reproducable example without dependencies to see what I mean with leaks: https://gist.github.com/tim-st/30eb88b2a96fdd77623be945dff5fc2a ⏎ ⏎ yep, I'm playing around with this code and notice that on every request there is at least 3 allocations (each of them equal a body size) and only 2 deallocations later
17:01:34FromGitter<dm1try> used `logAlloc = true` and call `GC_full_collect` before each request
17:06:08FromGitter<razuit> is it possible to import a const with .importc? Looking at importing a const from a C .h header file without redefining it
17:07:29FromGitter<mratsim> yes but only as a var
17:08:25FromGitter<tim-st> @dm1try very good catch, exactly my feeling when I recognized it had the same ram grow curve like no gc at all
17:08:54FromGitter<tim-st> I tried GC_full_collect already didnt change
17:10:09FromGitter<razuit> @mratsim how would that look like?
17:12:37*voice_ftp joined #nim
17:15:53*voiceftp quit (Ping timeout: 276 seconds)
17:22:20*a_b_m joined #nim
17:23:24*darithorn joined #nim
17:25:28*abm quit (Ping timeout: 245 seconds)
17:39:21*PMunch joined #nim
17:40:47*smt` joined #nim
17:41:13*smt` quit (Max SendQ exceeded)
17:42:49FromGitter<mratsim> var foo {.importc β€œCname”, header: β€œpath/to/header.h”.}
17:43:27*smt quit (Ping timeout: 240 seconds)
17:44:17*epmor joined #nim
17:45:42*epmor quit (Client Quit)
17:45:55*epmor joined #nim
17:48:40FromGitter<DanielSokil> Hello, What is a good example of when to use `reference types` vs `non-reference types`? ⏎ ⏎ *Here is a non-ref object:* ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5b96ae77728ddf02828ad364]
17:51:37FromGitter<glassofethanol_twitter> So ref allocates heap storage?
17:52:49*epmor quit (Quit: leaving)
17:55:32FromGitter<DanielSokil> "Traced references point to objects of a garbage collected heap" ⏎ https://nim-lang.org/docs/manual.html#types-reference-and-pointer-types
17:55:56FromGitter<glassofethanol_twitter> Ah I see
18:05:10FromGitter<Vindaar> @DanielSokil aside from potential performance differences, it makes a big difference regarding mutability of the underlying object
18:10:03*krux02 quit (Remote host closed the connection)
18:12:54*erratic quit (Ping timeout: 252 seconds)
18:14:59FromGitter<DanielSokil> @Vindaar Could you please further explain what you mean by: "mutability of the underlying object"?
18:18:12FromGitter<kayabaNerve> If I pass an object from A to B and alter it in B, the one in A is also altered
18:18:19FromGitter<Vindaar> if you use `let` on a non ref object, it cannot be modified, while using `let` on a ref object you can happily modify the underlying object (just not the reference)
18:18:45FromGitter<kayabaNerve> (because it's the same object and you're just passing a reference)
18:19:15FromGitter<unreadable> how long till Nim reaches v1.0?
18:19:15FromGitter<Vindaar> in your example for the ref object, `person1` can also be declared as `let` and it will still change the name of `person1`
18:19:26FromGitter<kayabaNerve> And sure. Let behaves very differently. It makes sense why.
18:19:54FromGitter<Vindaar> if you wanted to change a name of a non ref object, you'd need to 1. declare it as a `var` and 2. (if done via a proc) have that proc take a `var Person` argument
18:20:56miran@unreadable: that is the forbidden question here :P
18:21:20FromGitter<kayabaNerve> Or take in ref Object and use ref Object from the start.
18:24:21miran@DanelSokil: http://ix.io/1mpJ/ notice the difference in declaring persons (let vs var) and in procedures (PersonRef vs var PersonObj)
18:27:06FromGitter<unreadable> oke
18:40:24FromGitter<tim-st> @dm1try the same for sync version of httpserver: https://gist.github.com/tim-st/abbb86a591172a7b997c853fcda5cff9
18:40:43FromGitter<tim-st> the problem is gc or socket
18:40:58FromGitter<kayabaNerve> EZ
18:41:01FromGitter<kayabaNerve> Just disable the GC
18:43:17FromGitter<tim-st> I try to find out if my nim code can be used in production or if I need parts in go, I think "disable gc" is not the best help here
18:43:22miran@unreadable: v0.19 should be out soon (TM), and from what i know, v1.0 is planned after that
18:43:48FromGitter<kayabaNerve> No. It's not. I was trying to make a joke.
18:44:09FromGitter<kayabaNerve> Disabling the GC actually disables a lot of features.
18:44:33FromGitter<tim-st> actually it compiles fine without gc but the system crashes after a few minutes
18:45:07FromGitter<kayabaNerve> Interesting.
18:45:23FromGitter<tim-st> well of course there are warnings
18:47:14FromGitter<unreadable> @miran that's great
18:51:19FromGitter<DanielSokil> @unreadable Probably close to 2019, v19 in 2019, make sense to me.
18:51:37FromGitter<DanielSokil> beta release could be earlier.
18:52:41FromGitter<DanielSokil> @kayabaNerve @Vindaar Thanks, I really appreciate it.
18:56:24TheLemonMantim-st, there's an interesting section in gc.rst about how to dump the heap
18:56:37TheLemonManyou may want to use that to further debug that problem
18:57:40FromDiscord<exelotl> anybody know how I can make this work? https://gist.github.com/geckojsc/e1b68d957bc4bdf4008b716341fe163a
18:59:19*druonysus joined #nim
18:59:19*druonysus quit (Changing host)
18:59:19*druonysus joined #nim
19:01:33*zacharycarter quit (Ping timeout: 252 seconds)
19:04:56PMunchexelotl, well I did it this way in SDLGamelib: https://github.com/PMunch/SDLGamelib/blob/master/gamelib/ticker.nim
19:05:53FromGitter<tim-st> TheLemonMan: thanks, that's a good hint, the number of allocs and deallocs is completely different...
19:06:06FromGitter<tim-st> [Heap] allocs/deallocs: 159/97
19:06:58PMunchIt's not perfect as it wraps Tickables in an extra proc
19:07:38FromGitter<tim-st> for repeated calls the number of allocs increases linear and the number of deallocs stays const
19:08:03PMunchBut it's very generic, anything that can tick with a milliseconds count can be added to the ticker
19:08:35FromDiscord<exelotl> ah yeah I see you're doing it with an anonymous proc
19:09:49*cyraxjoe quit (Remote host closed the connection)
19:10:02FromGitter<tim-st> TheLemonMan: If I understand this correct I have 43 strings on heap with nearly 400mb which fits with the number of occupied bytes in gc, so they just dont get collected
19:10:38TheLemonManhave you tried forcing a fullcollect after the response is sent?
19:10:41FromDiscord<exelotl> I was hoping to avoid wrapping the call because I'm guessing there's some overhead involved
19:11:09FromGitter<tim-st> TheLemonMen: I did this before at start but can do it again at start and end
19:15:15PMunchexelotl, if it's not important for you to give them different names you can simply call them both update
19:15:26PMunchAnd let Nim sort of which one to use when you call an object
19:16:24FromGitter<tim-st> TheLemonMan: this works better but still allocs are ~ +50; the ram still stays at largest that was requested and dont goes back
19:16:25PMunchHmm, that doesn't work for putting them in a list though..
19:18:20*riidom quit (Ping timeout: 268 seconds)
19:19:35FromDiscord<exelotl> yeah exactly. Nim provides methods instead of procs to solve this exact problem, except my understanding is that Nim method calls compile into 'dispatch trees'
19:19:42PMunchexelotl, you can have a look at how yglukhov does it here: https://github.com/yglukhov/ecs
19:19:43FromDiscord<exelotl> which are effectively a bunch of if statements to check the type at runtime and call the correct procedure. Therefore the more types you have, the slower your program gets.
19:20:48PMunchBasically what he does is every time you try to add an entity of a new kind to a world it creates a new sequence of that type. When you add an entity that's seen before it's added to the corresponding sequence.
19:32:54FromGitter<tim-st> TheLemonMan: It seems like nondeterministic behaviour sometimes it cleans a bit then it does not at last I had it at 592mb ram for small request and fullCollect two times in proc: https://gist.github.com/tim-st/abbb86a591172a7b997c853fcda5cff9
19:35:06TheLemonManweird, memory usage stays stable for me
19:35:41FromGitter<tim-st> what do you mean by memory usage? occupied or total?
19:35:47FromGitter<tim-st> are you on linux?
19:35:55TheLemonManboth and yes
19:36:10FromGitter<tim-st> I'm on windows
19:36:57FromGitter<tim-st> when you download like 100mb does it go back under 100mb some time?
19:39:06TheLemonManno, but I've already told you countless times that memory is not released to the OS
19:40:05FromGitter<tim-st> so once it's over 1gb a nim program can never use less ram than 1gb?
19:41:27FromGitter<tim-st> I have like 50 processes open, every one of them goes up and down with ram usage, only the nim program does never
19:43:08TheLemonManI'll bite...when should the GC release memory to the OS then?
19:43:09FromGitter<tim-st> I'm now implementing the same example code in go to see if it does down there (I think it does)
19:44:02*erratic joined #nim
19:44:18FromGitter<tim-st> it should do this by looking at the growth factor, when it has too much total memory it should resize by div 2 if it has too less it should resize by mul 2
19:44:41pigmejTheLemonMan: That's not true using examples from tim-st I can easily use all memory on system
19:44:42pigmejon linux
19:44:43FromGitter<unreadable> somehow I couldn't compile a simple nim app because gcc couldn't find libisl.so.15
19:44:59FromGitter<unreadable> doing a quick check, found I have libisl.so.19 oO
19:45:10FromGitter<unreadable> should I reinstall the lib?
19:45:42FromGitter<tim-st> pgmej: I think the behaviour is not normal, on Python they dont use lots of gigabytes forever too, but I will implement in golang now, too see if I'm wrong
19:46:25pigmejyup
19:47:04zestyrit seems most of the memory is caused by lots of overhead by using multipartdata objects
19:47:47zestyrsending a ~40 MB file can easily jump to 200 MB occupied because the file is read into a string, which is added to a multipartdata object, which is then formatted into another string, and then sent via a socket
19:48:29zestyrin the httpclient library that is
19:49:03*zacharycarter joined #nim
19:49:03*kungtotte quit (Read error: Connection reset by peer)
19:49:34zacharycarterquestion - is it possible to define an operator as a macro with a symbol like `${}` ?
19:49:43*kungtotte joined #nim
19:50:06zestyrthe GC not letting go of that memory afterwards is pretty annoying since that can lead to an otherwise very lightweight program constantly using a lot of system memory
19:55:05*rockcavera quit (Remote host closed the connection)
20:06:41*rockcavera joined #nim
20:08:04*Etheco- quit (Read error: Connection reset by peer)
20:13:36*zacharycarter quit (Ping timeout: 252 seconds)
20:16:23dom96zestyr: please make issues for this
20:17:24FromGitter<dm1try> @tim-st could you try with `--gc:markAndSweep`?
20:19:43FromDiscord<Shield> Is there a reason why this doesn't work
20:19:43FromDiscord<Shield> ```
20:19:43FromDiscord<Shield> var socket = newAsyncSocket()
20:19:43FromDiscord<Shield> while true:
20:19:43FromDiscord<Shield> try:
20:19:44FromDiscord<Shield> waitFor connect(socket, server_address)
20:19:44FromDiscord<Shield> break
20:19:45FromDiscord<Shield> except:
20:19:47FromDiscord<Shield> echo "Retrying in 5sec"
20:19:48FromDiscord<Shield> waitFor sleepAsync 5000
20:19:50FromDiscord<Shield> ```
20:19:51FromDiscord<Shield> while this does
20:19:52FromDiscord<Shield> ```
20:19:54FromDiscord<Shield> var socket = newAsyncSocket()
20:19:55FromDiscord<Shield> while true:
20:19:57FromDiscord<Shield> try:
20:19:58FromDiscord<Shield> waitFor connect(socket, server_address)
20:20:00FromDiscord<Shield> break
20:20:01FromDiscord<Shield> except:
20:20:02FromDiscord<Shield> echo "Retrying in 5sec"
20:20:04FromDiscord<Shield> waitFor sleepAsync 5000
20:20:05FromDiscord<Shield> socket.close() # not sure if this needed
20:20:07FromDiscord<Shield> socket = newAsyncSocket()
20:20:08FromDiscord<Shield> ```
20:21:39PMunchShield, please use a paste service like pastebin or ix.io when sharing code
20:23:30zestyrdom96: sorry, I will. still investigating the causes and possible solutions
20:23:32FromGitter<dm1try> @tim-st with `markAndSweep ` there is 3 allocations and 3 deallocations for the response body vars; and this works fine because a new memory is required if there is no reserved memory as we expected before
20:24:16FromGitter<dm1try> btw I tested `devel` branch =)
20:25:01FromDiscord<Shield> my apologies, calling connect again on a socket will keep failing unless you assign a new socket again via newAsyncSocket(), is this the normal behaviour?
20:41:13dom96AFAIK this is OS behaviour
20:47:18*PMunch quit (Remote host closed the connection)
20:57:44*kapil___ quit (Quit: Connection closed for inactivity)
20:58:28*miran quit (Ping timeout: 244 seconds)
21:00:13*xet7_ joined #nim
21:00:23FromDiscord<exelotl> PMunch: hey I did it!
21:00:26FromDiscord<exelotl> https://gist.github.com/geckojsc/e1b68d957bc4bdf4008b716341fe163a
21:00:58FromDiscord<exelotl> solution was to use {.nimcall.} so that it doesn't try to convert them to closures
21:01:04*xet7 quit (Ping timeout: 240 seconds)
21:01:06FromDiscord<exelotl> then I can do an unsafe cast
21:05:43FromDiscord<exelotl> now what I wonder is... do I really need the `tid` field? I'm sure Nim already exposes some type info at runtime which I might be able to use instead, but I don't know how to use it.
21:08:25FromGitter<mratsim> you can use if Foo is I think
21:09:11FromGitter<mratsim> or just use methods
21:09:30*TheLemonMan quit (Quit: "It's now safe to turn off your computer.")
21:09:49FromGitter<mratsim> instead of proc updateFoo use method updateFoo
21:14:07FromGitter<arnetheduck> @Araq, now that there's `func`, should all `nosideeffects` pragmas be purged from std lib, as a way of providing a good example? or is `func` uncertain still?
21:14:08FromDiscord<exelotl> yeah I'm intentionally trying to avoid methods because I don't think they scale well (100 subclasses = 100 else-ifs)
21:20:41FromDiscord<Shield> what kind of thing you're working on that needs optimization on dynamic dispatch level?
21:26:05*nsf quit (Quit: WeeChat 2.2)
21:37:04*zachcarter joined #nim
21:40:40*Vladar quit (Remote host closed the connection)
21:46:44*xet7_ is now known as xet7
21:51:58FromDiscord<exelotl> @Shield it's just a personal project to see if I can make a really fast 2D game engine that's also clean and easy to use
21:58:06FromDiscord<exelotl> a reasonably sized game can end up with hundreds of different entity types. Given my understanding of how Nim's multimethods / dispatch trees work, simply adding more types to the game will slow down the update loop, even if those types are rarely used.
22:00:34FromDiscord<exelotl> I can force there to be a different list for each entity type, then just use static dispatch. But that ruins the 'clean and easy to use' part.
22:03:32FromDiscord<Shield> oh nice, good luck
22:07:21FromDiscord<exelotl> thx :)
22:12:56FromGitter<zetashift> @exelotl good luck! I would love to see the code
22:23:29FromDiscord<exelotl> thanks, I still have quite a few problems that I'm not sure how to solve (e.g. how to check inside a macro if a procedure exists for a given type)
22:38:59*xet7 quit (Quit: Leaving)
22:44:16*stefanos82 quit (Quit: Quitting for now...)
23:00:50FromDiscord<emekoi> does anyone here know how to use azure pipelines?
23:02:11*a_b_m quit (Quit: Leaving)
23:35:47FromGitter<gogolxdong> @bung87 this is a piece of illustrative code for the problem I mentioned yesterday. https://nim-lang.org/docs/manual.html#type-bound-operations-destructors
23:40:05*sz0 quit (Quit: Connection closed for inactivity)
23:41:18FromGitter<bung87> oh thanks, seems this is not my use case.
23:51:26*brainproxy quit (Quit: WeeChat 2.2)
23:51:59FromGitter<gogolxdong> Your Job features a field with destructable type and you did not provided an explicit implementation.
23:55:33FromGitter<bung87> I think the example will safe for without gc
23:56:58*noonien quit (Quit: Connection closed for inactivity)
23:59:46FromGitter<gogolxdong> I am trying to prove that doesn't leak, also to detect for our backend.