_dl_runtime_resolve - 共享对象何时被加载到内存? [英] _dl_runtime_resolve -- When do the shared objects get loaded in to memory?

查看:820
本文介绍了_dl_runtime_resolve - 共享对象何时被加载到内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个具有高性能需求的消息处理系统。最近我们注意到,第一个消息比后续消息花费的时间长很多倍。一堆变换和消息增加发生在这通过我们的系统,大部分是通过外部lib完成。

We have a message processing system with high performance demands. Recently we have noticed that the first message takes many times longer then subsequent messages. A bunch of transformation and message augmentation happens as this goes through our system, much of it done by way of external lib.

我刚刚剖析这个问题(使用callgrind),比较一个消息的运行和许多消息的运行(提供比较的基线)。

I just profiled this issue (using callgrind), comparing a "run" of just one message with a "run" of many messages (providing a baseline of comparison).

我看到的主要区别是函数do_lookup_x占用了大量的时间。看看对这个函数的各种调用,他们似乎都被公共函数调用:_dl_runtime_resolve。不知道这个函数是什么,但对我来说,这看起来像是第一次使用各种共享库,然后由ld加载到内存。

The main difference I see is the function "do_lookup_x" taking up a huge amount of time. Looking at the various calls to this function, they all seem to be called by the common function: _dl_runtime_resolve. Not sure what this function does, but to me this looks like the first time the various shared libraries are being used, and are then being loaded in to memory by the ld.

这是正确的假设吗?二进制文件将不会将共享库加载到内存中,直到它们准备使用,因此我们将看到第一个消息大大减速,但没有后续?

Is this a correct assumption? That the binary will not load the shared libraries in to memory until they are being prepped for use, therefore we will see a massive slowdown on the first message, but on none of the subsequent?

我们如何避免这种情况?

How do we go about avoiding this?

注意:我们的操作范围是微秒级。

Note: We operate on the microsecond scale.

推荐答案

ld.so(8)手册页, ENVIRONMENT 部分:

   LD_BIND_NOW
          (libc5;  glibc since 2.1.1) If set to a non-empty string, causes
          the dynamic linker to resolve all  symbols  at  program  startup
          instead  of deferring function call resolution to the point when
          they are first referenced.  This is useful when using  a  debug-
          ger.

因此, LD_BIND_NOW = y ./timesensitiveapp

这篇关于_dl_runtime_resolve - 共享对象何时被加载到内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