Skip to content

Instantly share code, notes, and snippets.

@vrurg
vrurg / coerce-bench.raku
Created July 7, 2022 02:05
Benchmarking for Raku coercion protocol
View coerce-bench.raku
class CNewMulti {
has $.val;
multi method new(Int:D $val) {
samewith :$val;
}
}
class CNewSingle {
has $.val;
method new(Int:D $val) {
View timing-test.raku
use Test;
my $v = 0;
my $st = now;
for ^100000 {
$v++;
}
my $et = now;
diag "Test time: " ~ ($et - $st);
View Bar.rakumod
unit class Bar;
use Foo;
also does Foo;
@vrurg
vrurg / rakudo-segv
Created February 1, 2022 16:18
Rakudo SEGV
View rakudo-segv
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f9a85de6249 in exists_key () from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
[Current thread is 1 (Thread 0x7f9a857db440 (LWP 3931316))]
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f9a857db440 (LWP 3931316) 0x00007f9a85de6249 in exists_key ()
from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
2 Thread 0x7f9a857d9700 (LWP 3931317) 0x00007f9a85e3a0a5 in add_usage_for_bb ()
from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
View nominalizable-test.raku
role R[::T] {
my subset RS of T where { note "VALIDATING ", $_, ", T:", T.^name; True };
method the-subset { RS }
method foo(RS $vrs) {
pass "got value " ~ $vrs.raku
}
}
View red-arch-doc-comments.md

My comments are in quotes like this one.

Red ORM

I think title must reflect the subject somehow. Perhaps, include the "architechture" word.

Red is a ORM for Raku that tries to mimic Raku's Seq's API but to query databases.

Since the document is aiming at potential contributors, this sentense is redundant. They already know its ORM, its about DBs. The only useful part of it is about Seq mimicing.

View Comma MoarVM debug report.md

Prerequsites

  • Project: https://github.com/vrurg/raku-Vikna/tree/for-comma-debug
  • Rakudo stack is built with ./Configure.pl --gen-moar --gen-nqp --backends=moar – nothing specific
  • Just in case, as the project needs chained dispatchers, there is a branch v-dispatcher for it in either the main rakudo repo or in my fork at https://github.com/vrurg/rakudo/tree/v-dispatchers
  • A breakpoint is set in lib/Vikna/EventHandling.rakumod. Basically any line within !run-ev-loop method is ok. Last time it was line 58.
  • The script I'm using for testing is t/desktop/010-screen-resize.t
  • The debugging can be configured with option start suspended set to any on or off, makes no difference. I usually start suspended, so my scenario is based on this.

What happens:

View gist:8357c16c419c293e0953240b31ad20f1
java.lang.NullPointerException
in compute_mro (gen/jvm/Metamodel.nqp:1240)
in compose (gen/jvm/Metamodel.nqp:3972)
in <anon> (gen/jvm/World.nqp:3355)
in <anon> (gen/jvm/World.nqp:5474)
in ex-handle (gen/jvm/World.nqp:5472)
in pkg_compose (gen/jvm/World.nqp:3355)
in package_def (gen/jvm/Actions.nqp:3247)
in !reduce (gen/jvm/stage2/QRegex.nqp:1607)
in !cursor_pass (gen/jvm/stage2/QRegex.nqp:1550)
View class-qualified.p6
role R {
has $!a = 0;
method inc-a { $!a++ };
method a { $!a }
method info {
say "R::info ::?CLASS: ", ::?CLASS;
}
}
View proxy-bench.p6
use Bench;
my $rcnt = 0;
my $wcnt = 0;
class C {
has $.a is rw;
has $.b is rw;
submethod TWEAK {
my $a;