Re: Connection-Pooling Compile-Time ORM

2020-06-30 Thread ZadaZorg
I envy your productivity and inventiveness.

Re: getFileSize async and sync

2020-06-30 Thread mashingan
It's different because `AsyncFile` keeps its `fd` field private. The Windows one is using the version from `winlean` which actually wrapper for `GetFileSize` from win32. Also, windows has peculiarity of different handling whether the file handle is synchronous and asynchronous one. That's why

Re: getFileSize async and sync

2020-06-30 Thread snej
I've never used async file I/O APIs, but my understanding is that they just cover reading/writing the file itself. The size is metadata that comes from the filesystem's catalog / inodes / whatever, not the file itself, and is very cheap to get. I suppose you _could_ get the file size

Re: threads:on + gc:orc = C(!) compiler errors in unit tests

2020-06-30 Thread Yardanico
The second one isn't strange, it's a hint which can improve performance if you follow it sometimes :) but it can come from the library code too

Re: threads:on + gc:orc = C(!) compiler errors in unit tests

2020-06-30 Thread ZadaZorg
Running your example gives me nice working results: [OK] foo Run But I also have strange suggestion like you: Hint: passing 'n[i].key' to a sink parameter introduces an implicit copy; if possible, rearrange your program's control flow to prevent it

Re: threads:on + gc:orc = C(!) compiler errors in unit tests

2020-06-30 Thread snej
Turns out it's pretty trivial to reproduce. I've filed [https://github.com/nim-lang/Nim/issues/14865](https://github.com/nim-lang/Nim/issues/14865) . $ cat test.nim import unittest test "foo": check 3 + 4 == 7 $ nim c -r --threads:on --gc:orc test.nim Hint:

Re: threads:on + gc:orc = C(!) compiler errors in unit tests

2020-06-30 Thread Yardanico
Well, it would be nice if you try on the latest devel compiler :) And if it still doesn't work - try to minimize it and report, like e.g. I did in some cases -

threads:on + gc:orc = C(!) compiler errors in unit tests

2020-06-30 Thread snej
OK, here's a weird bug. Once I enable both `--threads:on` and `--gc:orc`, all of my unit tests (which uses the `unittest` module) fail to compile, with gnarly looking C errors: /Users/snej/.cache/nim/testCodec_d/@mtestCodec.nim.c:1144:112: error: incomplete definition of type

Re: getFileSize async and sync

2020-06-30 Thread snej
Not everyone uses async/await, and it's more common to use it for networking than for files (in my experience.) The async file I/O is for code that does use async and is worried enough about disk latency to want to avoid blocking on disk I/O. That's more extreme than I've ever gone, but I've

Re: getFileSize async and sync

2020-06-30 Thread ZadaZorg
OK, but in "async" version, there is nothing async at all (as I can understand). So that asyncfile can use proc from io module for example.

Re: Multithreaded await

2020-06-30 Thread snej
...OK, I have [some code that appears to work](https://gist.github.com/snej/653856212361be805751e4208a87d131), at least in Nim 1.2.2 with gc:orc. It lets you * Wrap a Future in another Future that can be passed to and completed on another thread, and will then invoke the original Future on

getFileSize async and sync

2020-06-30 Thread ZadaZorg
Hi, working with async stuff decided to look at what async way of getting file size and compare it to sync way. Got no difference in principle, but there is 2 different implementations: The "sync" version in io.nim: proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect],

Re: Multithreaded await

2020-06-30 Thread snej
Yeah, I still have [your example](https://gist.github.com/treeform/3e8c3be53b2999d709dadc2bc2b4e097) open in a browser tab, and I think I may need to start borrowing from it, since it doesn't look like I can use Nim's thread pools with ORC (see above).

Re: Multithreaded await

2020-06-30 Thread snej
Thanks for the example! I'm doing it slightly differently but using your basic technique. Next roadblock is that `FlowVar` doesn't seem compatible with ORC (which I need so I can pass object graphs across threads): `nim-1.2.2/lib/pure/concurrency/threadpool.nim(214, 6) Error: cannot bind

Re: Multithreaded await

2020-06-30 Thread treeform
In my system I do all async/await and asyncdispatch on a single thread. Then I have a work Q to do other the actual work. Was very simple to put together.

Re: New blog post: Ray tracing in Nim

2020-06-30 Thread treeform
Very nice blog post!

Re: Multithreaded await

2020-06-30 Thread rayman22201
Right now, the most straight forward way to achieve this is by manually creating an asyncEvent that you can pass to the other thread. That secondary thread can then use the asyncEvent to trigger a wakeup on the event loop. @see here for an example:

Re: Multithreaded await

2020-06-30 Thread mratsim
> I'm not considering Weave, for now, because it looks like it's oriented > toward finer-grained parallelism and is probably more complex than I need. Weave is indeed focused on CPU-bound workloads and not IO workloads, i.e. it optimize for throughput and not latency.

Multithreaded await

2020-06-30 Thread snej
OK, I've got a WebSocket-based client running on a single thread with async/await and asyncdispatch. Now I want this to interact with other threads — for example, I'd like another thread to be able to post a message for the WebSocket to send. The sticking point is how to wake up the async

Re: Benefit of the effect system?

2020-06-30 Thread Yardanico
{.pragma: raisesssz, raises: [Defect, MalformedSszError, SszSizeMismatchError].} Run Makes a new pragma called `raisesssz`, which, when used, will imply `raises: [Defect, MalformedSszError, SszSizeMismatchError]`

Re: Benefit of the effect system?

2020-06-30 Thread snej
What does the `{.raises:[...].}` pragma at the top of a source file do, as in your ssz_serialization.nim? The manual only describes it as a proc annotation.

Re: New blog post: Ray tracing in Nim

2020-06-30 Thread snej
Nice article! I like the explanation of Nim's benefits. I forwarded it to my team.

Re: Tables and Import

2020-06-30 Thread snej
Module names seem to be lowercase by convention, and types uppercase.

Re: What's the future of "implicitDeref"?

2020-06-30 Thread Araq
Good point so probably we should require `ptr T not nil` for auto-deref...

Re: Tables and Import

2020-06-30 Thread tanguymario
Ok, I also tried replacing this line: var imgTable: Table[string, Image] Run by this one: var imgTable: Table[string, Image.Image] Run And it still gives the same error. Anyway I will change the module names

Re: Benefit of the effect system?

2020-06-30 Thread mratsim
We use it in our code to: * Enforce noSideEffect (i.e. no access to globals, including stdin/stdout). * Enforce handling of recoverable exceptions and make sure all kinds of exceptions that can be thrown in inner function calls are accounted for or handled or considered irrecoverable: *

Re: Tables and Import

2020-06-30 Thread SolitudeSF
no, you named a module same way as another symbol, and module takes precedence. nothing to do with tables.

Tables and Import

2020-06-30 Thread tanguymario
Hello, I am doing a simple test with tables and have problems using import. I have a file Image.nim: type Image* = ref object of RootObj filepath*: string Run And a main file: import tables import Image var imgTable:

Re: Tables and Import

2020-06-30 Thread SolitudeSF
i think Image is first recognized as module. rename it to lowercase.

Re: Tables and Import

2020-06-30 Thread tanguymario
Yes it works that way, thanks! But it is strange the type can be created but cannot be recognized in as the Table value type, isn't it ?

New blog post: Ray tracing in Nim

2020-06-30 Thread miran
Guest post by @mratsim: [https://nim-lang.org/blog/2020/06/30/ray-tracing-in-nim.html](https://nim-lang.org/blog/2020/06/30/ray-tracing-in-nim.html)