<< 02-10-2024 >>

00:00:05*disso-peach quit (Quit: Leaving)
00:00:12*albe quit (Quit: The Lounge - https://thelounge.chat)
00:07:19*albe joined #nim
02:00:38FromDiscord<Nlits (Ping on reply)> Are seqs and strings still stored on the heap
02:00:48FromDiscord<Elegantbeef> Of course
02:02:14FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Of course": So then sizeof(string) should be all i need to allocate for a string, since the actual data is stored elsewhere, correct?
02:02:35FromDiscord<Elegantbeef> Yes
02:19:53FromDiscord<Nlits (Ping on reply)> And finally, would i need to manually share the stored data to share it between threads? It seems there is no easy way to create a sharedAlloc string
02:20:11FromDiscord<Nlits (Ping on reply)> If yes, how
02:23:53FromDiscord<Elegantbeef> Pass it as a parameter to a thread
02:24:02FromDiscord<Elegantbeef> Make it a global variable and `{.gcsafe.}: ...` it
02:24:12FromDiscord<Elegantbeef> Pass it across a channel using `ptr string`
02:25:41FromDiscord<Elegantbeef> You do not even need `sharedAlloc` if you ensure the string outlives the threads
02:32:36FromDiscord<Nlits (Ping on reply)> In reply to @Elegantbeef "Pass it across a": Hm for some reason i thought channels were deprecated. (The string doesn't outlive the thread and is deeply embedded in a object, making things more difficult)
03:12:02FromDiscord<illum1nation> what hashing algorithm does std/hash use? I could'nt find it in the docs
03:12:12FromDiscord<illum1nation> (edit) "std/hash" => "std/hashes"
03:19:35FromDiscord<Elegantbeef> It's an implementation detail, but seems it's wangyi hash and murmurhash
03:21:20*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
03:27:19*SchweinDeBurg joined #nim
04:08:59FromDiscord<xtrayambak> In reply to @demotomohiro "How about to this?": I actually have casted a `Function` into a `Scope` and want to turn it back into a `Function`, but that results in the `name` string's length becoming a big integer and accessing the `name` string causes a segmentation fault
04:09:03FromDiscord<xtrayambak> but again, I was using `cast`
04:09:18FromDiscord<xtrayambak> doing `Function(myScope)` causes a conversion defect
04:10:50FromDiscord<Elegantbeef> I really should make a PR that on first install if Nim detects `cast` in user code you have to agree to a "I understand that `cast` is an unsafe operation that retinterprets bits and will not abuse it" 😄
04:35:20*rockcavera quit (Remote host closed the connection)
04:59:39FromDiscord<demotomohiro> In reply to @xtrayambak "I actually have casted": Use `cast` only when you know the data structure of variables and how memory management works.↵`cast` just copys bits and it doesn't copy safely any variables.
04:59:50FromDiscord<xtrayambak> In reply to @demotomohiro "Use `cast` only when": ah
05:00:16FromDiscord<xtrayambak> In reply to @Elegantbeef "I really should make": yeah, that was probably stupid on my part
05:10:04FromDiscord<demotomohiro> sent a long message, see https://pasty.ee/rTKHLjty
05:12:15FromDiscord<Elegantbeef> You'd think demo, but people cannot read
05:12:23FromDiscord<Elegantbeef> They see `cast` and go "Oh I want to convert types"
05:13:57FromDiscord<demotomohiro> hmm
05:23:05FromDiscord<Elegantbeef> I might be too jaded and cynical
06:29:13*PMunch joined #nim
06:37:01FromDiscord<nnsee> might be? that's surprisingly optimistic of you
06:39:05FromDiscord<Elegantbeef> I do always like to downplay reality
07:46:39FromDiscord<Robyn [She/Her]> How would I go about making workers in Nim? I want to have a queue of available worker threads that I pass work to when they're available, but I don't want to wake up the thread as work is available, not sure how exactly to do that
07:47:57FromDiscord<Elegantbeef> Use a channel
07:48:04FromDiscord<Elegantbeef> Use selectors
07:48:33FromDiscord<Robyn [She/Her]> i want to wake up the thread i mean
07:48:51FromDiscord<Elegantbeef> Right so you do `let data = channel.recv()`
07:49:05FromDiscord<Elegantbeef> `recv` is blocking
07:49:54FromDiscord<Elegantbeef> You can just use a threadpool though
07:50:04FromDiscord<Robyn [She/Her]> In reply to @Elegantbeef "`recv` is blocking": Oooh okay, rad
07:53:10*HER_ joined #nim
07:55:00*HER quit (Ping timeout: 252 seconds)
07:55:49*redj quit (Quit: No Ping reply in 180 seconds.)
07:57:16*redj joined #nim
08:05:12*jjido joined #nim
08:53:21*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
09:18:00*cnx quit (Remote host closed the connection)
09:26:50*cnx joined #nim
09:31:10*coldfeet joined #nim
10:15:24*coldfeet quit (Remote host closed the connection)
11:43:25*ryuukk quit (Remote host closed the connection)
11:44:23*ryuukk joined #nim
12:04:30FromDiscord<nocturn9x> What is the simplest, cross-platform way for me to have threads wait on a semaphore?
12:04:45FromDiscord<nocturn9x> I'm trying to keep worker threads around instead of creating them every time, and sleeping on a semaphore seems like the way to go
12:04:54FromDiscord<nocturn9x> or a condition variable, whatever works
12:20:56FromDiscord<nocturn9x> sent a code paste, see https://play.nim-lang.org/#pasty=bCajEYZy
12:21:25FromDiscord<nocturn9x> `self.children[i]` is a big `ref object` and I can't afford to not use it in the main thread (all shared state is accessed through atomics and is therefore safe): how do I make nim shut up?
12:23:06FromDiscord<griffith1deadly> In reply to @nocturn9x "`self.children[i]` is a big": unsafeIsolate exists
12:23:24FromDiscord<nocturn9x> how do I use it though?
12:24:02FromDiscord<nocturn9x> I don't control `threadpools`' code
12:24:05FromDiscord<nocturn9x> so I can't just go and change it
12:24:38FromDiscord<nocturn9x> it seems the problem is with `toTask()`
12:27:57FromDiscord<nocturn9x> I can get around it by storing the reference somewhere else and then letting the thread access that, but it's kind of ugly
12:28:38FromDiscord<griffith1deadly> seems like thats only possible way
12:34:15*ryuukk quit (Remote host closed the connection)
12:36:32*ryuukk joined #nim
12:37:55*ntat joined #nim
13:00:34FromDiscord<nocturn9x> _Spawns the input function call asynchronously, potentially on another thread of execution._↵what the fuck do you mean potentially↵the fuck is the point of a library called threadpools if it only potentially spawns different threads↵I stg sometimes Nim makes me want to kill someone.
13:00:41FromDiscord<nocturn9x> (edit) "potentially" => "_potentially_"
13:01:17FromDiscord<nocturn9x> I want it to _always_ start a new thread
13:03:06FromDiscord<nocturn9x> and I want it to be immediate, too. From my testing it seems that `spawn` does not actually immediately create a task
13:03:08FromDiscord<nocturn9x> that is a big problem
13:04:37FromDiscord<odexine> if the current thread is idle then why would it need to use another thread, or perhaps it means that itll reuse an idle thread thats been spawned already
13:06:23FromDiscord<nocturn9x> the current thread is most definitely _not_ idle
13:06:30FromDiscord<nocturn9x> since it spawns stuff then goes on to do work on its own
13:06:39FromDiscord<nocturn9x> the problem is that it seems spawning is done lazily
13:06:46FromDiscord<nocturn9x> until you sync on something or call syncAll
13:06:50FromDiscord<nocturn9x> that is _not_ okay
13:06:56FromDiscord<nocturn9x> I need the worker to start when I say so
13:07:21FromDiscord<nocturn9x> because if I have the thread argument set to, say, 5, then I spawn 4 workers and do the same work on the thread that created the pool
13:07:30FromDiscord<nocturn9x> because this is how SMP is generally implemented in chess engines
13:07:38FromDiscord<nocturn9x> this doesn't work if the workers start _after_ main search is done
13:09:05FromDiscord<nocturn9x> anyway, whatever, this is just a sign that threading in Nim is still as garbage as I remember it to be
13:09:09FromDiscord<nocturn9x> (edit) "remember" => "remembered"
13:09:31FromDiscord<nocturn9x> there is not _one_ simple library that implements a basic `Event` with `set`/`wait`, seemingly for no reason
13:09:40FromDiscord<nocturn9x> might just make one myself at that point
13:50:20FromDiscord<nervecenter> You should probably have this talk with Araq in #internals
13:50:43FromDiscord<nervecenter> In reply to @nocturn9x "_Spawns the input function": You should probably have this talk with Araq in #internals
13:59:57*beholders_eye joined #nim
14:01:21*acidsys quit (Ping timeout: 248 seconds)
14:02:22FromDiscord<narimiran> Who wants a new Nim release?↵↵Here, have two: https://nim-lang.org/blog/2024/10/02/nim-220-2010.html
14:11:56*PMunch quit (Quit: Leaving)
14:20:15*ryuukk quit (Remote host closed the connection)
14:21:58*ryuukk joined #nim
14:25:55*acidsys joined #nim
14:29:11FromDiscord<fabric.input_output> > ↵> ↵> Methods now support implementations based on a VTable by using --experimental:vtables. Methods are then confined to the same module where their type has been defined.↵💪 yay
14:29:16FromDiscord<kiloneie> I saw this when i was in the bathroom, then i forgot about it till i saw announcement post.↵↵Where do i post FORUM issues ?
14:29:24FromDiscord<kiloneie> under website ?
14:29:25FromDiscord<fabric.input_output> (edit) removed "↵> ↵>"
14:32:21FromDiscord<spotlightkid> https://github.com/nim-lang/nimforum/issues
14:57:31*coldfeet joined #nim
15:22:49*lucasta joined #nim
15:29:41FromDiscord<kiloneie> Man... there is no difference between Farm and the previous... https://media.discordapp.net/attachments/371759389889003532/1291059540724289637/image.png?ex=66feb865&is=66fd66e5&hm=3b24ed1ecce3bbfb1f1e61d01a085d663561e6ba81372c76b6c8dc5dd60f6899&
15:29:54FromDiscord<kiloneie> Bad benchmark ?
15:42:28FromDiscord<kiloneie> Wait, this has to be because im using a 16bit int instead of what Farm can do, a 64bit string Hash ?
15:43:34FromDiscord<odexine> farm is not going to improve performance for hashing a 16 bit int
15:43:46FromDiscord<odexine> hashing a 16 bit int is already unnecessary
15:43:57FromDiscord<kiloneie> Does choosenim allow you to have multiple Nim versions for such testings ? I always do a manual install.
15:44:14FromDiscord<odexine> iirc yes?
15:44:18FromDiscord<odexine> just switch between them
15:44:36FromDiscord<kiloneie> wait i can just ". Define nimStringHash2 to get the old values back." right ?
15:46:17FromDiscord<kiloneie> "std/hashes.hash(x:string) changed to produce a 64-bit string Hash", is this just for 64bit strings then ?... im confused
16:32:42FromDiscord<jmgomez> '
16:36:52FromDiscord<fabric.input_output> so now hashes are 64 bit?
16:37:15FromDiscord<fabric.input_output> cuz until now it was `type Hash = distinct uint32` or smth
16:45:06FromDiscord<kiloneie> https://github.com/nim-lang/Nim/blob/version-2-0/lib/pure/collections/sets.nim↵I think only the algorithm has changed to Farm-like.
16:45:21FromDiscord<kiloneie> im not that good with github yet...
16:48:41*lucasta quit (Remote host closed the connection)
17:15:16*coldfeet quit (Remote host closed the connection)
17:56:54FromDiscord<rakgew> iirc the typical farm hash result is a uint64
17:59:43FromDiscord<spotlightkid> Yes, that is the point of choosenim. But only one version can be active at any one time. It is not like e.g. pyenv, where you can set different Python version for different projects or just for the active shell.↵(@kiloneie)
18:16:49FromDiscord<kiloneie> so i can do something like choosenim 2.0.8, it downloads it(or i have to b4 hand), and then compile, and redo for 2.2.0, right ?
18:19:10FromDiscord<griffith1deadly> choosenim 2.0.8↵nim -v↵choosenim 2.2.0↵nim -v
18:20:41FromDiscord<kiloneie> And choosenim can self update right ?
18:22:15*ntat quit (Quit: Leaving)
18:52:51*jjido joined #nim
18:57:17FromDiscord<double_spiral> In reply to @narimiran "Who wants a new": bro chill im still on 2.0.6
19:12:50*jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…)
19:13:01FromDiscord<rakgew> for nim2.2.0 I thought I try out choosenim, but no luck so far\:↵anyone else has problems running latest choosenim on debian(12/bookworm)?↵it does compile, but when run I get the error `could not load: libcurl.so(|.4)` even though I have the dependency `libcurl4-gnutls-dev` installed as mentioned in the readme and issue #303
19:14:37FromDiscord<rakgew> ah? the debug build runs? weird
19:17:03FromDiscord<rakgew> ok, without `-d:staticBuild` it works. \:-D
19:47:43FromDiscord<silme94> can we use tlHelp32.h functions in nim? if yes how
19:48:00FromDiscord<silme94> like CreateToolhelp32Snapshoot
20:17:47FromDiscord<Nlits (Ping on reply)> What is the best way to pass priority in a async? I have something i want to check every cycle, and am currently using sleepAsync but that hangs. I understand running checks until isn't a very efficient or async thing to do but i don't really have any options in my current situation
20:23:26FromDiscord<enthus1ast.> Maybe fulfill a promise?
20:25:47FromDiscord<Nlits (Ping on reply)> In reply to @enthus1ast. "Maybe fulfill a promise?": If done in a while loop it overwhelms async resulting in a block (It creates a new promise before async goes and resolves a different one)
20:26:20FromDiscord<enthus1ast.> What do you mean by cycle?
20:27:59FromDiscord<enthus1ast.> And sleepAsync is designed to "hang"
20:28:18FromDiscord<enthus1ast.> Maybe there is a fundamental misunderstanding?
20:30:09FromDiscord<enthus1ast.> What I sometimes did was asyncCheck a proc which had an endless loop doing something and await sleepAsync
20:32:44FromDiscord<enthus1ast.> But I do not use async any more (or quite seldom) for instances where I need similar functionality I used a simple hack like this: ↵↵https://github.com/enthus1ast/nimRunEngine↵https://github.com/enthus1ast/nimIntervalEngine
20:33:45FromDiscord<enthus1ast.> The two functions above let me remove all async code I had
20:33:58FromDiscord<Nlits (Ping on reply)> In reply to @enthus1ast. "And sleepAsync is designed": That was a separate issue i accidentally mixed in there where my code was hanging forever
20:34:02FromDiscord<enthus1ast.> (edit) "functions" => "modules"
20:46:01*beholders_eye quit (Read error: Connection reset by peer)
20:47:37FromDiscord<Nlits (Ping on reply)> In reply to @enthus1ast. "What do you mean": I need it to check often, but not often to block other tasks
20:47:42FromDiscord<Nlits (Ping on reply)> Would poll work?
20:49:57FromDiscord<Nlits (Ping on reply)> poll seems to work
21:12:52FromDiscord<Nlits (Ping on reply)> Update: i created a new, better wait for cycle function, but now i still have the issue where sleepAsync hangs forever. (With prologue)
21:14:32*om3ga quit (Ping timeout: 255 seconds)
21:20:02FromDiscord<Nlits (Ping on reply)> I managed to fix the problem by creating a loop on every thread, but a solution where I can run it on the main thread would be helpful
21:27:10*HER_ is now known as HER
21:32:23FromDiscord<enthus1ast.> Why not just spawn a thread?
21:32:44FromDiscord<enthus1ast.> Then lock the stuff you need to access and call it a day 🙂 ?
22:04:30FromDiscord<Nlits (Ping on reply)> In reply to @enthus1ast. "Why not just spawn": Idk how prologue handles threads and how to safely spawn one
23:36:27FromDiscord<spotlightkid> Yes, but if you have choosenim \<= 0.8.4 installed, don't use `choosenim update self`, because choosenim's repo moved moved from \>= 0.8.5. So you need to re-install it from https://github.com/nim-lang/choosenim
23:37:01FromDiscord<spotlightkid> Yes, but if you have choosenim \<= 0.8.4 installed, don't use `choosenim update self`, because choosenim's repo moved moved from \>= 0.8.5. So you need to re-install it from https://github.com/nim-lang/choosenim↵(@kiloneie)
23:40:33FromDiscord<kiloneie> Okay. I haven't had a choosenim for more than a test try years ago so no problems there.
23:51:32*fallback quit (Read error: Connection reset by peer)