Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Last active August 5, 2017 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/685b627a6a2749483dc5ec09c6a777a4 to your computer and use it in GitHub Desktop.
Save MasterDuke17/685b627a6a2749483dc5ec09c6a777a4 to your computer and use it in GitHub Desktop.
constant RAKUDO = './rakudo'.IO.absolute; # TODO should depend on the backend
srand(1);
sub get-similar($tag-or-hash, @other?, :$repo=RAKUDO) {
my @options = @other;
my @tags = get-output(cwd => $repo, 'git', 'tag',
'--format=%(*objectname)/%(objectname)/%(refname:strip=2)',
'--sort=-taggerdate')<output>.lines
.map(*.split('/'))
.grep({ build-exists: .[0] || .[1] })
.map(*[2]);
my $cutoff = $tag-or-hash.chars max 7;
my @commits = get-output(cwd => $repo, 'git', 'rev-list',
'--all', '--since=2014-01-01')<output>
.lines.map(*.substr: 0, $cutoff);
# flat(@options, @tags, @commits).min: { sift4($_, $tag-or-hash, 5, 8) }
my $ans = 'HEAD';
my $ans_min = ∞;
for flat @options, @tags, @commits {
my $dist = rand * 4;
if $dist < $ans_min {
$ans = $_;
$ans_min = $dist;
}
}
$ans
}
sub get-output(*@run-args, :$timeout = 5, :$stdin, :$ENV, :$cwd = $*CWD) {
my @lines;
my $proc = Proc::Async.new: |@run-args, w => defined $stdin;
my $s-start = now;
my $result;
my $s-end;
react {
whenever $proc.stdout { @lines.push: $_ }; # RT #131763
whenever $proc.stderr { @lines.push: $_ };
whenever Promise.in($timeout) {
$proc.kill; # TODO sends HUP, but should kill the process tree instead
@lines.push: «timed out after $timeout seconds»
}
whenever $proc.start: :$ENV, :$cwd { #: scheduler => BEGIN ThreadPoolScheduler.new { # TODO do we need to set scheduler?
$result = $_;
$s-end = now;
done
}
with $stdin {
whenever $proc.print: $_ { $proc.close-stdin }
}
}
%(
output => @lines.join.chomp,
exit-code => $result.exitcode,
signal => $result.signal,
time => $s-end - $s-start,
)
}
my $a;
for ^20 {
$a = get-similar(~$_);
}
say $a;
================================================================================================
This is Rakudo Perl 6 running in valgrind, a tool for debugging and profiling programs.
Running a program in valgrind usually takes *a lot* more time than running it directly,
so please be patient.
This Rakudo version is 2017.07.132.gabf.1.cfe.72 built on MoarVM version 2017.07.322.gda.4.d.2218,
running on ubuntu (17.04.Zesty.Zapus) / linux (4.10.0.28.generic)
------------------------------------------------------------------------------------------------
==21618== Memcheck, a memory error detector
==21618== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==21618== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==21618== Command: /home/dan/Source/perl6/install/bin/moar --full-cleanup --execname=./install/bin/perl6-valgrind-m --libpath=/home/dan/Source/perl6/install/share/nqp/lib --libpath=/home/dan/Source/perl6/install/share/perl6/lib --libpath=/home/dan/Source/perl6/install/share/perl6/runtime /home/dan/Source/perl6/install/share/perl6/runtime/perl6.moarvm go.p6
==21618==
e154644
==21618==
==21618== Process terminating with default action of signal 6 (SIGABRT)
==21618== at 0x565A77F: raise (raise.c:58)
==21618== by 0x565C379: abort (abort.c:89)
==21618== by 0x50A4716: uv_mutex_destroy (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x5015921: gc_free (ConcBlockingQueue.c:72)
==21618== by 0x4FE6F85: MVM_gc_collect_free_gen2_unmarked (collect.c:699)
==21618== by 0x4FE34E1: MVM_gc_global_destruction (orchestrate.c:542)
==21618== by 0x5084E91: MVM_vm_destroy_instance (moar.c:443)
==21618== by 0x109239: main (main.c:261)
==21618==
==21618== HEAP SUMMARY:
==21618== in use at exit: 249,548,005 bytes in 198,634 blocks
==21618== total heap usage: 752,392 allocs, 553,758 frees, 2,233,712,202 bytes allocated
==21618==
==21618== 64 (40 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 631 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x501C91F: MVM_malloc (alloc.h:2)
==21618== by 0x501C91F: MVM_decoder_configure (Decoder.c:131)
==21618== by 0x4FC3A76: MVM_interp_run (interp.c:5061)
==21618== by 0x5084D11: MVM_vm_run_file (moar.c:356)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== 144 bytes in 3 blocks are possibly lost in loss record 889 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4FD4519: MVM_calloc (alloc.h:11)
==21618== by 0x4FD4519: MVM_load_bytecode (loadbytecode.c:69)
==21618== by 0x4FBC704: MVM_interp_run (interp.c:3200)
==21618== by 0x5084D11: MVM_vm_run_file (moar.c:356)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== 272 bytes in 1 blocks are possibly lost in loss record 1,013 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4013BAA: allocate_dtv (dl-tls.c:322)
==21618== by 0x4013BAA: _dl_allocate_tls (dl-tls.c:539)
==21618== by 0x5CFD29B: allocate_stack (allocatestack.c:586)
==21618== by 0x5CFD29B: pthread_create@@GLIBC_2.2.5 (pthread_create.c:663)
==21618== by 0x50A465F: uv_thread_create (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x4FD244E: MVM_thread_run (threads.c:156)
==21618== by 0x50847CB: MVM_vm_create_instance (moar.c:301)
==21618== by 0x10917E: main (main.c:236)
==21618==
==21618== 272 bytes in 1 blocks are possibly lost in loss record 1,014 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4013BAA: allocate_dtv (dl-tls.c:322)
==21618== by 0x4013BAA: _dl_allocate_tls (dl-tls.c:539)
==21618== by 0x5CFD29B: allocate_stack (allocatestack.c:586)
==21618== by 0x5CFD29B: pthread_create@@GLIBC_2.2.5 (pthread_create.c:663)
==21618== by 0x50A465F: uv_thread_create (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x4FD244E: MVM_thread_run (threads.c:156)
==21618== by 0x4FE9C21: get_or_vivify_loop (eventloop.c:128)
==21618== by 0x4FE9C21: MVM_io_eventloop_queue_work (eventloop.c:151)
==21618== by 0x4FF05F2: MVM_io_timer_create (timers.c:85)
==21618== by 0x4FB29C5: MVM_interp_run (interp.c:4202)
==21618== by 0x5084D11: MVM_vm_run_file (moar.c:356)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== 392 bytes in 7 blocks are possibly lost in loss record 1,065 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x5071C6C: MVM_malloc (alloc.h:2)
==21618== by 0x5071C6C: generate_unicode_property_values_hashes (unicode.c:73188)
==21618== by 0x5071C6C: MVM_unicode_init (unicode.c:73266)
==21618== by 0x50843B4: MVM_vm_create_instance (moar.c:145)
==21618== by 0x10917E: main (main.c:236)
==21618==
==21618== 448 bytes in 8 blocks are possibly lost in loss record 1,095 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x507205B: MVM_malloc (alloc.h:2)
==21618== by 0x507205B: generate_unicode_property_values_hashes (unicode.c:73194)
==21618== by 0x507205B: MVM_unicode_init (unicode.c:73266)
==21618== by 0x50843B4: MVM_vm_create_instance (moar.c:145)
==21618== by 0x10917E: main (main.c:236)
==21618==
==21618== 864 bytes in 18 blocks are possibly lost in loss record 1,211 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4FD4519: MVM_calloc (alloc.h:11)
==21618== by 0x4FD4519: MVM_load_bytecode (loadbytecode.c:69)
==21618== by 0x4FBC704: MVM_interp_run (interp.c:3200)
==21618== by 0x5084CEB: MVM_vm_run_file (moar.c:338)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== 2,176 bytes in 8 blocks are possibly lost in loss record 1,365 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4013BAA: allocate_dtv (dl-tls.c:322)
==21618== by 0x4013BAA: _dl_allocate_tls (dl-tls.c:539)
==21618== by 0x5CFD29B: allocate_stack (allocatestack.c:586)
==21618== by 0x5CFD29B: pthread_create@@GLIBC_2.2.5 (pthread_create.c:663)
==21618== by 0x50A465F: uv_thread_create (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x4FD244E: MVM_thread_run (threads.c:156)
==21618== by 0x4FB3CB8: MVM_interp_run (interp.c:4033)
==21618== by 0x5084D11: MVM_vm_run_file (moar.c:356)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== 2,176 bytes in 8 blocks are possibly lost in loss record 1,366 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x4013BAA: allocate_dtv (dl-tls.c:322)
==21618== by 0x4013BAA: _dl_allocate_tls (dl-tls.c:539)
==21618== by 0x5CFD29B: allocate_stack (allocatestack.c:586)
==21618== by 0x5CFD29B: pthread_create@@GLIBC_2.2.5 (pthread_create.c:663)
==21618== by 0x50A465F: uv_thread_create (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x4FD244E: MVM_thread_run (threads.c:156)
==21618== by 0x4FB3CB8: MVM_interp_run (interp.c:4033)
==21618== by 0x4FD21E5: start_thread (threads.c:81)
==21618== by 0x50A4616: uv__thread_start (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x5CFC6D9: start_thread (pthread_create.c:456)
==21618==
==21618== 2,992 bytes in 374 blocks are definitely lost in loss record 1,398 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x504690D: MVM_malloc (alloc.h:2)
==21618== by 0x504690D: plan_for_cs (plan.c:64)
==21618== by 0x5046A3B: plan_for_sf (plan.c:95)
==21618== by 0x5046BEF: MVM_spesh_plan (plan.c:133)
==21618== by 0x504456B: worker (worker.c:13)
==21618== by 0x4FD2180: thread_initial_invoke (threads.c:57)
==21618== by 0x4FB0AFE: MVM_interp_run (interp.c:88)
==21618== by 0x4FD21E5: start_thread (threads.c:81)
==21618== by 0x50A4616: uv__thread_start (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x5CFC6D9: start_thread (pthread_create.c:456)
==21618==
==21618== 8,904 bytes in 230 blocks are definitely lost in loss record 1,562 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x504684C: MVM_malloc (alloc.h:2)
==21618== by 0x504684C: copy_type_tuple (plan.c:41)
==21618== by 0x5046931: plan_for_cs (plan.c:66)
==21618== by 0x5046A3B: plan_for_sf (plan.c:95)
==21618== by 0x5046BEF: MVM_spesh_plan (plan.c:133)
==21618== by 0x504456B: worker (worker.c:13)
==21618== by 0x4FD2180: thread_initial_invoke (threads.c:57)
==21618== by 0x4FB0AFE: MVM_interp_run (interp.c:88)
==21618== by 0x4FD21E5: start_thread (threads.c:81)
==21618== by 0x50A4616: uv__thread_start (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x5CFC6D9: start_thread (pthread_create.c:456)
==21618==
==21618== 54,848 (54,720 direct, 128 indirect) bytes in 1,368 blocks are definitely lost in loss record 1,815 of 1,973
==21618== at 0x4C2FB45: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x504495E: MVM_calloc (alloc.h:11)
==21618== by 0x504495E: stats_for (stats.c:7)
==21618== by 0x5045B6C: MVM_spesh_stats_update (stats.c:523)
==21618== by 0x5044459: worker (worker.c:13)
==21618== by 0x4FD2180: thread_initial_invoke (threads.c:57)
==21618== by 0x4FB0AFE: MVM_interp_run (interp.c:88)
==21618== by 0x4FD21E5: start_thread (threads.c:81)
==21618== by 0x50A4616: uv__thread_start (in /home/dan/Source/perl6/install/lib/libmoar.so)
==21618== by 0x5CFC6D9: start_thread (pthread_create.c:456)
==21618==
==21618== 190,176 bytes in 3,396 blocks are possibly lost in loss record 1,898 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x50715AC: MVM_malloc (alloc.h:2)
==21618== by 0x50715AC: generate_unicode_property_values_hashes (unicode.c:73173)
==21618== by 0x50715AC: MVM_unicode_init (unicode.c:73266)
==21618== by 0x50843B4: MVM_vm_create_instance (moar.c:145)
==21618== by 0x10917E: main (main.c:236)
==21618==
==21618== 213,024 bytes in 3,804 blocks are possibly lost in loss record 1,902 of 1,973
==21618== at 0x4C2DB2F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==21618== by 0x5070949: MVM_malloc (alloc.h:2)
==21618== by 0x5070949: generate_property_codes_by_names_aliases (unicode.c:73136)
==21618== by 0x5070949: MVM_unicode_name_to_property_code (unicode.c:73160)
==21618== by 0x4FB8D30: MVM_interp_run (interp.c:1654)
==21618== by 0x5084D11: MVM_vm_run_file (moar.c:356)
==21618== by 0x10941E: main (main.c:253)
==21618==
==21618== LEAK SUMMARY:
==21618== definitely lost: 66,656 bytes in 1,973 blocks
==21618== indirectly lost: 152 bytes in 8 blocks
==21618== possibly lost: 409,944 bytes in 7,254 blocks
==21618== still reachable: 249,071,253 bytes in 189,399 blocks
==21618== suppressed: 0 bytes in 0 blocks
==21618== Reachable blocks (those to which a pointer was found) are not shown.
==21618== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==21618==
==21618== For counts of detected and suppressed errors, rerun with: -v
==21618== ERROR SUMMARY: 14 errors from 14 contexts (suppressed: 0 from 0)
Aborted (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment