Hello! OSD already has some useful asok commands in the matter of memory profiling / stats (`get_heap_property`, `heap` -- please take a look on OSD.cc where these cmds are registered). Maybe they would suit your use-case better than printing to a log in `tick()`. Regards, Radek On Sat, Nov 11, 2023 at 4:27 AM Suyash Dongre <suyashd999@xxxxxxxxx> wrote: > > Hi guys!This is a function for MDS (src/mds/MDCache.cc) that prints out the rss and other memory stats every couple seconds at debug level 2.I am trying to create a similar function for printing memory and other stats for OSD. (will be adding the code in src/osd/OSD:tick() function),can anyone provide a basic guidelines about what all classes, functions I will need to use and what all will I require for achieving so?Any help would be extremely valuable, Thanks for your time! > > void MDCache::check_memory_usage() > { > static MemoryModel mm(g_ceph_context); > static MemoryModel::snap last; > mm.sample(&last); > static MemoryModel::snap baseline = last; > > // check client caps > ceph_assert(CInode::count() == inode_map.size() + snap_inode_map.size() + num_shadow_inodes); > double caps_per_inode = 0.0; > if (CInode::count()) > caps_per_inode = (double)Capability::count() / (double)CInode::count(); > > dout(2) << "Memory usage: " > << " total " << last.get_total() > << ", rss " << last.get_rss() > << ", heap " << last.get_heap() > << ", baseline " << baseline.get_heap() > << ", " << num_inodes_with_caps << " / " << CInode::count() << " inodes have caps" > << ", " << Capability::count() << " caps, " << caps_per_inode << " caps per inode" > << dendl; > > mds->update_mlogger(); > mds->mlogger->set(l_mdm_rss, last.get_rss()); > mds->mlogger->set(l_mdm_heap, last.get_heap()); > } > > _______________________________________________ > Dev mailing list -- dev@xxxxxxx > To unsubscribe send an email to dev-leave@xxxxxxx _______________________________________________ Dev mailing list -- dev@xxxxxxx To unsubscribe send an email to dev-leave@xxxxxxx