betaveros / noulith

*slaps roof of [programming language]* this bad boy can fit so much [syntax sugar] into it
1.13k stars 20 forks source link

parallel (`par_each` + `par_map`) #24

Closed crides closed 8 months ago

crides commented 8 months ago

Just replaced Rc with Arc, RefCell with RwLock, and slapped Send + Sync on the traits, and used rayon for the job

Probably not a great idea as I have no idea how much synchronization is actually needed, but it does make things run faster so :shrug:

betaveros commented 8 months ago

It's a cool idea but when I casually benchmarked it, a small single-threaded loop got ~30% slower :-/

s, t := 0, time();
for (a <- 0 til 20000000) (s += a);
print(s, time() - t)
crides commented 8 months ago

huh, I haven't even benchmarked actually :joy:. It's not too surprising that the performance is worse, due to all of the locks/atomics. I don't have better ideas at the moment though. Maybe I'll only use the commit (locally) when I need parallelism...