00:00:09 | * | rnrwashere joined #nim |
00:12:52 | * | shodan45 quit (Quit: No Ping reply in 180 seconds.) |
00:17:18 | * | shodan45 joined #nim |
00:20:46 | * | noeontheend joined #nim |
00:39:09 | FromGitter | <irskep> I've got some code that compiles in one file and doesn't compile in another. Could really use some help if anyone's up for it. Details to follow. |
00:39:24 | FromGitter | <irskep> This compiles: https://github.com/irskep/nimrl/blob/master/src/scenes/state_debug_scene.nim#L24 |
00:39:28 | FromGitter | <irskep> This does not compile: https://github.com/irskep/nimrl/blob/master/src/input.nim#L7 |
00:40:20 | FromGitter | <irskep> The procs are identical. `IsKeyPressed` is defined by `raynim`, which is a nimterop-based wrapper of raylib (https://www.raylib.com/). `KEY_UP` is an num of some kind, and seems to be where the trouble is, but I can't reason about what the trouble would be, exactly. |
00:43:12 | FromGitter | <irskep> My best guess is that the `KeyboardKey` enum is missing its underlying `cint` data type somehow, but that seems like very surprising behavior |
00:44:37 | FromGitter | <irskep> Solved it, PEBKAC: I wrote a wrapper for `IsKeyPressed` that does the type cast and forgot to import it. |
01:05:02 | * | stefanos82 quit (Remote host closed the connection) |
01:09:58 | FromGitter | <dawkot> Hi, what is the preferred way to get a random element of a `HashSet`? Just converting it to a seq and using the `sample` method from `random` on it? |
01:25:12 | FromGitter | <irskep> I'm not aware of any standard library that gives you a nice way to randomly sample something that isn't a linear list. :-) Not being an expert, that seems like it'd be reasonable. |
01:27:13 | FromGitter | <irskep> Even the very latest version of Python doesn't have anything like that, and they have a kitchen sink stdlib |
01:27:30 | * | Cthalupa quit (Read error: Connection reset by peer) |
01:28:12 | FromGitter | <dawkot> I guess that means you're right |
01:28:41 | FromGitter | <dawkot> Never needed random sampling before so I didn't get to know what other languages offer |
01:40:24 | * | Cthalupa joined #nim |
01:58:20 | * | fanta7531 joined #nim |
02:18:35 | * | Tyresc quit (Quit: WeeChat 2.4-dev) |
02:23:52 | * | fanta7531 quit (Quit: fanta7531) |
02:25:43 | * | ng0_ joined #nim |
02:28:29 | * | ng0 quit (Ping timeout: 256 seconds) |
02:55:04 | * | rnrwashere quit (Remote host closed the connection) |
02:58:21 | * | rnrwashere joined #nim |
03:02:31 | * | banc quit (Quit: Bye) |
03:15:30 | * | dddddd quit (Remote host closed the connection) |
03:23:34 | * | banc joined #nim |
03:59:28 | shashlick | @irskep: how is nimterop working for you |
04:00:47 | * | Cthalupa quit (Ping timeout: 255 seconds) |
04:03:27 | * | nsf joined #nim |
04:49:34 | * | noeontheend quit (Ping timeout: 258 seconds) |
04:51:24 | * | noeontheend joined #nim |
05:00:10 | * | chimez joined #nim |
05:04:02 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
05:18:38 | * | noeontheend quit (Ping timeout: 255 seconds) |
05:22:34 | * | chimez quit (Quit: chimez) |
05:23:15 | * | Ven`` joined #nim |
05:26:10 | * | narimiran joined #nim |
05:28:02 | * | Ven`` quit (Ping timeout: 272 seconds) |
05:29:12 | * | rnrwashere quit (Remote host closed the connection) |
05:34:09 | * | rnrwashere joined #nim |
05:35:01 | * | rnrwashere quit (Remote host closed the connection) |
05:35:15 | * | rnrwashere joined #nim |
05:35:23 | * | chimez joined #nim |
06:11:27 | * | rnrwashere quit (Remote host closed the connection) |
06:17:46 | * | Vladar joined #nim |
06:35:48 | * | chimez quit (Quit: chimez) |
07:01:47 | * | krux02 joined #nim |
07:18:44 | * | vlad1777d joined #nim |
07:27:50 | * | chimez joined #nim |
07:28:01 | * | chimez quit (Client Quit) |
07:28:14 | * | vlad1777d quit (Ping timeout: 255 seconds) |
07:32:58 | FromGitter | <Varriount> Dawkot: Generate a random number x, and perform x iterations through the hash keys? |
07:45:20 | * | PMunch joined #nim |
07:54:34 | * | vlad1777d joined #nim |
08:00:00 | * | gmpreussner quit (Quit: kthxbye) |
08:04:37 | * | gmpreussner joined #nim |
08:21:31 | * | ng0_ quit (Ping timeout: 256 seconds) |
08:25:57 | * | ng0_ joined #nim |
08:36:54 | FromGitter | <mratsim> other mods, is that an elaborate troll or a genuine thread? https://forum.nim-lang.org/t/4664 cc @dom96, @Araq? |
08:37:21 | PMunch | Haha, I can only see the title but it smells troll |
08:38:03 | FromGitter | <mratsim> @dawkot I build my own "set" with sampling for my game of go needs |
08:38:08 | * | chimez joined #nim |
08:38:30 | FromGitter | <mratsim> https://github.com/mratsim/golem-prime/blob/master/src/datatypes.nim#L106-L119 |
08:38:36 | narimiran | @mratsim i've seen that and decided not to make it public |
08:39:14 | narimiran | look at this: "The instructions say "build something? . We don't have Home Depot or Lowes around here" |
08:39:57 | FromGitter | <mratsim> and random sampling is like this: https://github.com/mratsim/golem-prime/blob/master/src/move_heuristics/m_move.nim#L19-L23 |
08:42:24 | * | ng0_ quit (Quit: Alexa, when is the end of world?) |
08:42:48 | FromGitter | <mratsim> if you want multinomial sampling (i.e. sampling with different probability distribution), it was added in devel, implementation using cumulative sum + binary search. Here are 2 implementations that I'm currently evaluating: https://github.com/numforge/laser/blob/master/benchmarks/random_sampling/bench_multinomial_samplers.nim (1 is cumsum + binary search and the other is based on Binary Idnexed Tree (Fenwick Trees)) |
08:56:26 | * | vlad1777d quit (Ping timeout: 255 seconds) |
09:15:11 | * | abm joined #nim |
09:18:30 | * | floppydh joined #nim |
09:30:52 | * | neceve joined #nim |
09:34:00 | * | neceve quit (Client Quit) |
09:34:25 | * | neceve joined #nim |
09:36:41 | * | skelett quit (Quit: WeeChat 2.1) |
09:37:05 | * | skelett joined #nim |
09:54:38 | * | PMunch quit (Ping timeout: 245 seconds) |
10:01:50 | * | vlad1777d joined #nim |
10:06:46 | * | dom96_w joined #nim |
10:12:10 | * | rnrwashere joined #nim |
10:16:52 | * | rnrwashere quit (Ping timeout: 264 seconds) |
10:19:00 | * | PMunch joined #nim |
10:33:47 | * | lritter joined #nim |
10:38:47 | krux02 | mratsim that forum post you linked to. I cannot tell if it is a troll. If it isn't, it is a very low level beginner, so low that teaching him would cost a lot of time and effort. |
10:45:22 | Araq | beginner on Windows that doesn't understand the command line |
10:45:44 | Araq | and does not have English as his major tongue. I don't think he is a troll |
10:57:16 | * | chimez quit (Quit: chimez) |
11:02:33 | FromDiscord | <exelotl> code::blocks self traumatisation sounds about right |
11:03:36 | * | sealmove joined #nim |
11:40:25 | sealmove | Is the code of Krux's project (the Nim -> GLSL) available online? |
11:41:00 | * | kapil____ joined #nim |
11:41:37 | narimiran | sealmove: https://github.com/krux02/opengl-sandbox ? |
11:41:50 | sealmove | oh, that's the repo, thanks |
11:55:11 | sealmove | krux02: do you have a moment? |
11:57:49 | sealmove | krux02: it's not really related to your project, but I thought you could give me some insight on using Nim macros to generate code of some other language. |
11:59:54 | FromGitter | <mratsim> you don't need macros, you can use templates for starter |
12:00:19 | FromGitter | <mratsim> it's probably easier to start with that |
12:01:21 | FromGitter | <mratsim> for example: https://flyx.github.io/emerald/tutorial.html |
12:01:27 | FromGitter | <mratsim> (to generate HTML) |
12:01:46 | FromGitter | <mratsim> ah sorry it might use macros |
12:01:47 | sealmove | yeah, i wanted a simple example, thanks |
12:02:19 | FromGitter | <mratsim> this generates OpenCL: https://github.com/mratsim/Arraymancer/blob/master/src/tensor/private/p_kernels_interface_opencl.nim |
12:02:53 | FromGitter | <mratsim> for example this is self contained: https://github.com/mratsim/Arraymancer/blob/master/src/tensor/private/p_kernels_interface_opencl.nim#L128-L159 |
12:03:45 | FromGitter | <mratsim> it generates an opencl function called "kern_name" with type "ctype" and the function is "op" and can be + - / * ... |
12:03:55 | FromGitter | <mratsim> it's just string interpolation |
12:05:17 | FromGitter | <mratsim> final usage: https://github.com/mratsim/Arraymancer/blob/master/src/tensor/operators_blas_l1_opencl.nim |
12:05:40 | FromGitter | <mratsim> at the bottom |
12:05:42 | sealmove | Another question: Nim DSL can't use arbitary syntax right? If I want a DSL that uses (almost) arbitary syntax, what's my best bet? Maybe I could make a simple parser which then connects the new language with Nim macros? |
12:06:10 | FromGitter | <mratsim> you can use anything that can be parsed by Nim parser |
12:06:24 | FromGitter | <mratsim> i.e. if you want to use "-" in an identifier you can't |
12:06:56 | sealmove | I want to do Nim -> Bash :D |
12:07:06 | FromGitter | <mratsim> but the best way to check is to have a macro "macro myparser(body: untyped): untyped = echo body.treerepr" |
12:07:32 | * | dddddd joined #nim |
12:07:52 | FromGitter | <mratsim> and call it via: ⏎ ⏎ ```myParser: ⏎ mylist() ⏎ ofweirdStatement = IwantToTest``` [https://gitter.im/nim-lang/Nim?at=5c6aa018ecef85660bc684cb] |
12:08:08 | FromGitter | <mratsim> and you'll see if you get a parse error or not |
12:09:17 | FromGitter | <mratsim> if you want arbitrary syntax you need a custom tokenizer yes. |
12:10:38 | FromGitter | <mratsim> but the main limitations I'd say are postfix operators and stuff that are prevented in identifiers like "-" or starting a name with a "_" or having double "__" |
12:11:42 | sealmove | what about normal nim code? for example translating an if statement in nim to an if statement in bash? |
12:13:55 | FromGitter | <mratsim> you need to implement a code generator |
12:14:49 | sealmove | which takes Nim AST as input? |
12:16:37 | FromGitter | <mratsim> or Nim intermediate representation (whatever that is), have a look into Nim C generator: https://github.com/nim-lang/Nim/blob/devel/compiler/cgen.nim |
12:16:51 | FromGitter | <mratsim> or jsgen: https://github.com/nim-lang/Nim/blob/devel/compiler/jsgen.nim |
12:17:13 | FromGitter | <mratsim> or LLVM IR generator: https://github.com/arnetheduck/nlvm/blob/master/nlvm/llgen.nim |
12:17:18 | FromGitter | <mratsim> using Nim compiler as a plugin |
12:17:43 | sealmove | awesome, thanks |
12:18:30 | FromGitter | <mratsim> might be relevant as well ;) https://github.com/NateGraff/blessedvirginmary |
12:18:39 | FromGitter | <mratsim> LLVM IR to Bash |
12:20:04 | * | nsf quit (Quit: WeeChat 2.3) |
12:20:50 | FromGitter | <mratsim> also you can check what was in the undocumented PHP backend: https://github.com/nim-lang/Nim/pull/7606 |
12:21:40 | sealmove | PHP backend! Hadn't heard about that!! |
12:22:51 | FromGitter | <mratsim> it was deleted :P |
12:23:30 | FromGitter | <mratsim> basically it seems like it used a combination of emit + asm to produce a .php script |
12:24:44 | * | ng0 joined #nim |
12:30:22 | federico3 | urgh |
12:31:24 | sealmove | I know it's all in the documentation, but I don't get the rough idea of how to use Nim parser to specify a custom syntax :| |
12:32:50 | federico3 | https://github.com/nim-lang/Nim/pull/7606/files how was it working tho...? |
12:36:49 | FromGitter | <mratsim> with untyped, Nim parser will gice you an abstract syntax tree |
12:37:17 | FromGitter | <mratsim> but only if it's something that is valid Nim parsing wise |
12:37:37 | FromGitter | <mratsim> if you want a custom syntax you need your own lexer/parser |
12:37:52 | Araq | federico3: it assumed PHP is a variant of JavaScript :-) |
12:38:37 | Araq | worked quite well but we don't want to maintain it |
12:38:48 | Araq | „Thus a program analysis performing bounds checking for C arrays or strings, |
12:38:48 | Araq | say, must account for such implicit pointer arithmetic. We therefore set out by |
12:38:48 | Araq | asking the following question: How much pointer arithmetic can one include in |
12:38:49 | sealmove | oh I see! so I get some AST and I just observe it with a pretty printer and manipulate it |
12:38:50 | Araq | separation logic and remain within polynomial time? |
12:38:52 | Araq | Unfortunately, and perhaps surprisingly, the answer turns out to be: essentially none at all.“ |
12:39:11 | FromGitter | <mratsim> but I'm having trouble to understand what you want, on one hand you want Nim -> bash, and on another you want custom syntax (so not Nim) to --> ??? conversion |
12:39:43 | FromGitter | <mratsim> @sealmove yes |
12:40:03 | sealmove | mratsim: I think Nim's syntax will cover it, probably won't need a custom one |
12:40:16 | FromGitter | <mratsim> and the pretty printer is echo myAST.treerepr |
12:43:33 | sealmove | So basically all I need is the code generator, and Nim -> bash direct mapping seems possible |
12:44:51 | sealmove | Just wondering if I am missing something |
12:45:01 | FromGitter | <mratsim> best is to try :P |
12:45:11 | sealmove | yeah, will get my hands dirty |
12:45:13 | FromGitter | <mratsim> I'm writing my own compiler and I'm doing things step by steps |
12:45:27 | sealmove | oh, what compiler is it? |
12:45:36 | FromGitter | <mratsim> for example, after 7 steps of front-end refinements, this is my proof of concept: https://github.com/mratsim/compute-graph-optim/blob/master/e08_DSL_compiler.nim |
12:45:49 | FromGitter | <mratsim> Deep Learning and Image processing compiler |
12:46:00 | sealmove | iGo! |
12:46:14 | FromGitter | <mratsim> here it only supports expressions |
12:46:28 | FromGitter | <mratsim> from yesterday, i support statements and in-place updates: https://github.com/mratsim/compute-graph-optim/blob/master/e09_DSL_compiler_stmt.nim |
12:46:47 | FromGitter | <mratsim> next step is to support arrays and not just scalars |
12:47:02 | FromGitter | <mratsim> then during codegen, generates SIMD instructions |
12:47:10 | FromGitter | <mratsim> then support LLVM IR codegen |
12:47:22 | FromGitter | <mratsim> then add runtime generation |
12:47:33 | FromGitter | <mratsim> then support GPU code gen |
12:47:51 | sealmove | so custom language to do vector programming? |
12:47:53 | FromGitter | <mratsim> but don't do everything at once, start with an end to end simple example and starts adding features on top |
12:48:19 | FromGitter | <mratsim> the story is here: https://github.com/mratsim/compute-graph-optim/blob/master/arraymancer_discussion_347.md |
12:48:51 | sealmove | will read |
12:49:10 | FromGitter | <mratsim> I'm refactoring the backend of Arraymancer (https://github.com/mratsim/Arraymancer) |
12:50:09 | sealmove | great! seems important, gl |
12:50:17 | FromGitter | <mratsim> and while working on the new backend (https://github.com/numforge/laser) I'm limited in various ways when combining various "macro block" like convolution and matrix multiplication |
12:50:36 | FromGitter | <mratsim> I'm doing runtime check of simd size everywhere |
12:51:04 | FromGitter | <mratsim> I need to do the same thing (vectorization, loop blocking, parallelization) often but in different ways. |
12:51:56 | FromGitter | <mratsim> and also while I already provide an imperative way to do loop-fusion, you have to everything in that single for loop so it'snot composable |
12:52:19 | sealmove | when it's finished, will you use it to make a iGo AI? :D |
12:53:10 | FromGitter | <mratsim> I already started one: but I'm stuck because of static/ranges/distinct types compiler issues - https://github.com/mratsim/golem-prime |
12:53:26 | FromGitter | <mratsim> the neural network part can already be done today. |
12:53:40 | sealmove | I knew it! |
12:54:04 | FromGitter | <mratsim> the monte carlo tree search is actually the tricky thing, due to GC overhead in tree data structure, I have to do bench to make sure it's not too costly |
12:54:19 | sealmove | yeah, have to wait for Nim v2 for that |
12:54:43 | sealmove | (new runtime thing) |
12:54:44 | FromGitter | <mratsim> here it's promising: https://github.com/frol/completely-unscientific-benchmarks |
12:55:16 | FromGitter | <mratsim> but a 19x19 game board is 300+ bytes not just 16 |
12:55:24 | FromGitter | <mratsim> so the GC might collect much more often |
12:55:30 | FromGitter | <mratsim> so I would need a memory pool |
12:55:35 | FromGitter | <mratsim> so yeah |
12:56:34 | sealmove | have you tried Shogi/ |
12:56:41 | FromGitter | <mratsim> yes |
12:56:46 | sealmove | (btw minimal example of my idea https://bpaste.net/show/56c9b18f9bde) |
12:57:04 | sealmove | I've been playing Shogi for ~10 years |
12:57:16 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
12:57:34 | sealmove | iGo unfortunately basically tried |
12:57:46 | sealmove | barely* |
12:58:04 | FromGitter | <mratsim> I actually have this book at home: http://shop.nekomado.com/products/detail.php?product_id=38 (The Art of Shogi by Hopking) |
12:58:23 | FromGitter | <mratsim> but I didn't play that much |
12:59:17 | sealmove | am thrilled that someone from Nim has played it, even if a little |
12:59:25 | FromGitter | <mratsim> for your example, it might be easier to just use a jsonNode to bash command generator |
12:59:41 | sealmove | jsonNode, mmm |
12:59:59 | FromGitter | <mratsim> this way you can use json as config file |
13:00:27 | sealmove | i guess it's a good idea since json is popular |
13:01:37 | FromGitter | <mratsim> we're building something in that vein at status: https://github.com/status-im/nim-confutils |
13:02:43 | FromGitter | <mratsim> and you can use exec &"{conf.command} {conf.parameters}" |
13:03:07 | FromGitter | <mratsim> the {} interpolation comes from https://nim-lang.org/docs/strformat.html |
13:03:47 | FromGitter | <mratsim> for execution, seems like execProcess is your tool: https://nim-lang.org/docs/osproc.html#execProcess%2Cstring%2CopenArray[string]%2CStringTableRef%2Cset[ProcessOption] |
13:04:08 | FromGitter | <mratsim> i.e. AST is overkill for your need if it's a simple declarative thing |
13:04:22 | FromGitter | <mratsim> not AST / codegen |
13:04:48 | sealmove | well, i was hoping for a complete Nim -> Bash implementation. translate not only commands (like my minimal example) but also ifs and fors |
13:05:08 | sealmove | then you can script in this Nim DSL and produce standard Bash |
13:05:41 | sealmove | the simple declarative example is just a starting point |
13:06:15 | sealmove | (of course I don't know if this is a clever idea) |
13:07:15 | FromGitter | <mratsim> the only thing you are risking is your time and also you risk to learn something. |
13:08:45 | Zevv | wise words from a wise man, this mratsim :) |
13:08:59 | sealmove | :) |
13:10:09 | sealmove | i have little opportunities to use Nim so i'll take this one |
13:13:09 | Zevv | so if I'm understanding it right, you'll be making a bash backend for nim? |
13:14:17 | sealmove | yeah |
13:15:06 | sealmove | though of course you won't be able to compile everything and produce legit bash, so only a subset of Nim will be valid for translation. |
13:15:54 | sealmove | essentially it will be a Nim DSL. think of like SASS -> CSS |
13:16:08 | Zevv | let's see how far you'll get :) I suspect you'll have fun with var arguments and such :) |
13:21:32 | Zevv | sealmove: instead of creating a backend, you also could do it at macro level, which might be a tad easier |
13:22:00 | sealmove | Zevv: that was my first consideration |
13:22:45 | sealmove | If it's possible I'd prefer it |
13:23:27 | FromGitter | <mratsim> try with macros first yeah |
13:24:19 | sealmove | so macro should take AST as parameter and produce a string, right? |
13:24:48 | sealmove | (the bash code as string) |
13:25:56 | FromGitter | <mratsim> untyped means convert whatever your read as AST |
13:26:15 | FromGitter | <mratsim> but don't run Nim things on it, just give me as is. |
13:30:08 | sealmove | But essentially at some point the bash code must be generated. Is this done with a normal proc(smg: NimNode): string? |
13:37:26 | * | nsf joined #nim |
13:38:01 | FromGitter | <mratsim> yes you can do that |
13:39:03 | * | stefanos82 joined #nim |
13:46:56 | FromGitter | <yglukhov> Do I understand correctly that you can't use `genSym` to create a declaration of smth which can be referred after macro invocation? |
13:47:19 | FromGitter | <mratsim> {.experimental: "dynamicGenSym".} ? |
13:48:20 | FromGitter | <yglukhov> hm. what's that? can't find "dynamicGenSym" in nim sources. |
13:49:00 | FromGitter | <mratsim> ah sorry |
13:49:04 | FromGitter | <mratsim> it's bindSym |
13:49:13 | FromGitter | <mratsim> so unrelated :/ |
13:51:28 | FromGitter | <yglukhov> In other words, this: https://github.com/nim-lang/Nim/issues/10706 |
13:56:28 | FromGitter | <mratsim> didn't you already opened this issue 2 months ago? xD |
13:58:38 | FromGitter | <yglukhov> I don't think so :) |
14:00:23 | FromGitter | <mratsim> mmm, I think it works as intended, genSym goal is to generate unique symbols, which is useful in scopes or when shadowing names |
14:00:48 | FromGitter | <mratsim> newIdentNode does what you need |
14:01:45 | Zevv | sealmove: http://paste.ubuntu.com/p/hprmyYFwcx/ :) |
14:02:46 | sealmove | Zevv: thanks!!! |
14:04:23 | FromGitter | <yglukhov> newIdentNode doesn't cut it really because of overloading and stuff... |
14:05:02 | FromGitter | <yglukhov> it's a bit hard to define my problem in english, sorry :) |
14:29:15 | FromGitter | <mratsim> you want a unique name but that can be reused |
14:39:59 | * | kapil____ quit (Quit: Connection closed for inactivity) |
14:44:08 | shashlick | @mratsim confutils looks really cool |
14:48:47 | shashlick | Any good examples |
14:55:26 | Zevv | sealmove: http://paste.ubuntu.com/p/hprmyYFwcx/ :) |
14:55:37 | Zevv | sorry |
15:00:44 | shashlick | Why do loaded dlls take up so much ram |
15:01:09 | shashlick | 150k Nim dll takes up 12mb |
15:01:17 | shashlick | And I'm not allocating anything |
15:01:37 | livcd | a dll created in Nim ? |
15:01:45 | livcd | or loading a dll fromm Nim ? |
15:02:08 | shashlick | Both together |
15:03:07 | narimiran | https://news.ycombinator.com/item?id=19179285 |
15:11:07 | * | PMunch quit (Remote host closed the connection) |
15:15:11 | * | Snircle joined #nim |
15:21:40 | FromGitter | <mratsim> @shashlick, I don't think we'll have time to document confutils for the next 3-4 weeks, |
15:21:45 | FromGitter | <mratsim> best example is this: https://github.com/status-im/nim-beacon-chain/blob/master/beacon_chain/validator_keygen.nim#L29-L66 |
15:22:28 | FromGitter | <mratsim> it's a json file generator, each will contain a public and private key for testing |
15:24:03 | * | chimez joined #nim |
15:24:09 | * | chimez quit (Client Quit) |
15:25:29 | * | noeontheend joined #nim |
15:26:03 | * | ng0 joined #nim |
15:27:42 | * | neceve quit (Ping timeout: 268 seconds) |
15:28:30 | shashlick | @mratsim: ya was mainly wondering about the config file locations |
15:29:19 | shashlick | looks like registry on Windows and a serialization format on linux |
15:29:27 | shashlick | won't be user editable |
15:29:43 | shashlick | was hoping for a config file format for my text editor |
15:32:41 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
15:36:21 | FromGitter | <mratsim> confutils uses plain text files |
15:37:33 | * | Trustable joined #nim |
15:38:22 | FromGitter | <mratsim> json, yaml will be supported for sure |
15:41:28 | FromGitter | <Clyybber> Araq: What was the reason for not merging #10524 and instead clarifying in the spec? |
15:43:05 | Araq | seemed more useful to me |
15:43:09 | shashlick | okay I'll try it out once onw of those formats can be used on windows |
15:51:22 | FromGitter | <Clyybber> Araq: AFAICT it enables using negative ranges for constructing a set, right? Right now I have to do this in a for loop (correct me if I'm wrong), so I was hoping for #10524 to be merged. |
15:51:41 | * | nsf quit (Quit: WeeChat 2.3) |
15:51:48 | FromGitter | <Clyybber> Also, https://github.com/nim-lang/Nim/commit/739dc8094e4a4f6dd2f0eb0fb2eb8ce8191cb001#diff-9be874ad8ad98f21136d81b69500dd8aR13 the sentence here seems to have been broken up by that commit. |
15:52:35 | * | dom96_w joined #nim |
15:53:40 | shashlick | size of a reference field in an object is just a pointer right? |
15:55:22 | FromGitter | <mratsim> yes |
15:55:51 | shashlick | just tested a small dll with a small main and ram usage is minimal with loadLib |
15:56:11 | shashlick | i'm wondering if there's a copy of an object being done somewhere that's bloating my ram usage |
15:56:22 | FromGitter | <mratsim> iirc destructors changed the size of seqs, you wouldn't need to dereference to get it's length, but I may remember incorrectly. |
15:56:59 | shashlick | https://github.com/genotrance/feud/blob/master/src/globals.nim <= all my objects - I have a plugin object for each dll I load |
15:57:09 | shashlick | anything stands out as bloatable |
15:57:37 | FromGitter | <mratsim> TableRef |
15:58:54 | shashlick | there should be only one instance of Ctx, which is referred to by each plugin |
15:59:05 | shashlick | are you suggesting those tablerefs will get duplicated somehow? |
16:00:16 | FromGitter | <mratsim> it just seems like the most RAM hungry object, especially the TableRef that holds Plugins references |
16:00:25 | FromGitter | <mratsim> plugins*: TableRef[string, Plugin |
16:00:57 | * | sealmove quit (Quit: WeeChat 2.3) |
16:02:02 | shashlick | stepping through the code, the loadLib() line immediately makes ram jump up, not the new(Plugin) line |
16:11:25 | shashlick | this size issue is because of threadpool |
16:11:51 | shashlick | if i compile the dll with --threads:on, my ram usage goes up by 9mb |
16:12:09 | shashlick | an executable goes from 2.5mb to 9.5mb as well, simply for using the --threads:on |
16:12:42 | shashlick | no doubt i need threads, but it costs a lot |
16:17:24 | FromGitter | <mratsim> ugh, please open a bug report |
16:18:22 | FromGitter | <mratsim> it might be linking pthreads that just bloat the RAM or it might be another thing |
16:18:39 | shashlick | This is windows |
16:19:26 | shashlick | I'll try without threadpool but with --threads:on and see what happens |
16:25:39 | FromGitter | <mratsim> threads on triggers things in system.nim |
16:27:16 | FromGitter | <mratsim> I'm curious about what is a distinguished threads in threadpool btw @Araq. https://nim-lang.org/docs/threadpool.html#MaxDistinguishedThread |
16:29:25 | * | Trustable quit (Remote host closed the connection) |
16:29:31 | Araq | you pin the operations to a particular thread which turns it into a monitor |
16:30:35 | Araq | the thread is "distinguished" which means it has an identity, you can use this for a distributed hashing key lookup table, for instance |
16:30:41 | FromGitter | <Clyybber> Araq: AFAICT it enables using negative ranges for constructing a set, right? Right now I have to do this in a for loop (correct me if I'm wrong), so I was hoping for #10524 to be merged. ⏎ Also, in https://github.com/nim-lang/Nim/commit/739dc8094e4a4f6dd2f0eb0fb2eb8ce8191cb001#diff-9be874ad8ad98f21136d81b69500dd8aR13 the sentence here seems to have been broken up by that commit. |
16:30:58 | FromGitter | <Clyybber> Sry, repasted, because I think the bridge went down. |
16:31:12 | FromGitter | <mratsim> @shashlick, I think the issue is here: https://github.com/nim-lang/Nim/blob/b6d96cafc8bcad1f3d32f2910b25cd11a93f7751/lib/pure/concurrency/threadpool.nim#L359-L364 |
16:32:12 | FromGitter | <mratsim> ah no sorry |
16:32:16 | FromGitter | <mratsim> those are stack arrays |
16:32:25 | FromGitter | <mratsim> though 256 is quite large |
16:32:34 | FromGitter | <mratsim> but it should be in the BSS |
16:33:02 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
16:34:22 | * | dom96_w joined #nim |
16:34:26 | shashlick | @mratsim - compiling with --threads:on but without threadpool avoids the bloat |
16:34:45 | shashlick | let me try some more tests |
16:43:58 | * | noeontheend quit (Ping timeout: 244 seconds) |
16:45:20 | * | thomasross quit (Remote host closed the connection) |
16:45:35 | * | thomasross joined #nim |
16:46:26 | * | rnrwashere joined #nim |
16:50:44 | * | thomasross quit (Ping timeout: 255 seconds) |
16:50:53 | Araq | shashlick: I think it's extensive threadlocal storage |
16:51:35 | shashlick | is that in my code or in threadpool? |
16:55:43 | * | rnrwashere quit (Remote host closed the connection) |
17:00:28 | * | rnrwashere joined #nim |
17:03:12 | shashlick | tried moving to createThread but now I just crash on startup |
17:05:54 | * | rnrwashere quit (Remote host closed the connection) |
17:06:24 | * | rnrwashere joined #nim |
17:13:41 | * | rnrwashere quit (Remote host closed the connection) |
17:22:43 | * | Trustable joined #nim |
17:24:22 | FromGitter | <Varriount> Araq: Find any good CS papers recently? |
17:27:53 | Araq | https://www.adacore.com/uploads/techPapers/Safe-Dynamic-Memory-Management-in-Ada-and-SPARK.pdf |
17:28:22 | FromGitter | <mratsim> Oh you missed the Ada talk about borrow checking for raw pointers at FOSDEM |
17:31:43 | FromGitter | <Varriount> @mratsim One day I'll actually be able to afford to fly to FOSDEM |
17:33:27 | * | sealmove joined #nim |
17:35:45 | * | dorelix quit (Ping timeout: 246 seconds) |
17:37:28 | * | rockcavera quit (Remote host closed the connection) |
17:38:31 | * | rockcavera joined #nim |
17:40:03 | FromGitter | <mratsim> this one: https://fosdem.org/2019/schedule/event/ada_pointers/ |
17:40:48 | * | dorelix joined #nim |
17:41:06 | * | rnrwashere joined #nim |
17:45:47 | * | rnrwashere quit (Remote host closed the connection) |
17:51:24 | * | noeontheend joined #nim |
17:52:16 | * | rnrwashere joined #nim |
17:53:07 | shashlick | feud |
17:54:24 | * | zachk joined #nim |
17:56:05 | * | natrys joined #nim |
17:56:15 | * | rnrwashere quit (Remote host closed the connection) |
17:58:02 | * | rnrwashere joined #nim |
18:00:11 | * | rnrwashere quit (Remote host closed the connection) |
18:00:51 | * | rnrwashere joined #nim |
18:01:42 | shashlick | okay have greatly reduced my mem usage but still have a leak when you unloadLib() - ram doesn't get returned to OS |
18:02:39 | leorize | shashlick: what OS are you on? |
18:02:46 | shashlick | Windows |
18:06:09 | leorize | so unloadLib is implemented by FreeLibrary on Windows |
18:06:12 | leorize | https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-freelibrary |
18:06:57 | leorize | ^ looking at this, could it be that the refcount never reached 0? |
18:07:23 | shashlick | well, the dll does get unloaded - I can delete it while main binary is runnnig |
18:07:58 | shashlick | just that it is leaving some memory around and it isn't obvious in my code where it comes from |
18:19:36 | shashlick | well, at least I am down from 56Mb to 17Mb - cannot complain too much |
18:20:29 | * | dorelix quit (Remote host closed the connection) |
18:20:50 | * | dorelix joined #nim |
18:21:18 | * | seerix joined #nim |
18:24:05 | * | floppydh quit (Quit: WeeChat 2.3) |
18:25:18 | shashlick | well there's a leak somewhere for sure - barebones dll without threads compiles down to 120k and leaks 1Mb per load/unload cycle |
18:25:47 | leorize | check if the init function of the dll allocates anything? |
18:26:24 | * | dorelix quit (Remote host closed the connection) |
18:27:08 | shashlick | the dll is just `proc test() {.exportc, dynlib.} = echo "Hello"` |
18:28:43 | shashlick | if I don't symAddr or call test, it leaks 500k per round |
18:29:59 | FromGitter | <alehander42> i get illformed ast for obviosuly correct nim nodes |
18:30:04 | FromGitter | <alehander42> any idea what is happening |
18:30:12 | FromGitter | <alehander42> can it be a common gotcha |
18:30:50 | shashlick | okay, symAddr doesn't make any difference, calling test leaks another 400k |
18:31:31 | narimiran | @alehander42 i have reported one of those today |
18:31:34 | shashlick | fact that dynlib does nothing more than calling LoadLibrary() and FreeLibrary() under the covers suggests this is a windows issue |
18:32:21 | narimiran | @alehander42 it might be a "common gotcha", a.k.a regression |
18:32:33 | shashlick | well, it could also be something nim put in --app:lib mode that sits in mem |
18:34:41 | shashlick | yep, something in the nim dll is causing this - i just retried the test loading/unloading pcre32.dll and memory usage is constant |
18:36:43 | FromGitter | <alehander42> @narimiran yeah because i feel this didnt happen to me before very often or at least it was more obvious why |
18:36:57 | FromGitter | <alehander42> but maybe it's just me missing something clear |
18:37:29 | FromGitter | <alehander42> but at least the error is pointing to a subnode in the ast which is a simple ident, which doesn make sense: maybe the error is just pointint to the wrong illformed part |
18:37:43 | * | seerix quit (Remote host closed the connection) |
18:38:02 | * | seerix joined #nim |
18:40:12 | FromGitter | <alehander42> i cant find your issue tho |
18:42:53 | FromGitter | <mratsim> toStrLit can maybe help? |
18:43:09 | Araq | lol, Team Nim in the Ada talk |
18:44:16 | leorize | shashlick: dll can have autoloaded code |
18:44:24 | * | oz quit (Quit: EOF) |
18:44:33 | shashlick | i just tried with --gc:none in the dll and leak is gone |
18:44:35 | leorize | maybe the dll initalized the GC? |
18:45:10 | shashlick | Araq: do we need the gc in nim dlls that are loaded by nim apps |
18:45:52 | Araq | shashlick: well the GC is shared and only in nimrtl.dll |
18:47:59 | shashlick | but why do i need nimrtl when i have a main.exe which works standalone |
18:49:42 | FromGitter | <mratsim> I think a focus on dll would be nice to introduce Nim little by little in various slow languages (like Ruby, Python, JS, ...) |
18:51:15 | leorize | any love for static libraries? :P |
18:51:53 | * | oz joined #nim |
18:53:07 | leorize | the symbol clash of NimMain prevents two static nim library from being linked to a program |
18:53:53 | rayman22201 | love for destructors lol? will solve all library memory problems guaranteed :-P |
18:54:45 | shashlick | well, looks like I need to use nimrtl.dll but i am using threads so dead end |
18:55:45 | rayman22201 | maybe gc:regions would work for you? |
18:56:53 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:56:55 | shashlick | i have a main Nim executable which loads a bunch of nim dlls |
18:57:10 | shashlick | and am using threads |
18:57:11 | shashlick | if there's a best practice, happy to adhere to it |
18:59:51 | rayman22201 | idk about best practices, but it appears that you are hitting bugs when using "default gc" + loading dlls + threads. My intuition is that gc:regions may avoid these bugs. |
19:00:35 | rayman22201 | either that or keep attempting to narrow down your bug and fix nimrtl.dll |
19:00:38 | narimiran | @alehander42 my issue is not in nim-repo, but in one project where i experienced that. but the author cannot reproduce it. hmmm, how old is your devel? |
19:03:07 | shashlick | rayman22201 - i'd try but there doesn't seem to be any documentation around regions |
19:05:30 | * | natrys quit (Quit: natrys) |
19:06:50 | rayman22201 | @slashlick Yeah. Docs for regions sucks. This makes me sad. I through together a quick sample for @iffy recently, maybe that will help get you started: https://github.com/rayman22201/node-nim-memory-bug/blob/c6ea0d0097dcb350c020f07e97d21eeac6ae1936/clib.nim |
19:07:15 | rayman22201 | through -> threw |
19:09:16 | rayman22201 | Also this test in the nim core repo: https://github.com/nim-lang/Nim/blob/devel/tests/gc/thavlak.nim#L422 |
19:09:18 | shashlick | interesting, but not sure i can use it in the withRegion() style |
19:09:32 | shashlick | cause i'd load a dll and then the procs in it get called elsewhere |
19:09:52 | shashlick | am wondering how i'd use this |
19:10:11 | rayman22201 | there are more advanced usages. withRegion is a template that sets the "active region" for you, but you can do it manually. |
19:10:11 | shashlick | might work if you could init region, use where appropriate, and then free when done |
19:10:20 | rayman22201 | you can do exactly that if you need to |
19:11:19 | rayman22201 | https://github.com/nim-lang/Nim/blob/dee8e6e98ae868b8d933a718250c8e471bc125ea/lib/system/gc_regions.nim#L105 |
19:11:33 | shashlick | but does --gc:regions mean i have to use regions everywhere |
19:11:46 | rayman22201 | it does, yes. |
19:12:09 | * | sealmove quit (Quit: WeeChat 2.3) |
19:13:55 | shashlick | okay this is a whole new world then, for a simple use case of loading nim dlls in a nim app |
19:14:45 | rayman22201 | well, you are not "Just loading nim dlls in a nim app". You are "loading nim dlls in a *threaded* nim app". threads complicate everything. |
19:16:24 | rayman22201 | Also, Araq generally doesn't love dlls, so there has not been a lot of testing around them beyond the very basics. |
19:16:54 | Araq | I like dlls but Unix doesn't support them |
19:17:05 | rayman22201 | what is an so then lol? |
19:17:27 | shashlick | i agree but makes building real apps a lot more complicated |
19:17:45 | Araq | you cannot put a lib*.so next to the elf binary and have it used, so you need 'sudo cp /usr/lib' bullshit |
19:18:14 | Araq | and that's so broken that I consider Unix's support for dynamic libs to be non-existent |
19:18:37 | shashlick | there's LD_LIBRARY_PATH |
19:18:49 | rayman22201 | that's politics. It's still dynamic loading code. But shashlick is using windows anway. correct? |
19:19:11 | shashlick | i want to port across eventually |
19:19:30 | shashlick | but .so works fine for nimterop plugins |
19:21:15 | FromGitter | <mratsim> the main issue is that a nim binary loading a nim dll |
19:21:25 | * | aguspiza joined #nim |
19:22:03 | rayman22201 | this is all tangent to the point. @mratsim is correct. Dynamic code loading has memory leak with the default gc it seems. |
19:22:26 | shashlick | i think its working quite well for me, except for this leak really |
19:22:31 | Araq | threadlocal storage across DLLs is tough |
19:22:32 | * | nsf joined #nim |
19:23:22 | Araq | shashlick: try --tlsEmulation:on |
19:23:40 | Araq | and then we need to patch the stdlib to support freeing TLS |
19:23:47 | Araq | I mean to patch system.nim |
19:24:04 | shashlick | well, my threads are localized - the app creates threads, but loads dlls in the main thread only which create their own self-contained threads |
19:24:31 | shashlick | not sure if that makes a difference for treadlocal storage though |
19:25:22 | shashlick | trying tlsEmulation - is that only for the main exe or the dlls too |
19:25:32 | Araq | for all |
19:25:52 | shashlick | okay trying |
19:26:14 | Araq | leorize: the name clash can be prevented with --cppCompileToNamespace:namespace and compiling to C++ |
19:26:21 | Araq | I think. |
19:26:48 | shashlick | this is really fun though - the main editor app is just a plugin system - even the main windows are managed by plugin dlls |
19:26:58 | shashlick | so i only recompile small dlls |
19:27:09 | shashlick | system detects changes and recompiles changed portions |
19:32:07 | shashlick | Araq: nope - am still leaking memory |
19:32:27 | Araq | shashlick: sure but now you can free it |
19:32:56 | shashlick | i could always free the dll, but the memory allocated when it loads sits around |
19:33:14 | shashlick | by free, I mean it is no longer in use |
19:34:56 | Araq | read threads.nim line 289 |
19:35:29 | Araq | you need to do something like tlsFree(globalsSlot) except I don't know the real name for tlsFree |
19:35:38 | Araq | and it's not wrapped |
19:37:51 | shashlick | https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-tlsfree |
19:38:45 | shashlick | let me understand this - why do you think this is a thread local storage issue? how do threads come into play for dll load and unload |
19:39:03 | shashlick | i thought it was a multiple gc issue |
19:39:38 | shashlick | either i use nimRtl across all dlls and main app or use regions |
19:39:55 | * | lritter quit (Ping timeout: 268 seconds) |
19:41:30 | * | krux02 quit (Remote host closed the connection) |
19:49:13 | Araq | I don't know what it is, nor how you do measure that you have a leak |
19:51:46 | * | rnrwashere quit (Remote host closed the connection) |
19:53:49 | * | ptdel joined #nim |
19:54:39 | * | nsf quit (Quit: WeeChat 2.3) |
19:57:25 | shashlick | just looking at private bytes in procexp on Windows |
19:57:40 | * | disruptek quit (Quit: Bye) |
19:58:02 | * | disruptek joined #nim |
20:06:35 | * | toofly[m] quit (Quit: removing from IRC because user idle on matrix for 30+ days) |
20:07:39 | * | petersjt014[m] quit (Quit: removing from IRC because user idle on matrix for 30+ days) |
20:22:29 | * | ee7[m] quit (Quit: removing from IRC because user idle on matrix for 30+ days) |
20:35:20 | * | hohlerde left #nim ("Kicked by @appservice-irc:matrix.org : removing from IRC because user idle on matrix for 30+ days") |
20:41:04 | * | aguspiza quit (Ping timeout: 250 seconds) |
20:43:58 | * | Trustable quit (Remote host closed the connection) |
20:52:02 | * | calebwin[m] quit (Quit: removing from IRC because user idle on matrix for 30+ days) |
21:00:05 | * | Demos[m] left #nim ("Kicked by @appservice-irc:matrix.org : removing from IRC because user idle on matrix for 30+ days") |
21:04:50 | * | planetis[m] quit (Quit: removing from IRC because user idle on matrix for 30+ days) |
21:13:32 | * | noeontheend quit (Ping timeout: 255 seconds) |
21:15:52 | FromGitter | <arnetheduck> > you cannot put a lib*.so next to the elf binary and have it used, so you need 'sudo cp /usr/lib' bullshit ⏎ ⏎ you can, you simply have to enable it explicitly (through RPATH if you're the author, or LD_LIB_PATH if you're a user).. it's generally a feature that prevents some otherwise easy exploits |
21:19:57 | Araq | well surely. Refusing to run code always prevents exploits |
21:20:44 | * | rnrwashere joined #nim |
21:21:46 | * | sealmove joined #nim |
21:25:00 | * | rnrwashere quit (Ping timeout: 246 seconds) |
21:27:54 | * | abm quit (Quit: Leaving) |
21:30:29 | * | rnrwashere joined #nim |
21:31:25 | FromGitter | <arnetheduck> how goes the ast vs ir thinking? |
21:34:00 | Araq | I stopped and all my thinking time is spent on full memory safety without the GC |
21:36:31 | * | vlad1777d quit (Remote host closed the connection) |
21:37:35 | * | vlad1777d joined #nim |
21:47:50 | * | ptdel quit (Remote host closed the connection) |
21:51:15 | * | narimiran quit (Ping timeout: 246 seconds) |
21:51:34 | * | rnrwashere quit (Remote host closed the connection) |
21:56:44 | * | rnrwashere joined #nim |
21:57:38 | * | sealmove quit (Quit: WeeChat 2.3) |
21:59:35 | * | rnrwashere quit (Remote host closed the connection) |
22:23:50 | * | Ven`` joined #nim |
22:28:44 | * | noeontheend joined #nim |
22:29:41 | * | Vladar quit (Remote host closed the connection) |
22:47:23 | * | rnrwashere joined #nim |
22:48:50 | * | rnrwashere quit (Remote host closed the connection) |
22:54:16 | * | rnrwashere joined #nim |
22:55:13 | * | rnrwashere quit (Remote host closed the connection) |
22:55:24 | * | Ven`` quit (Ping timeout: 268 seconds) |
22:55:39 | * | rnrwashere joined #nim |
22:55:43 | * | Ven`` joined #nim |
22:59:33 | federico3 | want to surpass rust as well? :) |
23:00:03 | * | rnrwashere quit (Ping timeout: 245 seconds) |
23:01:19 | * | rnrwashere joined #nim |
23:02:37 | * | rnrwashere quit (Remote host closed the connection) |
23:04:31 | * | zyklon quit (Ping timeout: 246 seconds) |
23:10:33 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
23:14:01 | * | rnrwashere joined #nim |
23:21:09 | * | rnrwashere quit (Remote host closed the connection) |
23:21:18 | * | rnrwashere joined #nim |
23:29:49 | * | abm joined #nim |
23:31:22 | * | rnrwashere quit (Remote host closed the connection) |
23:32:45 | * | rnrwashere joined #nim |
23:44:44 | * | Ven`` quit (Ping timeout: 255 seconds) |
23:53:42 | * | rnrwashere quit (Remote host closed the connection) |
23:53:51 | * | rnrwashere joined #nim |
23:56:04 | * | leorize quit (Ping timeout: 250 seconds) |