00:24:19 | * | def- quit (Quit: -) |
00:25:06 | * | def- joined #nim |
00:28:16 | * | pmp-p quit (Ping timeout: 260 seconds) |
00:31:13 | * | def- quit (Quit: -) |
00:31:50 | * | def- joined #nim |
00:40:02 | * | def- quit (Quit: -) |
00:50:15 | FromDiscord | <albassort> alright beef |
00:50:34 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=GVSnEVub |
00:54:46 | * | pmp-p joined #nim |
00:58:18 | * | def- joined #nim |
01:03:49 | FromDiscord | <Elegantbeef> Who hurt you |
01:07:07 | FromDiscord | <fenilli> sent a code paste, see https://play.nim-lang.org/#pasty=sPxRcGJH |
01:08:29 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=MXgaFSyU |
01:12:20 | FromDiscord | <kots> In reply to @fenilli "I'm wondering why does": Probably because of seq[object] |
01:12:47 | FromDiscord | <polylokh_39446> yeah, that's an awful error message though |
01:14:17 | FromDiscord | <fenilli> Any idea on what to do to fix it? is `seq[object]` too ambiguous? |
01:14:41 | FromDiscord | <fenilli> oh yeh that is probably the case, changing to int works. |
01:15:02 | FromDiscord | <kots> object is not a concrete type |
01:15:04 | * | def- quit (Quit: -) |
01:15:28 | * | def- joined #nim |
01:16:18 | FromDiscord | <fenilli> well that is a bit annoying but I guess it makes sense, as nim needs to know at compile time what type of seq is it right? |
01:16:24 | FromDiscord | <kots> Right |
01:16:24 | FromDiscord | <polylokh_39446> AIUI the error's from Nim trying to take that as a typeclass and give you implicitly generic code. |
01:16:58 | FromDiscord | <polylokh_39446> you'll get the same error from `seq[int or float]` |
01:16:59 | FromDiscord | <fenilli> well the error is really bad for someone new even worst but I guess it makes sense after I think bout it. |
01:17:01 | FromDiscord | <Elegantbeef> Oh damn someone writing a quad tree |
01:17:10 | FromDiscord | <Elegantbeef> I wrote a Data oriented one just a few weeks ago |
01:17:25 | FromDiscord | <fenilli> well first one I'm making for a simple game of asteroids for colission |
01:18:20 | FromDiscord | <Elegantbeef> Yea mine was the first I've written |
01:18:30 | FromDiscord | <Elegantbeef> Nice general purpose with no references 😄 |
01:19:18 | FromDiscord | <fenilli> I'm just a bit in the thinking side now, probably have to make a Entity type to keep track of it now. |
01:19:30 | FromDiscord | <fenilli> so `seq[Entity]` would work. |
01:19:39 | FromDiscord | <Elegantbeef> https://github.com/beef331/keyboardwarrior/blob/master/data/quadtrees.nim for my version if interested |
01:19:44 | FromDiscord | <polylokh_39446> you can make it explicitly generic if that's what it is, or if you want to defer that question until later |
01:19:51 | FromDiscord | <Elegantbeef> I force all entries to store a `node` |
01:20:33 | FromDiscord | <fenilli> yours seen well more complete from what I'm thinking of doing for this simple game lol but i will take a look learn something from it. |
01:20:44 | FromDiscord | <fenilli> In reply to @polylokh_39446 "you can make it": meaning? passing something like <T>? |
01:21:30 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=NEWMGKsr |
01:21:31 | * | def- quit (Quit: -) |
01:21:41 | FromDiscord | <Elegantbeef> Hey I just avoid references like the plague |
01:21:55 | FromDiscord | <Elegantbeef> Dear reader I do not think I've even gotten covid once |
01:22:18 | FromDiscord | <fenilli> makes sense, just using ref there because it might be better for passing and modifies data from it. |
01:22:27 | FromDiscord | <fenilli> oh I see |
01:23:13 | FromDiscord | <fenilli> ok don't forget `ne, nw, se, sw: QuadTree[T]` at least the error without it this time is good. |
01:23:14 | FromDiscord | <Elegantbeef> Yea using references is less tedious since you do not need to pass the root tree around everywhere |
01:23:42 | FromDiscord | <Elegantbeef> I would suggest stealing my usage of `children: array[QuadPos, QuadTree[T]]` |
01:24:02 | FromDiscord | <Elegantbeef> This gives you a super power that you can iterate the children without having to manually do 4 branches |
01:24:20 | FromDiscord | <fenilli> I guess my problem is thinking of seq as array in JS |
01:24:31 | FromDiscord | <fenilli> now I stopped and could see my problem |
01:24:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=CNywVYIb |
01:24:41 | FromDiscord | <fenilli> they can't be of multiple types at the same time. |
01:24:42 | FromDiscord | <Elegantbeef> Look at that code 😄 |
01:25:17 | FromDiscord | <Elegantbeef> Yea you need some form of runtime type information and a pointer for arbitrary typed collections |
01:26:05 | FromDiscord | <fenilli> makes total sense, so a generic wouldn't work either for me, still need to create a single Entity type. |
01:26:26 | FromDiscord | <Elegantbeef> Yep you need the ugly `type Entity = ref object of RootObj` or an object variant |
01:26:42 | FromDiscord | <fenilli> didn't want to use inheritance still thinking a way to avoid it. |
01:26:42 | FromDiscord | <Elegantbeef> The latter is more preferable for performance nerds like myself |
01:29:50 | FromDiscord | <fenilli> object variant wouldn't work as entities will be separate from the same file, so can't really do a cyclic import there. |
01:30:10 | FromDiscord | <fenilli> so not like you can make Entity know about what will implement it. |
01:30:16 | FromDiscord | <fenilli> (edit) "what" => "who" |
01:30:23 | FromDiscord | <Elegantbeef> You can if you use pointer procs 😄 |
01:30:35 | FromDiscord | <fenilli> yeh no ptr lol |
01:30:40 | FromDiscord | <fenilli> I will probably do a simpler solution |
01:31:00 | FromDiscord | <Elegantbeef> I mean pointer procs are not really unsafe |
01:31:06 | FromDiscord | <fenilli> by making EntityManager or something like and just add entities there with a tuple of similar functionality |
01:31:26 | FromDiscord | <fenilli> I already do this for scenes, so not that different. |
01:32:08 | FromDiscord | <Elegantbeef> This sounds like interfaces 😄 |
01:32:19 | FromDiscord | <fenilli> kinda of lol |
01:32:35 | FromDiscord | <Elegantbeef> Shameless spam of traitor here |
01:33:44 | FromDiscord | <fenilli> well not like we could do something like `entities: seq[object with id]` or something like that. |
01:35:09 | FromDiscord | <Elegantbeef> You can but only statically |
01:35:15 | FromDiscord | <Elegantbeef> But with traitor you can 🙂 |
01:35:24 | FromDiscord | <Elegantbeef> though it'd be `object with setId and getId` |
01:37:43 | FromDiscord | <fenilli> sent a code paste, see https://play.nim-lang.org/#pasty=LyfXfqJo |
01:38:23 | FromDiscord | <fenilli> as if I had a Entity type with id and a tuple of similar functionality it wouldn't be possible to make an Entity with different vars on it. |
01:38:40 | FromDiscord | <Elegantbeef> Your choice is to use object variants, inheritance, or interfaces |
01:40:08 | * | pmp-p quit (Ping timeout: 260 seconds) |
01:41:10 | * | def- joined #nim |
01:43:53 | FromDiscord | <fenilli> sent a code paste, see https://play.nim-lang.org/#pasty=GhlgaNEN |
01:44:13 | FromDiscord | <Elegantbeef> That's not the write syntax |
01:44:23 | FromDiscord | <Elegantbeef> it'd be `of Bullet: bullet: BullentEntity` |
01:45:02 | FromDiscord | <Elegantbeef> The issue will crop up when you want bullet to interact with `Entity` |
01:45:08 | FromDiscord | <Elegantbeef> You can use delayed imports to get around this |
01:45:12 | FromDiscord | <fenilli> so it doesn't spread the parameters, but set a var with the creation? |
01:45:33 | FromDiscord | <Elegantbeef> Nim's object variants is not like Rust's (poorly named) Enums |
01:45:51 | FromDiscord | <Elegantbeef> Each branch of a Nim object has fields directly and does not require conversion between |
01:46:32 | FromDiscord | <fenilli> I see what does delayed import look like, didn't see in the docs. |
01:46:35 | FromDiscord | <Elegantbeef> You just do `Entity(kind: Bullet, bullet: BulletEntity(position: vec2(x, y))).bullet.position.x` |
01:46:56 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimtrest/wiki/Code-snippets#delayed-imports |
01:47:11 | FromDiscord | <Elegantbeef> You do not need `import` at the top of a file |
01:47:19 | FromDiscord | <fenilli> ohh |
01:47:22 | FromDiscord | <Elegantbeef> It can be anywhere and can be used to elevate order issues |
01:47:24 | FromDiscord | <fenilli> well that looks ugly tho. |
01:47:35 | FromDiscord | <Elegantbeef> Meh I disagree |
01:48:03 | * | def- quit (Quit: -) |
01:48:39 | FromDiscord | <fenilli> it does look useful to circunvent cyclic import tho it makes a file unsure what it imports and uses unless looking at the full code. |
01:48:40 | FromDiscord | <Elegantbeef> The single pass nature of Nim is very good for code readability since symbols are introduced inside `import` and code can be read top to bottom without "Where is this proc I've not seen it yet" |
01:48:49 | FromDiscord | <polylokh_39446> sent a code paste, see https://play.nim-lang.org/#pasty=ujJMBbJn |
01:49:21 | * | def- joined #nim |
01:49:27 | FromDiscord | <fenilli> does that assume all types are in a single file? |
01:49:39 | FromDiscord | <Elegantbeef> Yes |
01:49:40 | * | pmp-p joined #nim |
01:49:54 | FromDiscord | <Elegantbeef> You either do single file or delayed imports |
01:50:02 | FromDiscord | <polylokh_39446> the Entry types can be somewhere else, but they need to exist at the point of the Entity definition |
01:50:17 | FromDiscord | <polylokh_39446> (edit) "Entry" => "Entity" |
01:50:50 | FromDiscord | <Elegantbeef> Though that assumes there are no implementations of procedures that interact |
01:51:16 | FromDiscord | <fenilli> well tbf they shouldn't have it, that would be the job an ecs and all ( not that I have one at the moment ) |
01:51:33 | FromDiscord | <fenilli> but they have at the moment haha |
01:52:40 | FromDiscord | <fenilli> the advantage of an ecs here ( not gonna implement one ) would be that I could just pass an int to entities and get it at runtime after anyways. |
01:53:24 | FromDiscord | <fenilli> well I guess I could do a really fun thing and have a `entity_types.nim` file with the forward declaration of all types and any procs in its respective files |
01:53:30 | FromDiscord | <fenilli> that should work for all the problems in this case. |
01:53:38 | FromDiscord | <Elegantbeef> Just go use polymorph or necsus 😛 |
01:54:09 | FromDiscord | <fenilli> maybe later, my next objective for the next game is doing a simple ECS from scratch |
01:54:10 | FromDiscord | <Elegantbeef> We've reached the `types.nim` portion of this project |
01:54:32 | FromDiscord | <fenilli> this one is doing the quadtree lol |
01:54:57 | FromDiscord | <fenilli> instead of the amazing ultra good algorithim called double for |
01:55:15 | FromDiscord | <Elegantbeef> Hey double for is awful performance but simple code 😄 |
01:55:32 | FromDiscord | <Elegantbeef> I do also have a semi simple ECS that only uses 1 macro |
01:55:39 | FromDiscord | <fenilli> exactly ahha I was going to do that it would work, the game I'm making won't have more than 100 entities on screen at a time anyways. |
01:56:13 | FromDiscord | <fenilli> literally capped at 64+30+1 so 95 lol |
01:56:32 | FromDiscord | <Elegantbeef> Going to make a quad tree for 100 entities |
01:56:38 | FromDiscord | <Elegantbeef> Goin to make an ecs for 100 entities |
01:56:39 | FromDiscord | <fenilli> yep lol |
01:56:57 | FromDiscord | <Elegantbeef> Being scared of a single file for entities when you have 100 entities! |
01:57:00 | FromDiscord | <Elegantbeef> Developers are fickle |
01:57:00 | FromDiscord | <fenilli> that is called overengineering |
01:57:20 | FromDiscord | <fenilli> not scared |
01:57:29 | FromDiscord | <fenilli> i'm doing mostly for " what if I was making a game for real " |
01:57:34 | FromDiscord | <fenilli> learning process. |
01:57:45 | FromDiscord | <fenilli> I could literall make asteroids in a single file. |
01:57:50 | FromDiscord | <fenilli> (edit) "literall" => "literally" |
01:57:55 | FromDiscord | <polylokh_39446> lotta raylib examples that do that |
01:57:59 | FromDiscord | <fenilli> yeh |
01:58:19 | FromDiscord | <fenilli> its not a hard game and you can basically just go horse it all the way |
01:58:35 | * | def- quit (Quit: -) |
01:58:37 | FromDiscord | <fenilli> just want to use it as a learning experience in a smaller simpler game |
01:58:58 | * | def- joined #nim |
01:59:02 | FromDiscord | <fenilli> have in mind " new to nim, and new to game development " |
01:59:09 | FromDiscord | <fenilli> never used nim, and neither made a game in my life. |
01:59:36 | FromDiscord | <fenilli> made the first one two days ago a pong clone in nim, it uses a single file. |
02:01:19 | FromDiscord | <polylokh_39446> another way to give yourself a learning experience, is to implement the game as directly as possible - like in those raylib examples - and then start adding significant features, and see where it hurts / how painful it gets. |
02:01:47 | * | pmp-p quit (Ping timeout: 264 seconds) |
02:02:42 | FromDiscord | <planetis_m> Hey am I not understanding lvalues or is this a bug? https://play.nim-lang.org/#pasty=sZvMahPF |
02:02:56 | FromDiscord | <polylokh_39446> persistent bullets that damage you as well↵a large bounded map that you can navigate instead of the wrapping edges↵additional enemies that chase you and phase through obstacles↵a mouse-following cannon instead of shooting bullets where you're facing |
02:03:05 | FromDiscord | <Elegantbeef> You do not understand lvalues |
02:03:14 | FromDiscord | <Elegantbeef> L values are mutable in Nim best represented by `var T` |
02:04:56 | FromDiscord | <fenilli> for sure I could go like that, and it is kinda like that already, I had a working one, refactored to use scenes and a better file structure, now adding collision via quadtrees. |
02:05:27 | FromDiscord | <fenilli> but I guess your idea is more in line with adding features and not ideas. |
02:05:32 | FromDiscord | <polylokh_39446> where is that `{lvalue}` syntax documented? |
02:05:40 | FromDiscord | <fenilli> so If a feature needs something, add something, if not just don't. |
02:05:51 | FromDiscord | <planetis_m> In reply to @Elegantbeef "L values are mutable": oh f, how am I going to restrict to passing already declared variables and not hidden temporaries? |
02:05:56 | FromDiscord | <michaelb.eth> In reply to @polylokh_39446 "where is that `{lvalue}`": was wondering the same |
02:06:05 | FromDiscord | <planetis_m> In reply to @polylokh_39446 "where is that `{lvalue}`": https://nim-lang.github.io/Nim/manual_experimental.html#term-rewriting-macros-parameter-constraints |
02:06:26 | FromDiscord | <fenilli> oh are you THE planetis_m? i'm using your bindings, thank you for it. |
02:07:11 | FromDiscord | <planetis_m> In reply to @fenilli "oh are you THE": you're welcome I am glad you're able to make your project with them |
02:08:57 | FromDiscord | <Elegantbeef> `val: (var T){sym}`? |
02:09:36 | FromDiscord | <planetis_m> Yeah I went with sym |
02:10:03 | FromDiscord | <planetis_m> without the (var T) part |
02:10:51 | * | pmp-p joined #nim |
02:11:37 | FromDiscord | <Elegantbeef> Mismatch errors there are not that helpful so I'd be weary about it |
02:14:24 | FromDiscord | <planetis_m> sent a code paste, see https://play.nim-lang.org/#pasty=zsSrdMbX |
02:17:29 | FromDiscord | <Elegantbeef> Doesn't disabling `=copy` and `=dup` solve this? |
02:18:40 | FromDiscord | <planetis_m> They're already disabled for texture |
02:19:50 | FromDiscord | <Elegantbeef> So what does this solve? |
02:21:10 | FromDiscord | <planetis_m> sent a code paste, see https://play.nim-lang.org/#pasty=McRPWxaS |
02:22:01 | FromDiscord | <planetis_m> And also allow texture sharing |
02:22:48 | FromDiscord | <planetis_m> And no there're no reference counts, and the alternative would be to have a WeakTexture type that has =destory = discard |
02:23:42 | FromDiscord | <Elegantbeef> Can you not throw a `=wasMoved` in there? |
02:25:27 | FromDiscord | <planetis_m> In reply to @Elegantbeef "Can you not throw": I am not familiar with =wasMoved please elaborate |
02:25:39 | FromDiscord | <Elegantbeef> was moved resets the data to 0 |
02:25:58 | FromDiscord | <Elegantbeef> So in the above if you do `wasMoved(x.texture); x.texture = val` the old texture is not destroyed |
02:26:21 | FromDiscord | <planetis_m> I thought so, pbl I am going to try |
02:27:41 | FromDiscord | <planetis_m> No it doesn't work because =copy is not available |
02:28:18 | FromDiscord | <Elegantbeef> So copymem 😄 |
02:30:01 | FromDiscord | <planetis_m> Sure I think I used to, but copymem seems more unsafe, I let the compiler figure it out |
02:31:07 | FromDiscord | <Elegantbeef> Time to introduce a weaktexture then |
02:38:00 | FromDiscord | <planetis_m> I don't think WeakTexture would save us, it get's more complicated than that. The Model's destructor doesn't touch the resources assigned to the Material, but the Material has a UnloadMaterial that frees them. https://github.com/raysan5/raylib/blob/9d67f4734b59244b5b10d45ce7c8eed76323c3b5/examples/shaders/shaders_basic_pbr.c#L137-L151 freed at L267 Good luck mapping that to destructors |
03:38:34 | FromDiscord | <sOkam! 🫐> @ElegantBeef is there a way to do inverted cases for object variants?↵something like `case kind of not MyKind: somefield: T` |
03:41:00 | * | SchweinDeBurg joined #nim |
03:41:40 | FromDiscord | <Elegantbeef> `else` |
03:42:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=wyOAoFRj |
03:44:04 | FromDiscord | <sOkam! 🫐> i meant in order to exclude a field from the other kinds |
03:44:52 | FromDiscord | <Elegantbeef> Nope |
03:45:09 | FromDiscord | <sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#pasty=CnJChFbF |
03:45:18 | FromDiscord | <sOkam! 🫐> kk ty ✍️ |
03:55:28 | * | def- quit (Quit: -) |
04:30:03 | * | def- joined #nim |
04:42:59 | * | def- quit (Quit: -) |
05:02:12 | * | def- joined #nim |
05:08:37 | * | coldfeet joined #nim |
05:19:45 | * | coldfeet quit (Remote host closed the connection) |
06:40:52 | * | rockcavera quit (Remote host closed the connection) |
06:48:18 | * | def- quit (Quit: -) |
06:48:46 | * | def- joined #nim |
07:05:10 | * | khazakar_ joined #nim |
07:06:16 | * | khazakar_ quit (Client Quit) |
07:06:34 | * | khazakar_ joined #nim |
07:06:43 | * | khazakar_ quit (Client Quit) |
07:09:37 | * | def- quit (Quit: -) |
07:10:53 | * | def- joined #nim |
07:58:12 | * | fallback quit (Read error: Connection reset by peer) |
08:03:32 | * | fallback joined #nim |
08:04:56 | FromDiscord | <that_dude.> sent a code paste, see https://play.nim-lang.org/#pasty=wkmLOttg |
08:05:07 | FromDiscord | <that_dude.> I'm still using malebolgia for my multithreading btw |
08:12:06 | FromDiscord | <that_dude.> sent a code paste, see https://play.nim-lang.org/#pasty=GNLntQjk |
08:15:06 | FromDiscord | <that_dude.> Wrapping the part in a `{.cast(gcsafe).}` doesn't change anything |
08:20:47 | * | khazakar joined #nim |
08:29:11 | FromDiscord | <that_dude.> Is there something wrong with trying to spawn a thread to a proc in an object? |
08:41:24 | * | PMunch joined #nim |
08:54:42 | * | def- quit (Quit: -) |
08:55:06 | * | def- joined #nim |
09:51:16 | * | def- quit (Quit: -) |
09:51:29 | * | def- joined #nim |
10:01:26 | * | def- quit (Quit: -) |
10:10:55 | Amun-Ra | https://github.com/nim-lang/Nim/blob/devel/lib/std/tasks.nim#L113-L126 |
10:12:03 | Amun-Ra | wrap the body of the function with the cast |
10:17:23 | Amun-Ra | that line is for some reason |
10:20:19 | * | def- joined #nim |
11:12:33 | * | krux02 joined #nim |
11:28:14 | * | def- quit (Quit: -) |
11:45:52 | * | def- joined #nim |
13:00:26 | * | PMunch quit (Quit: Leaving) |
13:12:39 | * | Guest18 joined #nim |
14:08:08 | * | def- quit (Quit: -) |
14:11:44 | * | def- joined #nim |
14:22:16 | * | Guest18 quit (Quit: Client closed) |
14:22:23 | * | def- quit (Quit: -) |
14:22:47 | * | def- joined #nim |
14:52:04 | * | ntat joined #nim |
15:46:44 | * | def- quit (Quit: -) |
15:47:06 | * | def- joined #nim |
16:54:41 | * | rockcavera joined #nim |
17:00:21 | * | SchweinDeBurg quit (Quit: WeeChat 4.3.0-dev) |
17:29:07 | * | beholders_eye joined #nim |
17:39:53 | FromDiscord | <maxtachine> sent a code paste, see https://play.nim-lang.org/#pasty=PeKihelc |
17:40:45 | FromDiscord | <polylokh_39446> ptr cstring is wrong, it should be cstring for that one as well |
17:40:52 | FromDiscord | <maxtachine> oh ok |
17:41:52 | FromDiscord | <polylokh_39446> or, if that's the authority, then char is wrong, it should be `char decrypted` |
17:42:19 | FromDiscord | <maxtachine> decrypted is the output |
17:42:24 | FromDiscord | <maxtachine> (edit) "decrypted is the output ... " added "pointer" |
17:42:30 | FromDiscord | <polylokh_39446> it's the type that's the issue |
17:43:27 | FromDiscord | <polylokh_39446> a cstring is a pointer to NUL-terminated byte(s). a ptr cstring is a pointer to a pointer to NUL-terminated byte(s).↵char is a pointer to a byte. char is a pointer to a pointer to byte |
17:43:56 | FromDiscord | <maxtachine> ah |
17:44:53 | Amun-Ra | use cstring whether it's const char * or char * |
17:51:30 | FromDiscord | <supernova7107> is nim dead? |
17:51:42 | FromDiscord | <supernova7107> i cant see torch library matained anymore in nim |
17:51:46 | FromDiscord | <supernova7107> what it use then? |
17:52:21 | FromDiscord | <Phil> Not really, I have no clue of the torch library so I'm out there. |
17:52:52 | FromDiscord | <supernova7107> in ai everything is depend on torch |
17:52:59 | FromDiscord | <supernova7107> if u cant have that u are just dead language |
17:53:14 | ehmry | yes, but nothing depends on ai |
17:53:19 | FromDiscord | <vindaar> Flambeau is maintained https://github.com/SciNim/flambeau/. It's not complete though and users will probably need to help out a bit... |
17:53:23 | FromDiscord | <Phil> You may be amazed, but I do not care for ai |
17:53:29 | Amun-Ra | right |
17:54:04 | FromDiscord | <supernova7107> (edit) "dead language" => "then no hope i mean" |
17:54:13 | FromDiscord | <supernova7107> In reply to @vindaar "Flambeau is maintained https://github.com/SciNim/fl": will check thnx |
18:16:11 | * | beholders_eye quit (Ping timeout: 264 seconds) |
18:38:22 | FromDiscord | <Phil> Is there some kind of obvious gotcha with deepcopy that makes it leak? |
18:39:54 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=tvdCmLUv |
18:40:33 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=gGlnmIKK |
18:41:06 | FromDiscord | <Phil> the deepcopy happens on Thread A for a message I'm about to send to thread B |
18:41:26 | FromDiscord | <Phil> (edit) "the deepcopy happens on Thread A for a message I'm about to send to thread B ... " added "via threading channel" |
18:42:03 | FromDiscord | <Phil> If I just move those messages, I don't have memory leaks, but I do get data races, this is such a mindfuck |
18:52:03 | FromDiscord | <polylokh_39446> does `value` get destroyed by send after it's copied? |
18:52:50 | FromDiscord | <Phil> Yes |
18:53:19 | FromDiscord | <Phil> At least I get use-after-frees if I call `=destroy` on it again |
18:53:49 | FromDiscord | <Phil> Still in the business of trying to recreate my problem, I swear doing that is the hardest part of multithreading |
18:53:53 | FromDiscord | <Phil> I hate it so much |
18:55:11 | FromDiscord | <vindaar> which is why I use multiprocessing unless I absolutely need threads 🤭 |
18:59:43 | FromDiscord | <Robyn [She/Her]> In reply to @vindaar "which is why I": What's the difference between them? Multiprocessing is spawning an entirely new process, miltithreading is just threads? |
19:00:23 | FromDiscord | <Phil> Doesn't really help. |
19:01:09 | FromDiscord | <Phil> Socket communication most likely, which even more likely means deep copies, also stricter separation |
19:01:48 | FromDiscord | <vindaar> yeah, multiprocessing spawns new processes. Can be done either by hand of course, or just using `fork()`. Has some disadvantages (sharing data directly between threads to mutate for example doesn't work of course) and you duplicate the memory space of the parent process. But for a large number of parallel problems (in particular when they're rather dumb), multiprocessing is great. You don't need to worry about GC safety errors or race con |
19:03:02 | FromDiscord | <vindaar> `cligen` has `procpool` which is a low level version of python's multiprocessing module if you will\: https://github.com/c-blake/cligen/blob/master/cligen/procpool.nim |
19:04:11 | FromDiscord | <vindaar> but if it sounds interesting, I just finished (literally pushed \~1 hour ago) some syntax sugar around it for the common use case https://github.com/Vindaar/forked 😅 |
19:04:50 | FromDiscord | <griffith1deadly> In reply to @isofruit "Socket communication most likely,": is pipes better for multiprocessing than sockets? |
19:05:11 | FromDiscord | <Phil> You're asking the person that chose multithreading instead of multiprocessing what is better for multiprocessing |
19:05:37 | FromDiscord | <Phil> I have a vague idea at best |
19:06:12 | FromDiscord | <Phil> I'm too busy getting pissed at these absolute garbage stacktraces from asan that are about as helpful as stepping on a Lego |
19:07:25 | FromDiscord | <Robyn [She/Her]> In reply to @vindaar "yeah, multiprocessing spawns new": Fair, sounds neat for sure |
19:08:14 | FromDiscord | <leorize> FFI traces?↵(@Phil) |
19:08:31 | FromDiscord | <Phil> In reply to @leorize "FFI traces? (<@180601887916163073>)": No, they just tell me somehow deepcopy manages to leak and I'm struggling to write a minimal example |
19:08:41 | FromDiscord | <Phil> Though I think I had a breakthrough around 30s ago with that |
19:08:56 | FromDiscord | <leorize> if you have a trace and a sample I could figure something out |
19:10:53 | FromDiscord | <Phil> sent a long message, see https://pasty.ee/tfRvKuqm |
19:11:12 | FromDiscord | <Phil> https://media.discordapp.net/attachments/371759389889003532/1242555312016199811/message.txt?ex=664e434f&is=664cf1cf&hm=f262a7125538e9abfd66103df29beb388e091de67ee57c8d904d5c3dee58c266& |
19:11:17 | FromDiscord | <ieltan> lol |
19:11:38 | FromDiscord | <Phil> (edit) "https://pasty.ee/RrFGREQL" => "https://pasty.ee/almWLruX" |
19:12:17 | FromDiscord | <Phil> And yes that is so far the smallest example I managed, anything else just refused to replicate the behavior |
19:12:17 | FromDiscord | <demotomohiro> I think mutipleprocessing is good when cost of sharing or exchanging data is small. And it can easily scale to mutiple computers if you use sockets for communication. |
19:13:13 | FromDiscord | <Phil> I'm feeling tempted to jump to multiprocessing with my actor idea, solely because I already want to deepcopy the messages which increases transport-cost, though maybe not as much as using sockets etc. |
19:13:19 | FromDiscord | <griffith1deadly> In reply to @demotomohiro "I think mutipleprocessing is": but isnt scaling on local machine with pipes better? |
19:13:54 | FromDiscord | <leorize> you don't even have to use pipes with multiprocessing |
19:14:03 | FromDiscord | <leorize> a degree of shared memory can be used via shm |
19:14:08 | FromDiscord | <griffith1deadly> (edit) "better?" => "better than sockets?" |
19:14:51 | FromDiscord | <Robyn [She/Her]> In reply to @isofruit "Okay, I think I": I need to be installed? o.o |
19:15:08 | FromDiscord | <demotomohiro> In reply to @griffith1deadly "but isnt scaling on": I don't know if pipes better than sockets. |
19:15:19 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "a degree of shared": What's shm? |
19:15:34 | FromDiscord | <Phil> I'll try to simplify that clusterfuck of an example tomorrow, I think I'm slightly to annoyed today to do so.↵If you can already work with that leorize, I'd be glad, if not then I can understand, it's 90 loc just for a "minimal example" |
19:16:04 | FromDiscord | <Phil> (edit) "I'll try to simplify that clusterfuck of an example tomorrow, I think I'm slightly to annoyed today to do so.↵If you can already work with that leorize, I'd be glad, if not then I can understand, it's 90 loc just for a "minimal example" ... " added "afterall" |
19:16:29 | FromDiscord | <leorize> shared memory↵(@Robyn [She/Her]) |
19:16:37 | FromDiscord | <Phil> I swear async and multithreading is so. much. pain |
19:16:43 | FromDiscord | <leorize> this is where mmap comes in |
19:16:51 | FromDiscord | <Robyn [She/Her]> In reply to @leorize "shared memory (<@524288464422830095>)": Aah okay |
19:16:52 | FromDiscord | <Phil> Or just multithreading with "server-like" qualities |
19:17:48 | FromDiscord | <leorize> did tsan yell at you for that sample? |
19:18:12 | FromDiscord | <Phil> It shouldn't, nothing is shared here, it's deepcopy all the way |
19:18:24 | FromDiscord | <Phil> But I didn't even get to tsan yet, I tend to go for asan first since its the lower-hanging fruit |
19:18:25 | FromDiscord | <Phil> Supposedly |
19:18:47 | FromDiscord | <leorize> my hunch is that deepCopy + unsafeIsolate created an unowned copy |
19:19:05 | FromDiscord | <Phil> If that is the case I will hurt somebody |
19:19:06 | FromDiscord | <Phil> physically or emotionally |
19:19:09 | FromDiscord | <leorize> basically deepCopy object is copied again while the original was not destroyed |
19:19:10 | FromDiscord | <leorize> stuff like that |
19:20:07 | FromDiscord | <Phil> Like seriously, how would anyone ever even comprehend this level of fucked? |
19:20:22 | FromDiscord | <Phil> You're honestly a lifeline for me here when it comes to these kinds of issues |
19:21:11 | FromDiscord | <leorize> you're trying MT in nim |
19:21:18 | FromDiscord | <leorize> you gotta expect the growing pains |
19:21:35 | FromDiscord | <leorize> or rather the fact that you're the only one currently trying to propel this stuff forward |
19:22:39 | FromDiscord | <Phil> I dunno if it's a blessing or a curse that when it comes to computation problems that I invested in that I'm about as stubborn as I am easily frustrated at bs |
19:25:35 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=NqvNGvnq |
19:25:49 | * | coldfeet joined #nim |
19:27:15 | FromDiscord | <leorize> have you tried atomicArc? |
19:27:56 | FromDiscord | <Phil> No because I don't want to force my users to use it and theoretically it shouldn't be necessary |
19:29:04 | FromDiscord | <Phil> Apparently atomicArc doesn't work with chronos either |
19:29:17 | FromDiscord | <leorize> what does that mean? |
19:29:51 | FromDiscord | <leorize> is that leak you sent the only one? |
19:29:53 | * | ntat quit (Quit: Leaving) |
19:32:48 | FromDiscord | <Phil> In reply to @leorize "is that leak you": Not quite, it's 2 leaks, I just sent only one because I thought you ran the example to see the full traces 😄 https://media.discordapp.net/attachments/371759389889003532/1242560743900184637/message.txt?ex=664e485f&is=664cf6df&hm=b3ad97a8f6e10567e87c18c2dbac7562959a582c68f7c0de123bdce655d09970& |
19:33:03 | FromDiscord | <leorize> it's gonna take a bit to install nim again |
19:47:46 | * | daniel413006 joined #nim |
19:55:38 | * | def- quit (Quit: -) |
19:56:22 | * | def- joined #nim |
19:56:53 | * | daniel413006 quit (Quit: Client closed) |
20:01:12 | NimEventer | New thread by mantielero: Ffmpeg6.nim bindings for FFmpeg v6.x, see https://forum.nim-lang.org/t/11627 |
20:01:31 | * | jmdaemon joined #nim |
20:02:12 | FromDiscord | <leorize> @Phil\: good news\: your problem is very simple |
20:02:28 | FromDiscord | <Phil> insert squinting emoji |
20:02:38 | FromDiscord | <leorize> your object never left the mailbox |
20:02:55 | FromDiscord | <Phil> ... what? |
20:03:07 | FromDiscord | <leorize> your mailbox has a capacity phil |
20:03:14 | FromDiscord | <leorize> store was non blocking |
20:03:33 | FromDiscord | <leorize> so the server shutdown before it ever got anything out |
20:04:58 | FromDiscord | <Phil> ... that's bad for me, that means my actual issue is still not represented by that example |
20:05:03 | FromDiscord | <Phil> Fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuck |
20:05:11 | FromDiscord | <leorize> (cue go's "your channel capacity should either be 1 or 0, anything else is a bug") |
20:05:37 | FromDiscord | <leorize> and "if you use 1, you better have a good reason" |
20:12:42 | FromDiscord | <leorize> I mean, do you have the same pattern in your actual problematic program? |
20:13:29 | FromDiscord | <Phil> I do no.... wait a second, let me see what happens when I increase sleep appropriately |
20:14:54 | FromDiscord | <leorize> for this sample at least, you can just empty the mailbox on shutdown to fix it |
20:16:22 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#pasty=oXZTZcyD |
20:17:30 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#pasty=nXStyWlm" => "https://play.nim-lang.org/#pasty=MChLeJbR" |
20:18:08 | FromDiscord | <Phil> And I already empty all the mailboxes I have before shutdown, that's what I have a `gracefulShutdown` proc for |
20:18:59 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#pasty=zdulZrIh |
20:20:01 | FromDiscord | <Phil> For some of the things I do I need a mutable server instance, but I don't want to send a mutable instance of ServerActor from Thread A to B |
20:20:34 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#pasty=aXeYWHSG |
20:21:08 | FromDiscord | <Phil> I'm not aware of it. Ah, it was the atomics. Server stores an atomic determining whether it should be running or not |
20:21:22 | FromDiscord | <Phil> And i need to regularly load it as well as manipulate it to false when I want to shut it down |
20:25:43 | FromDiscord | <leorize> still doesn't explain `var server = server` \:p |
20:25:57 | FromDiscord | <leorize> isn't your server a ref? |
20:31:06 | FromDiscord | <Phil> Just played around, turns out I can indeed remove that when I adjust a proc.↵Odd, doesn't fix the leak but at least less code |
20:32:25 | FromDiscord | <leorize> let me know if you minimized a new sample |
20:42:58 | * | Lord_Nightmare quit (Ping timeout: 246 seconds) |
21:08:58 | * | coldfeet quit (Remote host closed the connection) |
21:11:00 | * | jmdaemon quit (Ping timeout: 260 seconds) |
21:24:48 | * | jmdaemon joined #nim |
22:43:36 | * | Lord_Nightmare joined #nim |
22:52:40 | * | jmdaemon quit (Ping timeout: 268 seconds) |
22:56:42 | * | beholders_eye joined #nim |
23:15:10 | * | termer_ is now known as termer |