excessive memcpy() calls?
От | Alan Stange |
---|---|
Тема | excessive memcpy() calls? |
Дата | |
Msg-id | 3D503421.3010306@rentec.com обсуждение исходный текст |
Список | pgsql-hackers |
Hello all, we have a fairly complicated query that we thought might run a bit faster, so ran postgress under a profiler. We're running on Solaris 8 using the Sun Forte 7 compilers and it's profiler tools that can collect execution profiles on a clock based profile as well as various hardware counter overflow profiles. The database is fairly small at 800MB in size. Using the collected data and poking around a bit it looks like memcpy() is being called a lot of times. The total run time for the query is 223 cpu seconds of which 15.3 is in memcpy(). Of these 15 seconds, 6.8 comes from LogicalTapeRead() and 4 from BufFileRead(). Now here's the rub: LogicalTapeRead() calls ltsReadBlock() which calls BufFileRead() which calls BufFileLoadBuffer() which calls FileRead(). FileRead() actually calls the read() system call which puts the relevant bytes into a buffer in user space (and involves a copy of the data). Working our way back up the call chain, BufFileRead()calls memcpy(), performing another copy of the bytes into a second buffer. Going further back up the call chain we find that LogicalTapeRead() again calls memcpy() copying the bytes a *third* time into another buffer. Is it possible that one of these copies can be removed? It seems to me that one can be, but I'm only looking at the source for the first time and perhaps I'm missing something. Yes, I know, this is only 6% of the cpu time, but memory busses are relatively slow and this copying is probably flushing some cpu cache as well. -- Alan stange@rentec.com
В списке pgsql-hackers по дате отправления: