cheney.net
域名年龄: 22年9个月6天HTTP/1.1 200 OK 服务器:nginx/1.2.1 访问时间:2014年11月25日 03:03:31 类型:text/html; charset=UTF-8 Transfer-Encoding: chunked 连接:keep-alive 语言环境:PHP/5.4.35-0+deb7u2 X-Pingback: http://dave.cheney.net/xmlrpc.php Content-Encoding: gzip 网站编码:UTF-8
Dave CheneyUnsafe at any speedMenuSkip to contentHomeProjectsavr11gorilla/httpmantaprofileResources for new Go programmersUnofficial ARM tarballs for GoAboutVisualising dependenciesJuju is a pretty large project. Some of our core packages have large complex dependency graphs and this is undesirable because the packages which import those core packages inherit these dependencies raising the spectre of an inadvertent import loop.Reducing the coupling between our core packages has been a side project for some time for me. I’ve written several tools to try to help with this, including a recapitulation of the venerable graphviz wrapper.However none of these tools were particularly useful, in fact the graphical tools I wrote became unworkable visually well before their textual counterparts — at least you can grep the output of go list to verify if a package is part of the import set of not.Visualising the import graphI’d long had a tab in my browser open reminding me to find an excuse to play with d3. After a few false starts I came up with tool that took a package import path and produced a graph of the imports.math/rand tree graphIn this simple example showing math/rand importing its set of five packages, the problem with my naive approach is readily apparent — unsafe is present three times.This repetition is both correct, each time unsafe is mentioned it is because its parent package directly imports it, and incorrect as unsafe does not appear three times in the final binary.After sharing some samples on twitter, rf and Russ Cox suggested that if an import was mentioned at several levels of the tree it could be pushed down to the lowest limb without significant loss of information. This is what the same graph looks like with a simple attempt to implement this push down logic.math/rand pushdown treeThis approach, or at least my implementation of it, was successful in removing some duplication. You can see that the import of unsafe by sync has been pruned as sync imports sync/atomic which in turn imports unsafe.However, there remains the second occurrence of unsafe rooted in an unrelated part of the tree which has not been eliminated. Still, it was better than the original method, so I kept it and moved on to graphing more complex trees.crypto/rand pushdown treeIn this example, crypto/rand, though the pushdown transformation has been applied, the number of duplicated imports is overwhelming. What I realised looking at this graph was even though pushdown was pruning single limbs, there are entire forks of the import graph repeated many times. The clusters starting at sync, or io are heavily duplicated.While it might be possible to enhance pushdown to prune duplicated branches of imports, I decided to abandon this method because this aggressive pruning would ultimately reduce the import grpah to a trunk with individual imports jutting out as singular limbs.While an interested idea, I felt that it would obscure the information I n
© 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询
2025-05-02 08:08, Process in 0.0047 second.