Hello, It seems that nothing is happening on the snow leopard front. This is something that has to be solved ASAP (1.6.4.2?)
The patch nofork.diff just disables forking altogether on Mac OS X. This is definitely a bit rude. If somebody tells me how to determine the OS version at runtime, I can update the patch. I'd appreciate if somebody could try this patch out. The bad part about disabling fork(), as Vincent pointed out, is that there is a noticeable delay at each autosave. I took my profiler and determined that, on linux, this delay is due the the call to to_utf8 which is done for each character. The following patch buffers plain characters into strings and yield a nice speedup. Some Shark profiles on Mac OS X could be useful too. The way I tested was 1/ load user guide 2/ M-x to open minibuffer 3/ run command repeat 60 command-sequence self-insert a ; undo ; buffer-write I also tried to add a big buffer to the ofstream we are using, but this did not really work. JMarc
svndiff src/support/ForkedCalls.cpp Index: src/support/ForkedCalls.cpp =================================================================== --- src/support/ForkedCalls.cpp (révision 31676) +++ src/support/ForkedCalls.cpp (copie de travail) @@ -192,7 +192,13 @@ void ForkedProcess::kill(int tol) pid_t ForkedProcess::fork() { -#if !defined (HAVE_FORK) +/* FIXME fork() is not usable on Mac OS X 10.6 (snow leopard) + * Use something else like threads. + * + * Since I do not know how to determine at run time what is the OS X + * version, I just disable forking altogether for now (JMarc) + */ +#if !defined (HAVE_FORK) || defined(__APPLE__) return -1; #else pid_t pid = ::fork();
svndiff src/Paragraph.cpp Index: src/Paragraph.cpp =================================================================== --- src/Paragraph.cpp (révision 31676) +++ src/Paragraph.cpp (copie de travail) @@ -90,6 +90,8 @@ public: /// void insertChar(pos_type pos, char_type c, Change const & change); + /// + void flushWriteBuffer(ostream & os); /// Output the surrogate pair formed by \p c and \p next to \p os. /// \return the number of characters written. @@ -213,6 +215,8 @@ public: Words words_; /// Layout const * layout_; + /// Use as a buffer in Paragraph::write + docstring write_buffer_; }; @@ -1168,6 +1172,13 @@ Paragraph::~Paragraph() } +void Paragraph::Private::flushWriteBuffer(ostream & os) +{ + os << to_utf8(write_buffer_); + write_buffer_.erase(); +} + + void Paragraph::write(ostream & os, BufferParams const & bparams, depth_type & dth) const { @@ -1199,6 +1210,8 @@ void Paragraph::write(ostream & os, Buff for (pos_type i = 0; i <= size(); ++i) { Change const change = lookupChange(i); + if (change != running_change) + d->flushWriteBuffer(os); Changes::lyxMarkChange(os, bparams, column, running_change, change); running_change = change; @@ -1209,6 +1222,7 @@ void Paragraph::write(ostream & os, Buff Font font2 = getFontSettings(bparams, i); font2.setMisspelled(false); if (font2 != font1) { + d->flushWriteBuffer(os); font2.lyxWriteChanges(font1, os); column = 0; font1 = font2; @@ -1218,6 +1232,7 @@ void Paragraph::write(ostream & os, Buff switch (c) { case META_INSET: if (Inset const * inset = getInset(i)) { + d->flushWriteBuffer(os); if (inset->directWrite()) { // international char, let it write // code directly so it's shorter in @@ -1234,10 +1249,12 @@ void Paragraph::write(ostream & os, Buff } break; case '\\': + d->flushWriteBuffer(os); os << "\n\\backslash\n"; column = 0; break; case '.': + d->flushWriteBuffer(os); if (i + 1 < size() && d->text_[i + 1] == ' ') { os << ".\n"; column = 0; @@ -1247,13 +1264,14 @@ void Paragraph::write(ostream & os, Buff default: if ((column > 70 && c == ' ') || column > 79) { + d->flushWriteBuffer(os); os << '\n'; column = 0; } // this check is to amend a bug. LyX sometimes // inserts '\0' this could cause problems. if (c != '\0') - os << to_utf8(docstring(1, c)); + d->write_buffer_.push_back(c); else LYXERR0("NUL char in structure."); ++column; @@ -1261,6 +1279,7 @@ void Paragraph::write(ostream & os, Buff } } + d->flushWriteBuffer(os); os << "\n\\end_layout\n"; }