00:48:43 | * | beholders_eye quit (Ping timeout: 264 seconds) |
00:48:52 | * | GnuYawk67 quit (Quit: The Lounge - https://thelounge.chat) |
00:49:16 | * | GnuYawk67 joined #nim |
01:20:56 | * | alexdaguy joined #nim |
01:54:24 | * | alexdaguy quit (Quit: w) |
02:26:32 | FromDiscord | <arkanoid> Hello! I have a general question about Memory Management. What is a cycle and why it hides in json and closures, why ORC succeeds in solving the cycles but ARC cant stop you from generating one? |
02:29:42 | FromDiscord | <Elegantbeef> Cause no one wrote a debug utility to report when a cycle was detected |
02:30:05 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=lMQOPRMc |
02:30:44 | FromDiscord | <Elegantbeef> A cycle is just a self reference either directly or indirectly, which means you need a more elaborate de allocation method than RAII |
02:31:13 | FromDiscord | <albassort> In reply to @albassort "https://github.com/nim-lang/Nim/blob/8fe518ed47163e": beef can you confirm this is an error |
02:31:59 | FromDiscord | <Elegantbeef> As in what? |
02:32:28 | FromDiscord | <arkanoid> can a cycle be detected/prevented at compile time, or is it a run-time only experience? |
02:32:42 | FromDiscord | <Elegantbeef> It's only possible at runtime given how Nim types are |
02:32:55 | FromDiscord | <Elegantbeef> since a `ref` is not single ownership you can only assume whether a type is cyclical |
02:33:04 | FromDiscord | <albassort> in the event safe disconnect is present, it cnanot raise an exception. If it cannot write, to the socket, and cannot detect its disconnected because its deepcopied between threads, it can get stuck in the while loop, so it should break |
02:33:16 | FromDiscord | <Elegantbeef> Of course with ARC you can at least annotate `{.acyclic.}` on types where it's required |
02:34:36 | FromDiscord | <albassort> sent a long message, see https://pasty.ee/AMBJITjr |
02:35:10 | FromDiscord | <albassort> adding break stops it but doesn't really notify you of the error |
02:35:15 | FromDiscord | <albassort> (edit) "adding break stops it but doesn't really notify you of the error ... " added "or its disconnection" |
02:35:20 | FromDiscord | <Elegantbeef> Right you seem to be correct |
02:35:29 | FromDiscord | <albassort> the solution is to remove safe disconn but you have no way of knowing |
02:35:58 | FromDiscord | <Elegantbeef> With safe disconnect it'll dead lock in here if `isBlockingErr` is false |
02:36:36 | FromDiscord | <Elegantbeef> Quick someone say something witty like "Exceptions are flow control" |
02:37:08 | FromDiscord | <albassort> they are until they aren't, like all flow control concepts like... indentation |
02:37:54 | FromDiscord | <arkanoid> does it mean it only happens with GCed memory? Cycles cannot happen on stack because of forced copy semantics? |
02:38:13 | FromDiscord | <Elegantbeef> No cycles cannot happen on stack cause you cannot have a self referential type in safe nim |
02:38:34 | FromDiscord | <Elegantbeef> It only happens in closures and references as they're memory safe references |
02:38:53 | FromDiscord | <Elegantbeef> Also should note JsonNodes can be cyclical, but only if you explicitly make them such, which will explode on serialisation |
02:40:23 | FromDiscord | <arkanoid> I don't get then what is the meaning of the acyclic pragma. Is it just to make ORC skip the task for that type and save time, or can it also provide some more safety |
02:40:31 | FromDiscord | <Elegantbeef> It just means "I know this will never be cyclical" |
02:41:21 | FromDiscord | <Elegantbeef> It stops Orc and there are no safeties |
02:41:27 | FromDiscord | <Elegantbeef> Which is why it's used in JsonNode |
02:44:29 | FromDiscord | <arkanoid> I don't get your last line. Can't a JsonNode create a cycle? |
02:44:52 | FromDiscord | <Elegantbeef> Like I said you technically can, but it's a useless type |
02:45:08 | FromDiscord | <Elegantbeef> How do you serialise a cyclical json type? |
02:46:41 | FromDiscord | <arkanoid> maybe you never serialize and deserialize, but just create in memory and use it as internal data structure |
02:46:50 | FromDiscord | <Elegantbeef> Sure you could, or you could author your own data type 😄 |
02:47:04 | FromDiscord | <Elegantbeef> But yes if you use it as a dynamic type you will leak if you have it self reference |
02:47:22 | FromDiscord | <Elegantbeef> That's again using the API wrongly and just abusing it's existence |
02:47:28 | FromDiscord | <arkanoid> thanks for all the answers |
02:48:00 | FromDiscord | <arkanoid> also thanks for the stack strings package. I'm using it and it's making my threading code easier to use |
02:48:26 | FromDiscord | <Elegantbeef> I only contributed to it 😄 |
02:49:41 | FromDiscord | <arkanoid> best way to ensure my code is not using the heap? valgrind? instrumentation? panic in custom memory allocator? ask to the Delphi Oracle? |
02:50:05 | FromDiscord | <Elegantbeef> Replace `malloc` with a panic 😄 |
02:53:13 | FromDiscord | <arkanoid> wow, I nailed it then \:D |
02:53:30 | FromDiscord | <Elegantbeef> Well it's the easiest way |
02:54:20 | FromDiscord | <Elegantbeef> Write your own allocator that you `LD_PRELOAD`, probably can even abuse Nim stack traces to get some useful information |
02:55:40 | FromDiscord | <arkanoid> https://stackoverflow.com/questions/48949265/how-to-develop-on-the-stack-with-nim |
02:56:29 | FromDiscord | <Elegantbeef> Actually since Nim exposes `allocImpl` you might be able to just change the pointer |
02:57:06 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#pasty=KfTXrVwS |
02:57:08 | FromDiscord | <albassort> boom reproduction |
02:57:14 | FromDiscord | <Elegantbeef> Ah nvm that's a procedure not a pointer |
02:57:17 | FromDiscord | <arkanoid> interesting. It seems that also gc\:None causes warning, so it may be sufficient to turn warnings into errors |
02:57:31 | FromDiscord | <Elegantbeef> The issue with no GC is you don't get destructors or hooks |
02:57:37 | FromDiscord | <Elegantbeef> So you're neutering your feature set |
02:57:44 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#pasty=hyWvPVPO" => "https://play.nim-lang.org/#pasty=yJswBGId" |
02:57:44 | FromDiscord | <Elegantbeef> For something that truthfully isn't that important |
02:58:26 | FromDiscord | <Elegantbeef> Nice now make an issue or PR to fix it 😛 |
02:58:36 | FromDiscord | <albassort> uhhhhhhhhhh |
02:58:45 | FromDiscord | <albassort> the easiest way is a timeout |
02:58:53 | FromDiscord | <arkanoid> oh, I thought that hooks and destructors were unrelated to gc\:None, but it actually makes sense |
02:58:56 | FromDiscord | <albassort> like 100 tries to send then you break and raise an error anyway |
02:59:18 | FromDiscord | <albassort> or find a better way to detect if its closed, but that seems complicated |
03:00:53 | * | mronetwo quit (Server closed connection) |
03:01:01 | * | mronetwo joined #nim |
03:01:41 | * | rockcavera joined #nim |
03:02:51 | FromDiscord | <Elegantbeef> Stop it |
03:02:51 | FromDiscord | <arkanoid> haha sorry |
03:02:51 | FromDiscord | <Elegantbeef> Get some help |
03:02:53 | FromDiscord | <Elegantbeef> The heap is not scary, whoever told you it was was smoking the good stuff |
03:02:53 | FromDiscord | <arkanoid> It is scary if you use threads |
03:02:53 | FromDiscord | <Elegantbeef> So then don't share heap resources across threads |
03:02:54 | FromDiscord | <Elegantbeef> So much easier than avoiding the heap all together and only using stack |
03:02:56 | FromDiscord | <Elegantbeef> Only using the stack is a path towards silliness |
03:02:58 | FromDiscord | <arkanoid> (safe) nim forbids you to do so. BTW am already doing that\: forcing stack only for thread shared data. I was only curious how much data I can put on the stack |
03:03:00 | FromDiscord | <Elegantbeef> It does not forbid you to |
03:03:18 | FromDiscord | <Elegantbeef> `isolate(T)` 😛 |
03:03:30 | FromDiscord | <arkanoid> sure, it does. If you try to read GCed data from thread it doesn't compile |
03:03:45 | FromDiscord | <Elegantbeef> Emphasis on 'share' |
03:03:56 | FromDiscord | <Elegantbeef> Don't share resources = happy life |
03:06:26 | FromDiscord | <arkanoid> thread that does not share resources is the unsafe version of a process |
03:06:38 | FromDiscord | <Elegantbeef> How is that unsafe? |
03:07:00 | FromDiscord | <arkanoid> ask chrome developers and firefox developer |
03:07:09 | FromDiscord | <Elegantbeef> How can it be unsafe if there is no sharing |
03:07:34 | FromDiscord | <Elegantbeef> It's even safer as it requires no mutexs |
03:09:18 | FromDiscord | <Elegantbeef> You run the code to completion and wait for your threads to finish then get the values |
03:09:21 | FromDiscord | <Elegantbeef> Threadpools are not unsafe |
03:10:30 | FromDiscord | <arkanoid> because if anything goes out of control it your thread, it can peek into the heap (firefox issues) |
03:10:44 | FromDiscord | <arkanoid> because if anything goes out of control in your thread, it can peek into the heap (firefox issues) |
03:10:47 | FromDiscord | <Elegantbeef> That happens without threading |
03:11:16 | FromDiscord | <Elegantbeef> Buffer overflows are not the reserved for threading |
03:11:37 | FromDiscord | <arkanoid> with processed you are much safer in same condition |
03:11:44 | FromDiscord | <arkanoid> with processes you are much safer in same condition |
03:12:03 | FromDiscord | <Elegantbeef> Except processes have startup time and require multiple binaries |
03:12:12 | FromDiscord | <Elegantbeef> Unless you embed it all into a single binary then load it up |
03:13:06 | FromDiscord | <Elegantbeef> You should avoid sharing between threads anyway, just cause you can does not mean you should multiple your scope of mutable state |
03:15:53 | FromDiscord | <arkanoid> if all you need is performance, yes that's the defensive strategy. Else, it's process isolation intrinsic job |
03:16:40 | FromDiscord | <Elegantbeef> So we've got you down to spawning a process instead? 😄 |
03:17:58 | FromDiscord | <arkanoid> even better! My program is running threads that are spawning multiple processes! |
03:19:39 | * | adigitoleo quit (Ping timeout: 248 seconds) |
03:21:49 | * | adigitoleo joined #nim |
03:24:05 | FromDiscord | <arkanoid> I just realized that I'm asking about stackoverflow on stackoverflow. Interesting |
03:27:48 | FromDiscord | <arkanoid> it seems that the limit for the main thread stack size is 512KB on Mac, 1MB on Windows and 8MB on Linux. Non main threads have a lower stack limit that seems to depends on the api used on each platform |
04:05:39 | FromDiscord | <leelikesfries> this language is absolutely beautiful |
04:22:24 | FromDiscord | <albassort> In reply to @leelikesfries "this language is absolutely": Nim or English 😛 |
04:23:54 | FromDiscord | <albassort> you know fucking what |
04:24:08 | FromDiscord | <albassort> i bet that socket bug is the exact bug that i've been complaining about for like 4 years |
04:24:22 | FromDiscord | <albassort> with threaded httpclient instances |
04:26:23 | FromDiscord | <Elegantbeef> I don't know if sending Sockets across threads is a faux pas or not |
04:29:58 | FromDiscord | <albassort> well, i need to, its not in my context |
04:30:07 | FromDiscord | <albassort> now, if i should reconstruct the fd or not is up for debate |
04:30:13 | FromDiscord | <albassort> im not sure how i would keep it open with doing that |
04:32:57 | FromDiscord | <Elegantbeef> I imagine that'll be what's suggested |
04:55:53 | * | robertmeta quit (Server closed connection) |
04:56:01 | * | robertmeta joined #nim |
05:27:03 | * | GnuYawk67 quit (Quit: The Lounge - https://thelounge.chat) |
05:27:21 | * | GnuYawk67 joined #nim |
05:45:53 | * | ursa-major quit (Server closed connection) |
05:46:02 | * | ursa-major joined #nim |
06:16:53 | * | bgupta quit (Server closed connection) |
06:17:02 | * | bgupta joined #nim |
06:39:56 | * | coldfeet joined #nim |
08:55:49 | * | ntat joined #nim |
09:19:17 | FromDiscord | <michael.lenz.> sent a code paste, see https://play.nim-lang.org/#pasty=HVCUzTWu |
09:23:39 | FromDiscord | <michael.lenz.> There’s better implementation with use of channels by Elcritch. So it’s not works because of gc, and ref type of the socket |
09:30:34 | * | ntat quit (Quit: Leaving) |
09:41:47 | FromDiscord | <michael.lenz.> Here are code examples https://github.com/nim-lang/Nim/issues/24591 |
10:55:43 | FromDiscord | <albassort> In reply to @michael.lenz. "I had the same": doubt this is the same issue |
10:56:22 | FromDiscord | <albassort> https://github.com/nim-lang/Nim/issues/24648 |
11:15:26 | FromDiscord | <michael.lenz.> In reply to @albassort "doubt this is the": It should be. As I understood you have issue with passing the socket to te thread using channels |
11:16:19 | FromDiscord | <albassort> pretty sure the issue is the deepcopy of the socket |
11:16:30 | FromDiscord | <albassort> if the issue is the same, my suggeted fixes should work on your code |
11:16:32 | FromDiscord | <albassort> go ahead and see |
11:19:44 | FromDiscord | <michael.lenz.> Sure, I will check it out when I get back |
11:22:21 | FromDiscord | <michael.lenz.> I see now what’s the difference, ok |
11:23:32 | * | beholders_eye joined #nim |
11:25:29 | FromDiscord | <michael.lenz.> And what if you store client socket as in separate array element and try to pass via channels to te thread? |
11:38:23 | * | oisota quit (Server closed connection) |
11:38:40 | * | oisota joined #nim |
11:39:00 | * | beholders_eye quit (Read error: Connection reset by peer) |
11:45:59 | FromDiscord | <michael.lenz.> The deepcopy should not cause this. More like it’s because thread opeates with the client socket in parallel, and accept modifies it at the same time on next connect event. I will check the code when I go back home |
11:46:23 | * | alexdaguy joined #nim |
11:47:16 | * | beholders_eye joined #nim |
11:57:22 | * | beholders_eye quit (Quit: WeeChat 4.1.2) |
11:57:38 | FromDiscord | <albassort> In reply to @michael.lenz. "The deepcopy should not": its def not this |
12:00:25 | * | beholders_eye joined #nim |
13:05:23 | * | xet7 quit (Server closed connection) |
13:05:47 | * | xet7 joined #nim |
14:52:18 | * | alexdaguy quit (Quit: w) |
14:58:51 | FromDiscord | <michael.lenz.> In reply to @albassort "its def not this": Plese check the comment, the issues is with accept(), because the call is blocking |
15:24:20 | FromDiscord | <leelikesfries> sent a code paste, see https://play.nim-lang.org/#pasty=uufPBTtB |
15:28:14 | FromDiscord | <odexine> https://nim-lang.org/docs/tables.html#getOrDefault%2CTable%5BA%2CB%5D%2CA%2CB |
15:59:31 | * | ntat joined #nim |
16:25:03 | FromDiscord | <firasuke> So how do you compute sha256 of a file using constantine? https://github.com/mratsim/constantine |
16:27:22 | rockcavera | firasuke see https://github.com/mratsim/constantine/blob/master/tests/t_mac_hmac_sha256.nim |
16:27:23 | FromDiscord | <firasuke> I tried using one of the libraries here: https://github.com/mratsim/constantine/tree/master/constantine/hashes/sha256 |
16:27:27 | FromDiscord | <firasuke> but was unsuccessful |
16:27:52 | FromDiscord | <firasuke> In reply to @rockcavera "firasuke see https://github.com/mratsim/constantine": ok |
16:28:21 | rockcavera | or https://github.com/mratsim/constantine/blob/master/tests/t_hash_sha256_vs_openssl.nim |
16:31:09 | FromDiscord | <firasuke> In reply to @rockcavera "or https://github.com/mratsim/constantine/blob/mast": already checked that |
16:35:08 | FromDiscord | <firasuke> still thanks |
16:41:26 | rockcavera | firasuke https://play.nim-lang.org/#pasty=MqRbiDWX |
16:49:44 | FromDiscord | <firasuke> In reply to @rockcavera "firasuke https://play.nim-lang.org/#pasty=MqRbiDWX": cool, thanks |
16:52:02 | rockcavera | firasuke https://play.nim-lang.org/#pasty=HRtOHYnk if you are going to read the file little by little, you need to do it this way with `update()` |
17:33:12 | FromDiscord | <leelikesfries> In reply to @odexine "https://nim-lang.org/docs/tables.html#getOrDefault%": i really love nim. |
18:15:15 | FromDiscord | <firasuke> In reply to @rockcavera "firasuke https://play.nim-lang.org/#pasty=HRtOHYnk ": sure |
19:24:55 | * | SchweinDeBurg quit (Read error: Connection reset by peer) |
19:30:21 | * | SchweinDeBurg joined #nim |
20:25:46 | FromDiscord | <System64 ~ Flandre Scarlet> Hi, is there a library to manipulate WAV files please?↵especially to get the samples |
20:26:52 | FromDiscord | <michael.lenz.> In reply to @sys64 "Hi, is there a": libsndfile |
21:43:54 | strogon14 | https://github.com/SpotlightKid/nim-sndfile |
21:46:51 | strogon14 | The original author gave me permission, to replace his version with mine at nimble.directory, but I haven't done a PR to update the entry yet. I wanted to add more tests first, but I should probably just release the damn thing. |
22:33:03 | * | ntat quit (Quit: Leaving) |
22:48:44 | * | marcus quit (Remote host closed the connection) |
22:50:34 | * | marcus joined #nim |
22:50:37 | * | coldfeet quit (Quit: Lost terminal) |
22:53:59 | * | marcus quit (Remote host closed the connection) |
22:55:45 | * | marcus joined #nim |