diff --git a/NativeBridgeMetalFrontend.mm b/NativeBridgeMetalFrontend.mm index ca0900f..1587a6c 100644 --- a/NativeBridgeMetalFrontend.mm +++ b/NativeBridgeMetalFrontend.mm @@ -312,8 +312,8 @@ static void sampleWriteProfile(uint32_t &consumed,int &fd,const char *const *pat if(!dup){seen[count++]=name;inclusiveMap[name]++;} } } - if(++rounds%12)return; - if(fd<0)for(int i=0;i<2 && fd<0;i++)fd=open(paths[i],O_WRONLY|O_CREAT|O_TRUNC,0644); + if(++rounds%12 || !total)return; // a process that never sampled must not overwrite the one that did + if(fd<0)for(int i=0;i<2 && fd<0;i++)fd=open(paths[i],O_WRONLY|O_CREAT,0644); // no O_TRUNC: the file keeps its fixed size if(fd<0)return; auto top=[&](std::unordered_map &map,char tag,unsigned limit,std::string &out) { std::vector> rows;