Posts tagged:

perl

Fast datetimes in MongoDB

Oct 1 • Posted 1 year ago

This was originally posted to Mike Friedman’s blog. Mike is a Perl Evangelist at 10gen, working on the Perl Driver for MongoDB One of the most common complaints about the Perl MongoDB driver is that it tries to be a little too clever. In the current production release of MongoDB.pm (version 0.46.2 as of this writing), all datetime values retrieved by a query are automatically instantiated as DateTime objects. DateTime is a remarkable CPAN distribution. In fact, I would say that DateTime and its related distributions on CPAN comprise one of the best date and time manipulation libraries in any programming language. But that power comes with a cost. The DateTime codebase is large, and instantiating DateTime objects is expensive. The constructor performs a great deal of validation, and creates a large amouunt of metadata which is stored inside the object. Upcoming changes to the Perl MongoDB driver solve this problem. Read more below. If you need to perform a series of complex arithmetic operations with dates, then the cost of DateTime is justified. But frequently, all you want is a simple read-only value that is sufficient for displaying to a user or saving elsewhere. If you are running queries involving a large number of documents, the automatic instantiation of thousands of complex objects becomes barrier to performance.

Read more

Perl Driver 0.46.1 Released

Sep 5 • Posted 1 year ago

This was originally posted to Mike Friedman’s personal blog

I’m happy to announce that after a long delay, version 0.46.1 of the Perl MongoDB driver has now been uploaded to CPAN, and should be available on your friendly local CPAN mirror soon.

This release is mostly a series of minor fixes and housekeeping, in preparation for developing a more detailed roadmap for more frequent releases down the line. Here’s what’s new so far:

Most of the distribution has been successfully transitioned to Dist::Zilla for automated building, tagging, and releasing to CPAN. This has vastly reduced the amount of effort needed to get releases out the door.

The behind-the-scenes algorithm for validating UTF-8 strings has been replaced with a more compliant and much faster version. Thanks to Jan Anderssen for contributing the fix.

Serialization of regexes has been improved and now supports proper stripping of unsupported regex flags across all recent Perl versions. Thanks to Arkadiy Kukarkin for reporting the bug and @ikegami for help with figuring out how to serialize regexes properly via the Perl API.

The driver will now reject document key names with NULL bytes, a possible source of serious bugs. Additionally, much of the distribution metadata has been cleaned up, thanks to the automation provided by Dzil. In particular, the official distribution repository and bug-tracker links now point to our GitHub and JIRA sites. Hopefully more bugs will now come in via those channels instead of RT.

Looking ahead, there is a lot of work yet to be done. I have prioritized the following tasks for version 0.47, which should help us moving forward to an eventual 1.0 release.

  • Eliminating the dependency on Module::Install
  • Significantly re-working the documentation to include better organization and more examples.
  • Additionally, much of the current documentation will be refactored via Pod::Weaver.
  • Replacing AUTOLOADed database and collection methods with safer generated symbols upon connection. Beginning with 0.48, these will have a deprecation warning added and will be removed entirely before the 1.0 release in favor of the get_database and get_collection methods. The docs will be updated to reflect this change.

I’m very excited about the future of MongoDB support for Perl, and looking forward to improving the CPAN distribution in concert with the Perl community!

Mike Friedman is the Perl Engineer and Evangelist at 10gen, working on the Perl Driver for MongoDB. You can follow his blog at friedo.com

blog comments powered by Disqus