Re: Execution speed Nim vs. Python

2017-09-27 Thread cblake
(I should perhaps qualify beyond -d:release using gcc or clang with high 
optimization levels on the back end since jil210 revealed in [another 
thread](https://forum.nim-lang.org/t/3198) the baseline 5X performance mystery 
arose from using tcc as a back end.)

Also, for the curious, the reason C++ STL will usually underperform Nim's hash 
tables in benchmarks like this is that STL iterator deletion semantics make the 
natural STL hash table collision resolution implementation choice be external 
chaining. Those extra linked list indirections add latency, especially when 
tables do not fit in on-CPU cache.


Re: Execution speed Nim vs. Python

2017-09-27 Thread cblake
Nim `Table` and `HashSet` should be caching the hash code values in their 
tables and also using that as a "comparison prefix" (comparing string values 
only if the integer hash codes already match). The string hash of the new 
inputs is ineliminable - or rather has to be done at least once anyway.

My guess is the lines are long-ish (greater than 10 chars, say). The default 
Nim hash string function could be faster, especially for longer strings. E.g., 
the current default does byte-at-a-time manipulations and usually 
8-byte/word-at-a-time can get about as good bit mixing much faster, especially 
for long strings like lines in files. Such a replacement might take that 60% 
hashing time in this particular benchmark down to 10-15% for a 2X-ish overall 
speed up.

I have benchmarked C++ for these kinds of tests and I suspect the current STL 
would not be faster than Nim with the -d:release in this case. (C++, too could 
benefit from faster default string hash).


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread def
kcachegrind:


nim -d:release --debugger:native c mydiff
valgrind --tool=callgrind ./mydiff file1 file2
kcachegrind callgrind.out.*


Also used here for example: 
[https://hookrace.net/blog/writing-an-async-logger-in-nim/#optimization](https://hookrace.net/blog/writing-an-async-logger-in-nim/#optimization)


Re: Problem with nim types i guess

2017-09-27 Thread _tecbeast
I solved it by putting j in the function. Why has the compile a problem when it 
is outside of the proc? 


import json, asynchttpserver, asyncdispatch

var server = newAsyncHttpServer()

proc cb(req: Request) {.async.} =
  var j = %* {
"test": 1,
"test2": "42",
  }
  await req.respond(Http200, j.pretty())

waitFor server.serve(Port(8080), cb)



Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread scriptkiddy
@def

What program is that?


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread scriptkiddy
Just to add to the conversation:

Each file is 1.7MB

**System specs**


OS: Ubuntu 16.04 xenial
Kernel: x86_64 Linux 4.4.0-83-generic
CPU: Intel Core i5-6600K @ 3.9GHz
RAM: 15980MiB


**Python 2.7**


$ time python test1.py test1.log test1-2.log

real0m0.042s
user0m0.040s
sys 0m0.000s


**Nim 0.17.2**


$ nim c -d:release test1.nim
$ time ./test1 test1.log test1-2.log

real0m0.056s
user0m0.044s
sys 0m0.008s


**Nim 0.17.2 (DEBUG)**


$ nim c -o:test1-dev test1.nim
$ time ./test1-dev test1.log test1-2.log

real0m0.273s
user0m0.264s
sys 0m0.008s


Times seem correct to me.

We have to remember that the majority of Python's file I/O stuff is implemented 
in C. The fact that Nim is ever so slightly slower than native compiled C is 
not surprising.

On my system, compiling with `-d:release` gives a 5x speed increase. This is 
also not surprising.


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread def
Of course gcc will optimize much better than tcc!

Also put your nim code in a proc for some more performance. Here's what parts 
are taking most of the time: 
[https://i.imgur.com/hLaOHVe.png](https://i.imgur.com/hLaOHVe.png)


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread jil210
Now I resolved this issue using gcc rather than tcc.

tcc version took 25 sec while gcc version 5 sec comparable to python version!

I thought tcc faster than gcc but nim using gcc makes faster on linux.


Re: Execution speed Nim vs. Python

2017-09-27 Thread Varriount
Python caches hashing of strings. Nim does not (it would be a challenge, as Nim 
strings are mutable). I suggest using string references or Hash objects if you 
want to compare performance.

Has anyone benchmarked C++ for this kind of test?


Problem with nim types i guess

2017-09-27 Thread _tecbeast
Hello I am new to nim. I have the following code and i don't understand what is 
wrong.

* * *


import json, asynchttpserver, asyncdispatch

var server = newAsyncHttpServer()

var j = %* {
"test": 1,
"test2": "42",
}

proc cb(req: Request) {.async.} =
await req.respond(Http200, json.pretty(j))

waitFor server.serve(Port(8080), cb)


**Error**:

main.nim(13, 15) Error: type mismatch: got (AsyncHttpServer, Port, proc (req: 
Request): Future[system.void]{.locks: .}) but expected one of:

proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void]; address = ""): Future[void]


Nimx installation issue

2017-09-27 Thread andrewgohlk
Hi,

I tried to install nimx in Windows 10 with the following:

E:Nim-0.17.2>nimble install nimx

Downloading 
[https://github.com/yglukhov/nimx](https://github.com/yglukhov/nimx) using git
Tip: 1 messages have been suppressed, use --verbose to show them.
Error: 'git' not in PATH.

However, it failed.

Pls advice how to solve this. 


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread jil210
thanks for testing. I was doing it with 148Mb files and I will try to revise as 
you suggested and recompile with -d:release. sure I did it before, though. Yes, 
i like nim but this performance issue should be resolved somehow.


Re: perfomance of set/hashset operation between python and nim

2017-09-27 Thread Jipok
I tested for 7.7 mb files: 


python2 ...  0,54s user 0,23s system 54% cpu 1,417 total
nim release ...  0,56s user 0,18s system 54% cpu 1,337 total
nim debug   ...  3,96s user 0,30s system 99% cpu 4,262 total


Perhaps a stupid question, but you compile with --d:release?

By the way you can replace it: 


let file1 = open(paramStr(1))
let file2 = open(paramStr(2))

let old_lines = file1.readAll().splitLines()
let new_lines = file2.readAll().splitLines()
file1.close()
file2.close()


on this: 


let old_lines = readFile(paramStr(1)).splitLines()
let new_lines = readFile(paramStr(2)).splitLines()



online task management software

2017-09-27 Thread JessicaMorgan
Jessica is a digital marketing specialist at TaskQue, a revolutionary online 
task management software which is very easy to use. Its main feature is the 
queue which is extremely helpful for managers and supervisors managing a team. 
Whenever a resource or team member is free, he will be automatically assigned a 
task so that the manager doesn't have to check for this so that his work won’t 
be interrupted at all. Its cloud nature is another brilliant concept that makes 
it the best tool in its category. Visit the page: 
[https://taskque.com](https://taskque.com)


Re: newb saying Hi

2017-09-27 Thread andre1sk
Thanx for the pointer will check it out