Baby Moose all Clean

Code clean-up day here in the Moose-pen.

After adding in a few ENV flags in yesterday's post I better get back on track and fix the 16 test cases I broke in this post.

The thing I had to do was modify the 'Database::Accessor::Driver::Test', (remember this one? my DAD for testing), so it returned a 'Database::Accessor::Result' class and the was easy enough and in now looks like

An interesting memory hog

So last day I with a colleague got to trace an interesting memory leak ( which was rather a memory waste than a leak ). It was using tens of gigabytes of RAM, whereas I wouldn't expect it to use more than 3-4GB.

Call it a witchcraft if you like, but we identified line to blame within first minutes we started looking at the problem. Unfortunately, we were not able to convince each other that it is the issue and as the problem was only visible in a long running soak test we were not able to justify running it.

Perl's garbage collection works by reference counting and only frees circular references at exit. As we were dealing with a long running daemon - we started by trying to locate circular references. Inspecting code gave nothing away. So we decided to utilise wonderful Paul Evans' Devel::MAT module. Unfortunately we were not able to locate any circular references.

Virtual Spring Cleaning (part 1 of XX / 2017) - in which I hear CPANs call

Virtual Spring Cleaning (part 1 of XX / 2017) - in which I look who's calling

I really like the products by AVM, especially their Fritz!Box line of VoIP+DSL modems. For a long time, I've wanted to synchronize my CardDAV contacts from my server to my Fritz!Box, so that the reverse number lookup works on my landline as well as my mobile phone.

Perl 5 Porters Mailing List Summary: April 4th-10th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week.

Enjoy!

Baby Moose Enviornment

Well is environment day here in the Moose-pen

Today I was going to take on that big test fail mess from yesterday's post but before I go too far along I was troubled by this code change;

my $user   = Test::DB::User->new();
--my $result = $user->create($utils->connect(),$container); 
++my $result = $user->create($utils->connect(),$container,{raw_query=>1});
Getting warning or debugging to fire off like the above may cause a good dela of trouble to some future programmer. Even in the best case scenario they still have to have edit the code and re-run it to see that SQL, not a good situation. As I see it I will have to make a few changes yet again to Accessor.pm.

Dependency phases in CPAN distribution metadata

In the previous article in this series we gave a general introduction to the distribution metadata which is included in releases as files META.json and/or META.yml. In this article I'll drill into more detail at one critical component of a distribution's metadata: dependencies, also known as prerequisites (usually shortened to "prereqs"). This is how you specify other CPAN modules that your distribution depends on.

This post is brought to you by Booking.com, a platinum sponsor for the Perl Toolchain Summit. Booking.com is one of the largest Perl shops in the world, and so depends heavily on the toolchain. Thank you to Booking.com for supporting the summit.

Dist::Zilla @Starter - Revision 2

I recently released revision 2 of the [@Starter] plugin bundle for Dist::Zilla. This revision brings small improvements to the default behavior, as well as the option to set a different installer plugin. In order to use the new revision, you must set the option "revision = 2" when using the bundle.

Revision 2 uses [Pod2Readme] instead of [ReadmeAnyFromPod] to generate the text README file. [ReadmeAnyFromPod] is a great and flexible plugin, but [Pod2Readme] is much simpler for the specific purpose of generating a text README. For any additional README files in other formats, I still recommend using [ReadmeAnyFromPod].

This revision also sets the option "inherit_version" in [MetaProvides::Package] to 0 by default. This makes no difference if your distribution contains uniform module versions, or for modules which have no version (they are still marked as having the distribution version unless you set "inherit_missing" to 0 as well), but if you have modules with different versions hardcoded, this will reflect that in the "provides" metadata.

Virtual Spring Cleaning Prelude: What I did, and what hasn't happened so far

While trying to get some more of my modules ready for release, I've been doing drive-by patches to CPAN modules that I used for various reasons. While I'm not exactly enthused about throwing a patch with a testcase over the fence, I think it's still far better to have the problem and solution in some bug tracker somewhere than having it only on my hard drive.

Tail Wags Baby Moose

Still Accessor.pm day here in the Moose::Pen.

In yesterday's post I was playing about with the 'raw_query' sub in Driver::DBI and that lead me back into Accessor.pm to make a few changes there. You might remember I had this as a final result in Accessor.pm

Better SQL tracing with DBIx::Class

I've been trying to track down some SQL issues with Tau Station and to be honest, I've never been terribly happy with the output from the DBIx::Class DBIC_TRACE or the DBI DBI_TRACE. So I have something better.

Good code style of DBIx::Custom at 2017

DBIx::Custom is good DBI wrapper to insert, update, delete, select easily and clean.

I introduce good code style of DBIx::Custom at 2017.

