01:35:48 | FromDiscord | <arkanoid> I wow, there is a cycle detector that can be used to track if code is arc candidate\: https://github.com/nim-lang/Nim/pull/23272 |
03:25:21 | * | rockcavera quit (Remote host closed the connection) |
06:10:29 | FromDiscord | <yummy_licorice> is it possible to get other values from -d: |
06:10:57 | FromDiscord | <yummy_licorice> like something like -d:libPath:/usr/include/somelib |
06:17:48 | FromDiscord | <bostonboston> strdefine |
06:21:31 | FromDiscord | <yummy_licorice> thanks |
06:30:28 | * | alexdaguy joined #nim |
07:46:09 | * | redj quit (Ping timeout: 276 seconds) |
07:46:28 | * | redj joined #nim |
07:52:56 | * | derpydoo joined #nim |
07:55:27 | FromDiscord | <luteva> sent a long message, see https://pasty.ee/kvZLZOFq |
07:59:11 | FromDiscord | <Elegantbeef> What compile time errors are you event trying to test for? |
08:10:57 | * | jjido joined #nim |
08:42:04 | * | tokyovigilante quit (Ping timeout: 260 seconds) |
09:14:58 | * | tokyovigilante joined #nim |
09:16:16 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=AjTOiVwH |
09:16:35 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=QLmcQPpT |
09:16:48 | FromDiscord | <nocturn9x> like wtf you mean I gave you the exact fucking thing you want??? |
09:19:29 | FromDiscord | <nocturn9x> interestingly I get an error in vscode on the line `ft: ...` saying "Layer[...] is not a concrete type", but the nim compiler doesn't seem to catch it |
09:19:37 | FromDiscord | <nocturn9x> am I fundamentally misunderstanding something |
09:21:01 | * | tokyovigilante quit (Ping timeout: 268 seconds) |
09:23:10 | Amun-Ra | that it's not the compiler that's analyzing the code |
09:25:12 | * | tokyovigilante joined #nim |
09:34:41 | FromDiscord | <nocturn9x> yeah |
09:34:52 | FromDiscord | <nocturn9x> I'm still confused as to why it doesn't compile though lol |
09:46:24 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
09:48:40 | FromDiscord | <nocturn9x> playground snippet: https://play.nim-lang.org/#pasty=slrVqkmp |
09:58:17 | * | jjido joined #nim |
09:59:48 | FromDiscord | <luteva> In reply to @Elegantbeef "What compile time errors": e.g. type errors. just what z |
09:59:52 | FromDiscord | <lainlaylie> smaller reproduction: https://wandbox.org/permlink/nubKyW87vflvKXna |
10:00:16 | FromDiscord | <lainlaylie> the usual `distinct` trick from implicit generic procs doesn't seem to work here |
10:00:29 | FromDiscord | <luteva> (edit) "z" => "static code analyzis does (which uses the compiler/VM/nimsuggest)" |
10:01:25 | FromDiscord | <luteva> (edit) "compiler/VM/nimsuggest)" => "compiler/VM/nimsuggest)↵Oh! You mean: In the tests? Well I am talking about unit test e.g." |
10:05:06 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
10:36:58 | FromDiscord | <Robyn [She/Her]> In reply to @nocturn9x "can someone enlighten me": I think it's because you're using type aliases and you have `FTWeightBias` as well as `IntWeight` both being int16 |
10:37:08 | FromDiscord | <Robyn [She/Her]> Either use different types or try a distinct type |
10:37:39 | FromDiscord | <nocturn9x> huh |
10:39:39 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=CrIxRagC |
10:39:42 | FromDiscord | <nocturn9x> this still does not compile |
10:39:48 | FromDiscord | <nocturn9x> `/usercode/in.nim(27, 9) Error: 'Layer[3072, 256, system.int16, system.int16]' is not a concrete type` |
10:39:55 | FromDiscord | <nocturn9x> that would be `l1` |
10:52:37 | FromDiscord | <nocturn9x> anyway I have another question |
10:52:51 | FromDiscord | <nocturn9x> I want to read a file from disk at compile time containing a struct and cast it to the correct type |
10:52:57 | FromDiscord | <nocturn9x> it appears Nim's VM does not support this |
10:53:16 | FromDiscord | <nocturn9x> how can I get around it? I need this to be a constant, or it won't be put in the static segment of the executable |
10:54:27 | FromDiscord | <nocturn9x> `const DEFAULT_NET_VERBATIM = cast[Network](staticRead("../verbatim.bin"))` |
10:54:38 | FromDiscord | <nocturn9x> this errors out with `VM does not support 'cast' from tyString to tyObject` |
10:55:51 | FromDiscord | <nocturn9x> ig I could put the cast in the runtime loading part where I just assign the variable |
11:09:10 | Amun-Ra | don't use cast, initialize object nim-way |
11:30:56 | FromDiscord | <nocturn9x> why would it not work |
11:31:12 | FromDiscord | <nocturn9x> I'm doing `file.write(cast[ptr UncheckedArray[byte]](addr net))` |
11:31:23 | FromDiscord | <nocturn9x> but when loading it back in it fails |
11:31:34 | FromDiscord | <nocturn9x> I can't initialize the object the nim way lmao I just have a stream of bytes |
11:32:06 | FromDiscord | <nocturn9x> it seems like something is getting corrupted |
11:32:28 | FromDiscord | <nocturn9x> and no, I don't need `{.packed.}` since everything is already aligned to 64 bytes and I want to preserve that padding in the final result |
11:34:26 | Amun-Ra | you can always initialize an object |
11:34:54 | FromDiscord | <nocturn9x> wut |
11:34:58 | FromDiscord | <nocturn9x> it's the result of a procedure |
11:35:02 | FromDiscord | <nocturn9x> it's already going to be initialized |
11:35:03 | FromDiscord | <nocturn9x> lol |
11:35:34 | Amun-Ra | you can initialize a Network object using initNetwork equivalent: const DEFAULT_NET_VERBATIM = cast[Network](staticRead("../verbatim.bin"))` |
11:35:52 | Amun-Ra | and file.write + UncheckedArray makes no sense |
11:36:04 | Amun-Ra | there's no size information |
11:36:10 | FromDiscord | <nocturn9x> In reply to @Amun-Ra "you can initialize a": that is literally what I have tried |
11:36:16 | FromDiscord | <nocturn9x> In reply to @Amun-Ra "and file.write + UncheckedArray": yeah I modified it |
11:36:22 | FromDiscord | <nocturn9x> In reply to @nocturn9x "that is literally what": teh VM does not support this lmao |
11:36:32 | Amun-Ra | support what? |
11:36:33 | FromDiscord | <nocturn9x> `file.writeData(cast[ptr UncheckedArray[byte]](addr net), sizeof(Network))` |
11:36:35 | FromDiscord | <nocturn9x> this is the line |
11:36:44 | FromDiscord | <nocturn9x> In reply to @Amun-Ra "support what?": it says it doesn't support the cast operation |
11:36:45 | FromDiscord | <nocturn9x> 🤷 |
11:36:53 | Amun-Ra | that is what I'm saying |
11:37:16 | FromDiscord | <nocturn9x> how do I say this |
11:37:19 | Amun-Ra | do you have that function somewhere online? |
11:37:27 | FromDiscord | <nocturn9x> why do you think I would be bothering with this |
11:37:32 | FromDiscord | <nocturn9x> if I could just initialize the network normally |
11:37:37 | FromDiscord | <nocturn9x> the point is to not have copies. |
11:37:50 | FromDiscord | <nocturn9x> initializing the network would require copying the weights to the object |
11:37:54 | FromDiscord | <nocturn9x> which is what I am already doing |
11:37:57 | FromDiscord | <nocturn9x> and is not what I want |
11:38:00 | Amun-Ra | are we still talking compile time? |
11:38:06 | FromDiscord | <nocturn9x> what I want is for the network to be in the .static segment of the executable |
11:38:22 | FromDiscord | <nocturn9x> such that if more instances of my engine are run on the same machine, they'll all use the same network data |
11:38:24 | FromDiscord | <nocturn9x> without overhead |
11:38:32 | FromDiscord | <nocturn9x> since the executable is loaded in memory only once |
11:38:39 | FromDiscord | <nocturn9x> and they all access the same read only section of the binary |
11:38:55 | FromDiscord | <nocturn9x> any sort of runtime manipulation breaks that behavior |
11:39:05 | FromDiscord | <nocturn9x> so I can't initialize the object in any way, I need casting to work |
11:39:07 | FromDiscord | <nocturn9x> that's it |
11:39:22 | Amun-Ra | tbh there wouldn't be much overhead if those objects were duplicated, apart from memory overhead |
11:39:26 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=UnyKpRyc |
11:39:34 | FromDiscord | <nocturn9x> In reply to @Amun-Ra "tbh there wouldn't be": the memory overhead is literally the problem |
11:39:48 | FromDiscord | <nocturn9x> believe me, I know what I'm doing. This is standard practice for advanced chess engines. |
11:40:05 | FromDiscord | <nocturn9x> (edit) "https://play.nim-lang.org/#pasty=WMiQbFTz" => "https://play.nim-lang.org/#pasty=puMKxrkt" |
11:40:13 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=uyBuysCv |
11:40:22 | FromDiscord | <nocturn9x> what I need is for typecasting to work |
11:40:34 | FromDiscord | <nocturn9x> but I'm likely doing something wrong idk |
11:40:45 | FromDiscord | <nnsee> In reply to @nocturn9x "the memory overhead is": surely this is what references are for |
11:41:04 | FromDiscord | <nocturn9x> In reply to @nnsee "surely this is what": ah yes the famous references that cross process boundaries |
11:41:05 | FromDiscord | <nocturn9x> ???? |
11:41:14 | FromDiscord | <nnsee> .static doesn't cross process boundaries either |
11:41:19 | Amun-Ra | tbh I don't see a problem in replacing cast with init, keeping object unique |
11:41:19 | FromDiscord | <nocturn9x> it does |
11:41:21 | FromDiscord | <nnsee> every process gets allocated its own .static |
11:41:34 | FromDiscord | <nocturn9x> well then every top engine developer is a moron I guess |
11:41:48 | FromDiscord | <nocturn9x> cuz it works fine in C++ and gains measurable amounts of elo when running multiple instances on the same machine |
11:41:55 | FromDiscord | <nocturn9x> the runtime equivalent of this would be to mmap + cast |
11:42:02 | Amun-Ra | so you're saying every one of them tried to cast in compile-time nim code |
11:42:15 | FromDiscord | <nocturn9x> I'm saying they've done it in C++ without issue |
11:42:32 | FromDiscord | <nocturn9x> the casting isn't even the problem, I can just have that outside of the constant |
11:42:34 | FromDiscord | <nocturn9x> it has no runtime cost |
11:42:41 | FromDiscord | <nocturn9x> the problem is I can't get the object to dump to disk correctly |
11:43:33 | FromDiscord | <nocturn9x> so the question is how do I dump an arbitrary object to a binary file and then load it back in as a string using staticRead such that at "runtime" I can do `net = cast[Network](data)`? |
11:43:45 | FromDiscord | <nnsee> In reply to @nocturn9x "well then every top": interesting. apparently i'm wrong |
11:44:01 | FromDiscord | <nnsee> ie most OSs do the same physical pages but apply some sort of CoW for it |
11:44:05 | Amun-Ra | make a proc that parses a string returned from staticRead |
11:44:07 | FromDiscord | <nocturn9x> yes |
11:44:09 | FromDiscord | <nnsee> didn't know this, TIL |
11:44:10 | FromDiscord | <nocturn9x> that is the usual way |
11:44:32 | FromDiscord | <nocturn9x> In reply to @Amun-Ra "make a proc that": hmm that could work but it would make compile times slow as fuck since it'd be iterating ~18 million weights |
11:44:38 | FromDiscord | <nocturn9x> I tested this before |
11:44:52 | FromDiscord | <nocturn9x> In reply to @nnsee "ie most OSs do": and since the network weights are never written to |
11:44:55 | FromDiscord | <nocturn9x> (by design) |
11:44:57 | FromDiscord | <nocturn9x> then you get a free copy |
11:45:00 | FromDiscord | <nocturn9x> with no overhead |
11:45:02 | FromDiscord | <nocturn9x> it's pretty nifty |
11:45:10 | Amun-Ra | you haven't mentioned that before, convert once and keep the result in cache |
11:45:23 | FromDiscord | <nocturn9x> huh how do I do that |
11:46:23 | FromDiscord | <nnsee> In reply to @nocturn9x "ah yes the famous": in any case i assumed you were talking about threads and not processes |
11:46:35 | FromDiscord | <nocturn9x> also remind me what was the pure nim way of swapping two bytes? |
11:46:36 | FromDiscord | <nnsee> but yes, what you're trying to do makes sense |
11:46:46 | FromDiscord | <nocturn9x> In reply to @nnsee "in any case i": well that wouldn't be a problem |
11:46:53 | FromDiscord | <nocturn9x> the network weights are already shared across threads |
11:46:56 | FromDiscord | <nocturn9x> since it's a global |
11:49:16 | FromDiscord | <nnsee> if you were targeting just unix i would just recommend mmap with MAP_SHARED, but i'm guessing you want your engine to work on windows as well |
11:50:16 | FromDiscord | <nocturn9x> yeah |
11:50:26 | FromDiscord | <nocturn9x> some engines bother with that |
11:50:36 | FromDiscord | <nocturn9x> they decompress the net in a shared memory segment under /tmp and mmap that |
11:50:37 | FromDiscord | <nocturn9x> but ehh |
11:50:56 | FromDiscord | <nocturn9x> windows is an important target for my engine unfortunately |
11:50:59 | FromDiscord | <nocturn9x> many testers use it |
11:52:38 | FromDiscord | <nnsee> wait, remind me again why casting to the object at runtime doesn't work? |
11:53:31 | FromDiscord | <nocturn9x> idk it gets fucked |
11:53:37 | FromDiscord | <nocturn9x> my guess is the write part is the problem |
11:53:44 | FromDiscord | <nocturn9x> but it is just not reconstructed correctly |
11:54:31 | FromDiscord | <nocturn9x> I will try a different approach where instead of embedding the network weights in the binary and then load those into the network object at runtime, I just read those at compile time and load them directly into a default network object |
11:55:36 | FromDiscord | <nocturn9x> (edit) "I will try a different approach where instead of embedding the network weights in the binary and then load those into the network object at runtime, I just read those at compile time and load them directly into a default network object ... " added "still at compile time" |
11:56:19 | FromDiscord | <nocturn9x> ah and of course |
11:56:22 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=jZCSzHaK |
11:56:25 | FromDiscord | <nocturn9x> same error as yesterday |
11:56:30 | FromDiscord | <nocturn9x> lmao the VM is so fucked |
11:59:37 | FromDiscord | <nocturn9x> hysterical |
11:59:47 | FromDiscord | <nnsee> In reply to @nocturn9x "idk it gets fucked": can it be that you're casting a string type (returned by the staticRead) which has the length and the reserved field prepended to it, to your object which probably doesn't have those. i haven't actually done nim in a while so i forget if this is how it works |
12:00:10 | FromDiscord | <nocturn9x> I am doing exactly that |
12:00:19 | FromDiscord | <nocturn9x> upsie? |
12:00:39 | FromDiscord | <nocturn9x> can I like convert to cstring or something |
12:00:47 | FromDiscord | <nocturn9x> that would be null terminated tho |
12:00:47 | FromDiscord | <nocturn9x> hm |
12:00:55 | FromDiscord | <nocturn9x> I just need a raw stream of bytes 😭 |
12:03:22 | FromDiscord | <nnsee> add the same fields to your object and just treat it as arbitrary padding? |
12:03:56 | FromDiscord | <nnsee> and when writing it, cut those bytes from the beginning? idk how you're creating the binary data |
12:04:00 | FromDiscord | <nocturn9x> where can I find the string definition |
12:04:10 | FromDiscord | <nocturn9x> In reply to @nnsee "and when writing it,": literally just reading off from staticRead |
12:04:11 | FromDiscord | <nocturn9x> lol |
12:04:15 | FromDiscord | <nnsee> i'm currently looking for it |
12:04:31 | FromDiscord | <nocturn9x> `const DEFAULT_NET = when INCBIN: cstring(staticRead(DEFAULT_NET_PATH)) else: Network()` |
12:04:38 | FromDiscord | <nocturn9x> and then |
12:04:46 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=CooieCvn |
12:04:58 | FromDiscord | <nocturn9x> this currently does not work |
12:05:15 | FromDiscord | <nocturn9x> ahh ofc it can't work cuz of the padding |
12:05:16 | FromDiscord | <nocturn9x> nvm |
12:05:17 | FromDiscord | <nocturn9x> I'm stupid |
12:05:22 | FromDiscord | <nocturn9x> I need to dump the padded net to disk |
12:05:27 | FromDiscord | <nocturn9x> ugh this is so remarkably annoying fr |
12:05:59 | FromDiscord | <nocturn9x> this is how I dump it btw |
12:06:00 | FromDiscord | <nocturn9x> `file.writeData(cast[ptr UncheckedArray[byte]](addr net), sizeof(Network))` |
12:07:48 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=OdvuLEMV |
12:07:51 | FromDiscord | <nocturn9x> and this is the object itself |
12:10:27 | * | ftajhii quit (Ping timeout: 246 seconds) |
12:11:04 | FromDiscord | <nocturn9x> anyway I've dumped the raw network object to disk with that line of code and tried loading back in via a cast |
12:11:06 | FromDiscord | <nocturn9x> and it no workie |
12:11:06 | FromDiscord | <nocturn9x> so idk |
12:11:14 | FromDiscord | <nocturn9x> not even converting to cstring |
12:36:40 | * | derpydoo quit (Quit: derpydoo) |
12:46:56 | FromDiscord | <narimiran> Nim 2.2.2 is out!! ↵↵https://nim-lang.org/blog/2025/02/05/nim-222.html |
13:02:37 | FromDiscord | <enthus1ast.> In reply to @nocturn9x "so the question is": I would use https://github.com/treeform/flatty for this, idk if it would work on compile time, though. |
13:03:33 | FromDiscord | <enthus1ast.> there would also be no need for casting |
13:03:56 | FromDiscord | <nocturn9x> that looks nice |
13:03:57 | FromDiscord | <nocturn9x> hmm |
13:13:29 | FromDiscord | <nocturn9x> quick question about threading |
13:13:48 | FromDiscord | <nocturn9x> what is the most painless way you know of migrating from the old `createThread` paradigm to a thread pool? |
13:13:59 | FromDiscord | <nocturn9x> I've tried to do that many times and always failed |
13:14:43 | FromDiscord | <nocturn9x> not modifying my code would be nice, anything more than just replacing the `createThread` call with `something.submit()` is a no-go |
13:14:48 | FromDiscord | <nocturn9x> and I need shared heaps to work ofc |
13:27:36 | FromDiscord | <enthus1ast.> i personally still use createThread ... |
13:29:13 | FromDiscord | <enthus1ast.> but i know that some use https://github.com/Araq/malebolgia now |
13:44:02 | FromDiscord | <mratsim> In reply to @nocturn9x "not modifying my code": submit is primitive on top of createThread if people don't want to manage their threadpools / event loops |
13:44:20 | FromDiscord | <nocturn9x> In reply to @enthus1ast. "but i know that": that works surprisingly poorly |
13:44:21 | FromDiscord | <nocturn9x> tried it before |
13:44:35 | FromDiscord | <nocturn9x> In reply to @mratsim "submit is primitive on": can I get an example of how that works? |
13:45:15 | FromDiscord | <mratsim> In reply to @nocturn9x "can I get an": https://github.com/mratsim/weave-io/blob/master/weave_io/threadpool.nim#L940-L955 |
13:45:34 | FromDiscord | <mratsim> all threadpools, malebolgia, weave, taskpool, follow that pattern. |
13:46:29 | FromDiscord | <nocturn9x> I need something a bit higher level |
13:46:40 | FromDiscord | <nocturn9x> where I just instantiate a thread pool of a given size and submit procedures to it |
13:47:23 | FromDiscord | <mratsim> but you said that `something.submit()` is a no go? |
13:47:43 | FromDiscord | <nocturn9x> nono |
13:47:55 | FromDiscord | <nocturn9x> what I said is that anything more complex than `something.submit` is a no-go |
13:47:59 | FromDiscord | <mratsim> ah |
13:48:21 | FromDiscord | <mratsim> https://github.com/status-im/nim-taskpools |
13:48:28 | FromDiscord | <mratsim> It only does that. |
13:48:51 | FromDiscord | <nocturn9x> <https://git.nocturn9x.space/heimdall-engine/heimdall/src/branch/master/src/heimdall/search.nim#L1397-L1435> |
13:48:54 | FromDiscord | <nocturn9x> this is how I currently do it |
13:49:02 | FromDiscord | <mratsim> The api is intentionally simple so it's easy to audit: https://github.com/status-im/nim-taskpools?tab=readme-ov-file#api |
13:49:44 | FromDiscord | <nocturn9x> I think I tried nim-taskpools before |
13:49:48 | FromDiscord | <nocturn9x> with fairly disastrous results |
13:49:50 | FromDiscord | <nocturn9x> let me test once again |
13:49:54 | FromDiscord | <nocturn9x> seems simple enough |
13:50:46 | FromDiscord | <nocturn9x> I don't even need to handle return values or anything of the sort |
13:50:49 | FromDiscord | <mratsim> you shouldn't createThread within a loop, it takes like 10ms to create a thread. You should create it outside and then each worker wait on a queue and process task that are enqueued there.. |
13:51:00 | FromDiscord | <nocturn9x> I am aware this is suboptimal |
13:51:08 | FromDiscord | <nocturn9x> trying to refactor it has failed |
13:51:12 | FromDiscord | <nocturn9x> (edit) "trying to refactor it has failed ... " added "many times" |
13:51:15 | FromDiscord | <enthus1ast.> In reply to @mratsim "you shouldn't createThread within": this is how i use it |
13:51:30 | FromDiscord | <nocturn9x> I assume taskpools does this |
13:52:04 | FromDiscord | <mratsim> sent a long message, see https://pasty.ee/aEIPTWyn |
13:52:30 | FromDiscord | <nocturn9x> on windows the C codegen for it is broken too |
13:52:33 | FromDiscord | <nocturn9x> I'll get rid of it |
13:52:38 | FromDiscord | <mratsim> In reply to @nocturn9x "I assume taskpools does": it does this but instead of having a single queue, each worker has its queue and when their queue is empy they steal from each other. |
13:52:52 | FromDiscord | <nocturn9x> oo |
13:52:53 | FromDiscord | <nocturn9x> fancy |
13:53:35 | FromDiscord | <mratsim> this removes contention from many threads hammering a single queue (which needs syunchronization)↵which is crucial for small tasks. |
13:53:52 | FromDiscord | <nocturn9x> my tasks are pretty chonktastic tbh |
13:53:59 | FromDiscord | <mratsim> it doesn't matter for a task longer than 100ms ~ 1s though |
13:54:00 | FromDiscord | <nocturn9x> the engine search is long running and expensive |
13:54:07 | FromDiscord | <nocturn9x> yeah figures |
13:54:21 | FromDiscord | <nocturn9x> like a search in a multithreaded environments can take minutes |
13:54:25 | FromDiscord | <nocturn9x> several |
13:54:33 | FromDiscord | <nocturn9x> (edit) "minutes" => "minute" |
13:54:41 | FromDiscord | <nocturn9x> (edit) "like a search in a ... multithreadedenvironment" added "highly" | "environments" => "environment" | "minute" => "minutes" |
13:54:44 | FromDiscord | <mratsim> but if you have a lot of for loop it can help distributing them efficiently if one thread is starving and the other has work |
13:54:55 | FromDiscord | <nocturn9x> yeah that makes sense |
13:55:10 | FromDiscord | <mratsim> especially on CPUs with P and E core that process stuff at very different speeds |
13:56:33 | FromDiscord | <nocturn9x> yep |
13:58:42 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=nASuXDoL |
13:58:47 | FromDiscord | <nocturn9x> does this setup logic look fine? |
13:59:01 | FromDiscord | <nocturn9x> the number of threads can change at any time as long as a search is not in progress, so I need to handle this |
13:59:11 | FromDiscord | <nocturn9x> (it is set with a user facing option) |
13:59:40 | FromDiscord | <nocturn9x> ah ig I need to handle the case when it is one |
13:59:47 | FromDiscord | <nocturn9x> since one worker just means doing a single threaded search |
13:59:51 | FromDiscord | <nocturn9x> which is done in the main thread |
14:00:02 | FromDiscord | <nocturn9x> (the search is spawned in a separate thread via `createThread`) |
14:01:28 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=NYZfqCCE |
14:06:22 | FromDiscord | <nocturn9x> hmm |
14:06:25 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=bVDiXmzY |
14:07:13 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=rWRUkzrV |
14:07:38 | FromDiscord | <nocturn9x> (edit) "https://play.nim-lang.org/#pasty=rjprgHLa" => "https://play.nim-lang.org/#pasty=AdBeUweO" |
14:08:05 | FromDiscord | <nocturn9x> how do I tell it to shut up? Putting `{.raises: [].}` just causes the problem to be diverted up the call tree |
14:08:14 | FromDiscord | <nocturn9x> and I don't really want to mark every function I call like that lol |
14:09:31 | FromDiscord | <nocturn9x> how do I tell it to just stfu |
14:09:41 | FromDiscord | <nocturn9x> all exceptions are turned to panics anyway, they're all fatal errors |
14:11:51 | FromDiscord | <xtrayambak> In reply to @nocturn9x "how do I tell": Is there any particular reason you're doing that? Violating GC safety isn't my goto solution for this stuff |
14:12:05 | FromDiscord | <xtrayambak> Unless a library I'm using just doesn't have a gcsafe function I'm using |
14:12:07 | FromDiscord | <nocturn9x> there is no other way to make it work |
14:12:17 | FromDiscord | <nocturn9x> none of the things I'm doing can ever be inferred to be gcsafe |
14:12:32 | FromDiscord | <xtrayambak> Yikes, I'm pretty sure you have to do what you fear then |
14:12:49 | FromDiscord | <nocturn9x> there's loads of sharing and globals and stuff that are logically safe since they're either read only or written to at very specific, known safe intervals |
14:12:57 | FromDiscord | <nocturn9x> (or in the case of the TT, collisions just don't matter) |
14:13:06 | FromDiscord | <nocturn9x> the compiler will never be able to catch that |
14:13:17 | FromDiscord | <nocturn9x> I mean I say loads, actually it's not that many anymore |
14:13:21 | FromDiscord | <nocturn9x> just in a few critical places |
14:13:32 | FromDiscord | <nocturn9x> but they are very far reaching |
14:13:48 | FromDiscord | <nocturn9x> like for example the attack tables for move generation are constant size arrays shared across threads |
14:13:57 | FromDiscord | <nocturn9x> they're only ever read from so it's a non-issue |
14:14:02 | FromDiscord | <nocturn9x> ig nim would be able to catch that |
14:14:05 | FromDiscord | <nocturn9x> but the rest is more nuanced |
14:14:19 | FromDiscord | <nocturn9x> and I do use atomics for many things just to be on the safe side |
14:14:33 | FromDiscord | <xtrayambak> I've never done any serious multithreading in Nim before, I used [weave](https://github.com/mratsim/weave) to offload image buffer drawing tasks to another thread in my [rendering engine](<https://github.com/ferus-web/ferusgfx>) |
14:14:47 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=NxcKaiFz |
14:14:48 | FromDiscord | <nocturn9x> welp |
14:14:49 | FromDiscord | <nocturn9x> here we go |
14:14:52 | FromDiscord | <nocturn9x> time to debug |
14:15:15 | FromDiscord | <xtrayambak> What library are you using for threadpools? Weave, malbolgia or your own thing? |
14:15:25 | FromDiscord | <nocturn9x> nim-taskpools |
14:15:30 | FromDiscord | <xtrayambak> Ah |
14:15:39 | FromDiscord | <xtrayambak> Try weave, it works fairly well from my experience |
14:16:11 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=jjpSrcPM |
14:16:13 | FromDiscord | <nocturn9x> I was being silly |
14:16:14 | FromDiscord | <nocturn9x> logic mistake |
14:16:19 | FromDiscord | <xtrayambak> In my case (the rendering engine), the thread never has to interact with any GC unsafe segments (like accessing global variables) so it just worked well with weave |
14:16:47 | FromDiscord | <xtrayambak> mratsim is just a genius to be honest :P |
14:17:21 | FromDiscord | <xtrayambak> In reply to @nocturn9x "logic mistake": Haha I remember trying to write a multithreaded HTTP server with no prior experience, I managed to make glibc throw errors at me |
14:17:32 | FromDiscord | <xtrayambak> (edit) "In reply to @nocturn9x "logic mistake": Haha I remember trying to write a multithreaded HTTP server with no prior experience, I managed to make glibc throw ... errors" added "internal" |
14:17:58 | FromDiscord | <nocturn9x> rofl |
14:18:29 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=uHmxHlLI |
14:18:38 | FromDiscord | <nocturn9x> cool so it appears something is not working as intended |
14:20:52 | FromDiscord | <xtrayambak> sent a code paste, see https://play.nim-lang.org/#pasty=gSDFknik |
14:21:26 | FromDiscord | <nocturn9x> oh |
14:21:31 | FromDiscord | <nocturn9x> it's another skill issue on my part it seems |
14:21:40 | FromDiscord | <nocturn9x> the usual off by one error |
14:21:48 | FromDiscord | <nocturn9x> I'm spawning 2 workers but only one is supposed to be spawned |
14:21:56 | FromDiscord | <nocturn9x> so worker #2 looks for data structures that do not exist |
14:22:09 | FromDiscord | <nocturn9x> (the first "worker" is actually the search main thread) |
14:22:26 | FromDiscord | <arkanoid> I have a constant string that I want to copyMem into a seq[byte] at runtime.↵If I do `copyMem(addr destBuffer[0], addr constString[0], len(constString))` I get `Error: expression has no address`. How to workaround this? |
14:22:37 | FromDiscord | <nocturn9x> `unsafeAddr`? |
14:23:03 | FromDiscord | <nocturn9x> would be helpful to know exactly which expression has no address |
14:23:18 | FromDiscord | <nocturn9x> likely the constant string, as it might be referenced in the code as an offset in the static section of the binary |
14:24:07 | * | ntat joined #nim |
14:25:25 | FromDiscord | <nocturn9x> k so the threads are getting spawned now but I'm getting really weird behavior |
14:25:36 | FromDiscord | <nocturn9x> it appears syncAll is blocking forever even though the workers stopped executing |
14:25:43 | FromDiscord | <nocturn9x> the main thread tells them to stop and they should abide by this |
14:25:52 | FromDiscord | <nocturn9x> it works with createThread so idk what's different here |
14:25:57 | FromDiscord | <xtrayambak> In reply to @arkanoid "I have a constant": I'd just copy the string, but that's wasteful |
14:26:05 | FromDiscord | <xtrayambak> In reply to @nocturn9x "`unsafeAddr`?": `unsafeAddr` is deprecated |
14:26:09 | FromDiscord | <nocturn9x> ah |
14:31:57 | FromDiscord | <nocturn9x> `Spawns the input function call asynchronously, potentially on another thread of execution.` |
14:32:00 | FromDiscord | <nocturn9x> tf you mean _potentially_ |
14:32:09 | FromDiscord | <nocturn9x> nononononono |
14:32:14 | FromDiscord | <nocturn9x> it _has_ to go in a separate thread lmao |
14:32:20 | FromDiscord | <nocturn9x> I can't have it hog the main thread lol |
14:32:36 | FromDiscord | <nocturn9x> it'll fuck with everything |
14:32:42 | FromDiscord | <nocturn9x> that explains why stopping doesn't work correctly |
14:32:51 | FromDiscord | <nocturn9x> @mratsim? |
14:33:52 | FromDiscord | <nocturn9x> perhaps this was the showstopper last time |
14:35:22 | FromDiscord | <xtrayambak> In reply to @nocturn9x "tf you mean _potentially_": not-verbose-nuff documentation strikes again |
14:35:28 | FromDiscord | <xtrayambak> (edit) "In reply to @nocturn9x "tf you mean _potentially_": not-verbose-nuff documentation strikes again ... " added "and claims another victim" |
14:35:48 | FromDiscord | <nocturn9x> :kekw |
14:35:54 | FromDiscord | <nocturn9x> (edit) ":kekw" => "kek" |
14:36:07 | FromDiscord | <nocturn9x> why in the unholy fuck would I ever _not_ want to spawn the task in another thread |
14:36:11 | FromDiscord | <nocturn9x> how can it be asynchronous otherwise |
14:36:19 | FromDiscord | <nocturn9x> it says on the README it doesn't support async-await |
14:36:27 | FromDiscord | <nocturn9x> so how does it run the task if I don't call syncAll |
14:36:27 | FromDiscord | <nocturn9x> lmao |
14:36:44 | FromDiscord | <nocturn9x> number of times I wanted to murder the author of a thread library: +1 |
14:37:04 | FromDiscord | <odexine> asynchronous means concurrent not parallel& |
14:37:05 | FromDiscord | <odexine> (edit) "parallel&" => "parallel" |
14:37:11 | FromDiscord | <nocturn9x> mate |
14:37:12 | FromDiscord | <xtrayambak> ^ |
14:37:18 | FromDiscord | <xtrayambak> In reply to @odexine "asynchronous means *concurrent* not": ^ |
14:37:19 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=qvtQBVxj |
14:37:24 | FromDiscord | <nocturn9x> I am ACUTELY aware of the difference |
14:37:27 | FromDiscord | <nocturn9x> I write event loops for fun |
14:37:35 | FromDiscord | <nocturn9x> the guy writing this README probably is not, though |
14:37:42 | FromDiscord | <nocturn9x> since it literally says "parallel" right there |
14:37:51 | FromDiscord | <odexine> what library is this again |
14:37:53 | FromDiscord | <nocturn9x> so is it parallel or not |
14:37:55 | FromDiscord | <nocturn9x> nim-taskpools |
14:38:03 | FromDiscord | <nocturn9x> do I have to clone the library and fix the retardation myself smh |
14:38:04 | FromDiscord | <odexine> oh this one |
14:38:06 | FromDiscord | <xtrayambak> In reply to @odexine "what library is this": status IM's nim-taskpool |
14:38:11 | FromDiscord | <xtrayambak> I've never had a good time with it myself |
14:38:15 | FromDiscord | <nocturn9x> at least give me the option to force spawn it in a thread |
14:38:18 | FromDiscord | <xtrayambak> (edit) "nim-taskpool" => "nim-taskpools" |
14:38:30 | FromDiscord | <nocturn9x> having non changeable defaults should be grounds for death by firing squad |
14:38:32 | FromDiscord | <nocturn9x> genuinely |
14:39:43 | * | alexdaguy quit (Quit: w) |
15:00:49 | FromDiscord | <nocturn9x> yeah idk nim-taskpools is severely retarded |
15:00:57 | FromDiscord | <nocturn9x> I'm afraid it's trying to do something it's not supposed to |
15:03:24 | FromDiscord | <nocturn9x> like |
15:03:28 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=gPMVENYN |
15:03:32 | FromDiscord | <nocturn9x> it doesn't even complete the spawning process |
15:03:37 | FromDiscord | <nocturn9x> it just dies |
15:03:46 | FromDiscord | <nocturn9x> and the traceback is mangled of course so it's useless garbage |
15:04:13 | FromDiscord | <nocturn9x> ehh altho |
15:04:17 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=GqtBWYLc |
15:04:21 | FromDiscord | <nocturn9x> the if stmt is line 438 |
15:04:26 | FromDiscord | <nocturn9x> so it is failing to load the atomic |
15:04:31 | FromDiscord | <nocturn9x> the question is why the fuck is it nil |
15:05:03 | * | jjido joined #nim |
15:05:03 | FromDiscord | <nocturn9x> since when can atomics even be nil |
15:05:40 | FromDiscord | <nocturn9x> can someone recommend a thread pool library that does not suffer from mental retardation and is still not trash to use |
15:08:56 | FromDiscord | <nocturn9x> even weave has this: spawn fnCall(args) which spawns a function that may run on another thread |
15:09:07 | FromDiscord | <nocturn9x> I don't want to _maybe_ run on another thread |
15:09:12 | FromDiscord | <nocturn9x> I want to run on another thread period |
15:09:22 | FromDiscord | <nocturn9x> genuine question: has anyone ever needed this? |
15:09:32 | FromDiscord | <nocturn9x> like why would I want to hog my main thread with random shit tasks |
15:16:52 | FromDiscord | <nocturn9x> @mratsim since weave is your library, please for the love of god give the option to always spawn a task on a worker thread |
15:17:27 | FromDiscord | <odexine> i think i understand now, its because if you only have one task in the queue why would you use a separate thread? |
15:17:35 | FromDiscord | <nocturn9x> because I want to???? |
15:17:39 | FromDiscord | <nocturn9x> like give me the freaking option |
15:17:57 | FromDiscord | <nocturn9x> my engine was designed like this, I'm not about to rearchitecture the design because a library writer couldn't be arsed to expose a configuration option |
15:18:30 | FromDiscord | <nocturn9x> like is it so much to ask for something like Python's `ThreadPoolExecutor` |
15:18:34 | FromDiscord | <nocturn9x> it does one thing and it does it well |
15:18:52 | FromDiscord | <nocturn9x> who the fuck cares about a parallel raytracing demo if you can't actually direct the library to do the most basic shit? |
15:19:20 | FromDiscord | <nocturn9x> sorry for my tone but this is like the 340943578th time I deal with this shit and I'm tired |
15:19:25 | FromDiscord | <odexine> ok |
15:19:29 | FromDiscord | <nocturn9x> nim's threading ecosystem is a hot steaming pile of garbage |
15:19:40 | FromDiscord | <nocturn9x> just have one library that works in the stdlib smh |
15:19:45 | FromDiscord | <odexine> i mean simply i'll just stop interacting with you so dw about it |
15:20:44 | FromDiscord | <nocturn9x> `Weave can also be run as a background service and process jobs similar to the Executor concept in C++. Jobs will be processed in FIFO order.` |
15:20:48 | FromDiscord | <nocturn9x> is that maybe what I need |
15:21:18 | FromDiscord | <nocturn9x> well okay maybe but it looks way too overengineered |
15:29:16 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
15:34:06 | FromDiscord | <nocturn9x> welp it seems I ended up figuring out how to use `std/threadpools` |
15:34:10 | FromDiscord | <nocturn9x> will test now to see if anything breaks |
15:34:29 | FromDiscord | <nocturn9x> but holy guacamole is doing threading in nim a huge pain in the butt. |
15:45:54 | FromDiscord | <solitudesf> how do i unsubscribe from this blog? |
15:49:57 | FromDiscord | <nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=jZyHyuZR |
15:50:00 | FromDiscord | <nocturn9x> #rip |
15:50:05 | FromDiscord | <nocturn9x> random crashes |
15:50:44 | FromDiscord | <nocturn9x> (the lines are all wrong) |
17:20:06 | Amun-Ra | random? hmm, accessing uninitialized data? |
17:29:00 | FromDiscord | <nocturn9x> well |
17:29:07 | FromDiscord | <nocturn9x> I'm fairly sure it is initialized |
17:29:11 | FromDiscord | <nocturn9x> I could be wrong |
17:29:16 | FromDiscord | <nocturn9x> I'll check more thoroughly tomorrow |
17:29:27 | FromDiscord | <nocturn9x> I can only deal with so many multithreading headaches in one day |
17:30:09 | Amun-Ra | hmm |
17:31:29 | FromDiscord | <nocturn9x> all I can say is it works fine for a while and then randomly crashes |
17:31:36 | FromDiscord | <nocturn9x> no issues when using threads spawned with createThreads |
18:01:53 | * | jjido joined #nim |
18:17:45 | * | bessieTheBoy joined #nim |
18:19:56 | bessieTheBoy | I know about a million people have probably asked this. But, I built nim on linux (Ubuntu/Debian) and I copied the binaries to my /usr/bin folder but when I try to do "nimble install sdl2" I get this error: |
18:19:57 | bessieTheBoy | Error: cannot open '/usr/lib/nim/lib/system.nim' |
18:21:29 | Amun-Ra | hmm, weird, I install nim on debian manually except I don't pollute /bin directory and use /opt instead (I symlink all the /opt/nim/bin to /usr/local/bin tho) |
18:22:02 | Amun-Ra | and I just clone the repo; git checkout v2.2.2; ./build_all.sh |
18:22:42 | bessieTheBoy | same :\ except polluting /bin dir (well technically /usr/bin) |
18:22:49 | Amun-Ra | I promise myself I'll find a time to build a proper deb someday ;> |
18:23:38 | Amun-Ra | ah, I can see the error - you have to copy more dirs than just bin |
18:23:57 | bessieTheBoy | oh |
18:24:24 | Amun-Ra | config and lib too |
18:24:30 | Amun-Ra | I have those: bin compiler config dist doc icons lib tools |
18:24:40 | bessieTheBoy | k ill see if that fixes it |
18:27:53 | Amun-Ra | Error: internal error: genTypeInfo(tyNil) |
18:28:24 | bessieTheBoy | now I get: |
18:28:24 | bessieTheBoy | Evaluating as NimScript file failed with: |
18:28:25 | bessieTheBoy | ... /tmp/nimblecache-1729675248220492780/sdl2_1755853463851935521/sdl2.nims(6, 8) Error: cannot open file: strutils |
18:28:27 | bessieTheBoy | oop |
18:28:34 | Amun-Ra | I switched from 2.0.14 to 2.2.2 to see whether the same error occures as on 2.0.2; reverting to 2.0.14 |
18:28:49 | bessieTheBoy | probably should've done a pastebin for that, sorry |
18:29:38 | Amun-Ra | run "nim dump" and check all search paths |
18:30:37 | bessieTheBoy | nim dump spits out the "list of currently defined symbols" is that correct? |
18:31:13 | Amun-Ra | yes |
18:31:17 | bessieTheBoy | oh but at the bottom after "end of list" there's: |
18:31:42 | Amun-Ra | now it's a good idea to use pastebin ;) |
18:31:46 | bessieTheBoy | /usr/lib/nim/lib |
18:31:54 | bessieTheBoy | just that |
18:32:02 | bessieTheBoy | oh |
18:32:04 | bessieTheBoy | yeah |
18:32:32 | Amun-Ra | do you have std directory inside /usr/lib/nim/lib? |
18:34:12 | bessieTheBoy | yes |
18:34:13 | bessieTheBoy | also |
18:34:15 | bessieTheBoy | https://pastebin.com/3BCUy5yv |
18:35:06 | bessieTheBoy | a quick "ls | grep str" in /usr/lib/nim/lib/std shows that strutils.nim does not exist |
18:35:46 | Amun-Ra | it's in "pure" |
18:35:55 | Amun-Ra | I mean /usr/lib/nim/lib/pure |
18:36:14 | bessieTheBoy | just realized that after a quick google search of "strutils.nim" XD |
18:36:20 | Amun-Ra | I think you're missing /usr/lib/nim/config |
18:36:24 | bessieTheBoy | prob |
18:36:29 | bessieTheBoy | lemme fix rq |
18:36:42 | bessieTheBoy | but how do I add that to search dirs? |
18:37:04 | bessieTheBoy | oh config will fix that i'd imagine? |
18:37:05 | Amun-Ra | you don't |
18:37:07 | * | xet7 joined #nim |
18:37:09 | Amun-Ra | yes |
18:37:42 | Amun-Ra | ok, I reverted to 2.0.14; I'll play with 2.2.2's koch in spare time |
18:38:24 | bessieTheBoy | it works thx |
18:38:31 | Amun-Ra | no worries |
18:39:27 | Amun-Ra | https://github.com/nim-lang/Nim/blob/485b414fcec195bf217aba252e97c3c71f9bf489/config/nim.cfg#L47-L60 |
18:40:56 | bessieTheBoy | nice |
18:41:07 | bessieTheBoy | that makes sense |
18:41:20 | Amun-Ra | that was missing |
18:41:26 | bessieTheBoy | yeah |
18:59:25 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
19:25:05 | * | coldfeet joined #nim |
19:26:19 | bessieTheBoy | btw I took note on the deb thing you said and just made an amd64 deb. |
19:26:32 | bessieTheBoy | just tested it in a chroot |
19:26:38 | bessieTheBoy | chroot jail* |
19:30:02 | bessieTheBoy | only downside is that I couldn't find if nimble works or not. I'm not good enough at chroot jails to add networking |
19:31:01 | * | jjido joined #nim |
20:20:21 | * | pbsds35 quit (Quit: The Lounge - https://thelounge.chat) |
20:21:06 | * | pbsds35 joined #nim |
20:29:09 | * | Jjp137 quit (Ping timeout: 248 seconds) |
20:29:35 | * | Jjp137 joined #nim |
21:39:36 | * | coldfeet quit (Quit: Lost terminal) |
21:47:10 | * | ntat quit (Quit: Leaving) |
21:47:43 | * | bessieTheBoy quit (Quit: Client closed) |
21:53:08 | * | rockcavera joined #nim |
21:57:35 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
21:59:18 | FromDiscord | <.bobbbob> If nim's std lib is mit licensed and statically compiled then does that mean pretty much any nim code will have to provide copyright info for nim? |
22:05:03 | FromDiscord | <Elegantbeef> No cause Nim libraries do not ship Nim code |
22:05:50 | FromDiscord | <Elegantbeef> In reality you can replace Nim's stdlib with your own stdlib if you so wish and license it under whatever you want |
22:08:01 | * | bessieTheBoy joined #nim |
22:18:48 | FromDiscord | <.bobbbob> I was under the impression that compiling mit licensed code from a library means you have to provide the copyright information for that library when you distribute it |
22:19:09 | FromDiscord | <.bobbbob> Maybe the info in the nimble file is enough? |
22:20:13 | FromDiscord | <.bobbbob> another question, how do you guys go about running tests in another test file for code that I dont want to export from that module? Say a function in the main file that's only supposed to be used in that file |
22:50:54 | FromDiscord | <.bobbbob> did nim 2.2.2 break nimble? it wont run any commands now, it just stalls |
23:15:53 | * | bessieTheBoy quit (Quit: Client closed) |