Re: Finding slowdowns in pkg_install (continuations

看板FB_hackers作者時間18年前 (2007/07/24 10:54), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
> -I tried ... buffering ... the +CONTENTS file parsing function, and the > majority of the time it yielded good results .... One approach I prototyped sometime back was to use libarchive in pkg_add as follows: * Open the archive * Read +CONTENTS directly into memory (it's guaranteed to always be first in the archive) * Parse all of +CONTENTS at once * Continue scanning the archive, disposing of each file as it appears in the archive. Based on my experience with this, I would suggest you just read all of +CONTENTS directly into memory at once and parse the whole thing in a single shot. fopen(), then fstat() to get the size, then allocate a buffer and read the whole thing, then fclose(). You can then parse it all at once. As a bonus, your parser then becomes a nice little bit of reusable code that reads a block of memory and returns a structure describing the package metadata. Tim Kientzle _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
文章代碼(AID): #16fMdi00 (FB_hackers)
文章代碼(AID): #16fMdi00 (FB_hackers)