Connect


  my $dbi = DBIx::Custom->connect("dbi:mysql:database=dbname", 'ken', '! LFKD% $&');

Create model

It is good to create model.


  $dbi->create_model('book'); 

Execute SQL

Because model is used, insert, update, delete, select is very clean.


You won't believe this one quick Perl 6 optimization hack!

Now that I've alienated half the crowd, here's the scoop. Perl6::Parser has a fairly extensive test suite, which I run on my laptop inside an Ubuntu 14.04 VM - it's the latest version I can find that supports seamless integration, though I'm considering completely dumping the GUI and going with just a few SSH connections.

But enough of that. Baseline Rakudo Perl 6 currently runs the Perl6::Parser test suite in 0.61s usr, 0.07s sys + 80s cusr time, 90 wallclock seconds, which is rather amazing considering how extensive and invasive the test suite is. After this one simple change, that time dropped from 90 wallclock seconds to 70 wallclock seconds.

If you look at Perl6::Parser::Factory at this version, you'll see a 'role Matchable', which is public and shouldn't be.

Baby Moose Comes Back

Well some Driver::DBI code today in the Moose-Pen.

Carrying on from my last Post where I had created the new sub 'raw_query' and had it testing nicely I started on my merry way to program the Driver::DBI module. Well I did not get very far along.

I started out with creating a get_sql sub that the 'raw_query' would call, but then quickly realized that that would be a little redundant as any time I needed just the SQL I could just call the 'raw_query' and save a sub. So I came up with this.

Integrating alienfile

Last week I introduced the alienfile recipe system and we wrote a simple alienfile that provides the tool xz and the library liblzma. I also showed how to test it using App::af. Today we are going to take that alienfile and integrate it into a fully functional Alien distribution.

The main motiviation for alienfile + Alien::Build was to separate the alien detection and installer code from the perl installer code. (In fact your alienfile is fully usable without any Perl installer at all; you can use your alienfile from a Perl script or Perl module using Alien::Build directly).

For our Alien, we will be creating Alien-xz, and we will use Alien::Build::MM to provide the thin layer of functionality needed between ExtUtils::MakeMaker (EUMM) and Alien::Build. This is what our Makefile.PL should look like:

OrePAN2 Processes MetaCPAN Lookups in Chunks

The issue

In the last month of 2016, I was assigned OrePAN2 in the CPAN Pull Request Challenge. When browsing its issues on GitHub, I discovered #47:

Perl 5 Porters Mailing List Summary: March 28th - April 3rd

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week.

Enjoy!

Baby Moose Grows Strong

Back to Accessor.pm day here in the Moose-Pen.

Starting where I left off in my last post I needed to figure out some way to get the raw query results back from Accessor.pm. I gave this a little though as there are a number of things to consider. First I never want to expose the underlying DAD to the end user of Accessor.pm, Second I have to make the name of call generic in the same way the CRUD calls are. Finally as I see this used largely for debugging it should return more than just a string.

To address the three above I started with an new sub called 'raw_query' ;

DBIx :: Custom 0.39 release - Adding SQL generation feature, and simple generation of model

I released DBIx::Custom 0.39. This time it is a big update. Please do test enough when updating.

DBIx::Custom 0.39

New features

The following features are added in DBIx::Custom 0.39.

SQL generation feature

SQL generation feature was added. You can get only SQL and bind values using the query option. This is corresponding to the feature of SQL::Abstract.


  my $query = $dbi->model('book')->insert({id => 1, name => 'Perl'}, query => 1);
  
  my $sql = $query->sql;
  my $bind_values   = $query->bind_values;

You can use it in combination with other DBI modules. For example, to send an asynchronous query, you can use AnyEvent::DBI and Mojo::Pg.


An introduction to CPAN distribution metadata

All CPAN releases (these days) include a metadata file which has information about the distribution. It can be used by tools like CPAN clients (when installing modules), but it's also helpful for other tool writers, and people analysing the structure of CPAN. The metadata file will be called META.yml or META.json, and recent releases often contain both.

In this blog post we'll introduce some of what's in the files and how they're used by CPAN clients.

This post is brought to you by FastMail, a gold sponsor for this year's Toolchain Summit, which is being held in Lyon, France in May. The summit is only possible with the support of companies like FastMail. We'll be doing a series of toolchain-related blog posts, to thank our sponsors.

CPAN Meta Browser

I've been looking for a better way to access the public CPAN metadata in files such as 02packages.details.txt and 06perms.txt, for checking the module index and CPAN permissions. For the latter you can always sign into https://pause.perl.org but I found that to be inconvenient. So I wrote a simple app that caches these files, converts them into a SQLite database, and then serves query results. You can find the result here: http://cpanmeta.grinnz.com/ and the source on GitHub. If there's any other metadata files that you want to be searchable let me know in a comment or GitHub issue.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.